Labsco
MCP SERVER

PromptThrift MCP

by woling-dev

Compress the older turns of a conversation into a summary, pin the facts that must survive it, and see what each model would cost.

Codebase Context Packing & Compression
Summary
Compression pays off on long conversations, and barely registers on short ones.

The publisher's own rule of thumb is to start after 8-10 turns: a short, dense technical exchange has little filler to strip and gives back 15-25%, while a 30-turn debugging session where only the conclusion matters is where the 70-90% figures come from. The Gemma 4 path costs nothing but spends roughly 10-15 seconds per call, which suits a background trim rather than something sitting in the user's critical path. Pin the facts that must survive before the first compression rather than after it, since the pinned list is what guarantees they appear in every summary that follows.

What it is

A local MCP server aimed at the cost of resending conversation history on every API call. Four tools: compress the older turns into a summary, keep a never-compress list of facts, count tokens and cost across 14 models, and suggest a cheaper model for a simple task. Everything runs on your machine — with Ollama present it compresses using Gemma 4, and without it falls back to rule-based extraction.

What you get
  • promptthrift_compress_history replaces older turns with a summary and leaves the recent ones intact
  • Two compression modes, picked automatically: rule-based extraction is instant and typically removes 50-60%, while Gemma 4 through Ollama takes roughly 10-15 seconds and typically removes 70-90%
  • promptthrift_pin_facts keeps named facts — a customer's allergy, a decision already taken — present in every future summary rather than at the mercy of the compressor
  • promptthrift_count_tokens reports usage and cost across 14 models, from the local Gemma 4 builds at $0.00 up to claude-opus-4.6 at $5.00 per million input tokens
  • promptthrift_suggest_model recommends the cheapest model that still fits the task
  • A post-compression sanitizer strips prompt-injection patterns out of the generated summary before it is fed back into a conversation
Requirements

Python 3.10+. Install with pip install git+https://github.com/woling-dev/promptthrift-mcp.git and launch server.py over stdio. Gemma 4 compression is optional: install Ollama, pull gemma4:e4b, and the server detects it with no configuration. PROMPTTHRIFT_OLLAMA_MODEL, PROMPTTHRIFT_OLLAMA_URL (default http://localhost:11434) and PROMPTTHRIFT_DEFAULT_MODEL (default claude-sonnet-4.6) are all optional. Nothing leaves the machine: no persistent storage, no telemetry, no third-party calls. MIT.

Setup effort

One command — pip install git+https://github.com/woling-dev/promptthrift-mcp.git