context-shrink-mcp

v1.2.0
context-shrink-mcp Checked 4 days ago Published 10 days ago

OpenAI-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, })

ParameterTypeDescription
messages *array
max_context_tokensinteger

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, })

ParameterTypeDescription
messages *array
keep_lastinteger
max_context_tokensinteger

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 })…

ParameterTypeDescription
messages *array
api_key
base_url
forceboolean
keep_lastinteger
max_context_tokensinteger
model
summary
summary_budget_tokensinteger
summary_rolestring
thresholdnumber

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.