context-shrink-mcp
v1.2.0OpenAI-compatible context guard MCP server: estimate, trim and compact a chat history under its context window.
These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.
estimate_context
Estimate the current context size in tokens before sending it to the model. Example call:: estimate_context({ "messages": [{"role": "user", "content": "hello"}], "max_context_tokens": 32768, })
| Parameter | Type | Description |
|---|---|---|
messages * | array | |
max_context_tokens | integer |
trim_context
Trim the oldest messages when the estimated context exceeds the model limit. Example call:: trim_context({ "messages": [...], "keep_last": 8, "max_context_tokens": 32768, })
| Parameter | Type | Description |
|---|---|---|
messages * | array | |
keep_last | integer | |
max_context_tokens | integer |
compact_context
Replace the oldest messages with a summary instead of dropping them. The summary comes from ``summary`` when given, otherwise from the local model via ``model``/``base_url`` (or the CONTEXT_SHRINK_MODEL / CONTEXT_SHRINK_BASE_URL environment variables). With neither, the tool returns a ``needs_summary`` plan plus the exact prompt, and no message content is echoed back. Example call:: compact_context({ "messages": [...], "keep_last": 8, "threshold": 0.8, "summary": "…", # omit to summarise with the model })…
| Parameter | Type | Description |
|---|---|---|
messages * | array | |
api_key | ||
base_url | ||
force | boolean | |
keep_last | integer | |
max_context_tokens | integer | |
model | ||
summary | ||
summary_budget_tokens | integer | |
summary_role | string | |
threshold | number |
describe_config
Report the resolved configuration without changing anything. Shows the context window every tool will use and where it came from: ``cli`` (``--max-context``), ``env`` (``*_MAX_CONTEXT_TOKENS``), or ``default`` (``32768``). Extra header names are listed, never their values.