Skip to main content

MCP Server

ContextCrumb includes an MCP stdio server with two tools:

compress_text
compress_file

Install MCP dependencies:

pip install "contextcrumb[mcp]"

Or run with uvx:

uvx --from "contextcrumb[mcp]" contextcrumb-mcp

MCP Client Config

Use this pattern for clients that accept JSON MCP server config:

{
"mcpServers": {
"contextcrumb": {
"command": "uvx",
"args": [
"--from",
"contextcrumb[mcp]",
"contextcrumb-mcp"
]
}
}
}

Tool: compress_text

Arguments:

ArgumentDefaultMeaning
textrequiredInline text to compress
threshold0.5Keep probability cutoff for threshold mode
target_keep_rationullFixed token budget; overrides threshold mode
goldentrueDeprecated compatibility flag; threshold mode is used by default
golden_min_keep_ratio0.333...Deprecated compatibility value
return_tokensfalseInclude token decisions

Tool: compress_file

Arguments:

ArgumentDefaultMeaning
pathrequiredLocal file path on the MCP server machine
encodingutf-8File encoding
threshold0.5Keep probability cutoff
target_keep_rationullFixed token budget
goldentrueDeprecated compatibility flag; threshold mode is used by default
golden_min_keep_ratio0.333...Deprecated compatibility value
return_tokensfalseInclude token decisions
forcefalseAllow syntax-sensitive file types for exploratory compression
content_modeconfig defaultauto, prose, code-comments, raw, or refuse

compress_file uses configured content_mode by default. In auto mode, supported source files preserve executable code exactly and compress only comments/docstrings. Supported code-aware languages are Python, JavaScript, TypeScript, JSX, TSX, Go, and Rust.

Unsupported syntax-sensitive file types such as diffs, structured configs, lockfiles, SQL, and .env files are refused unless force=true. Forced output should not be used for exact edits, quotes, commands, or schema details without reading the raw source.

Use A Warm Service

For repeated MCP calls, start the local service and run the MCP server in service mode:

contextcrumb service start --allow-root .
contextcrumb-mcp --use-service

Config:

{
"mcpServers": {
"contextcrumb": {
"command": "uvx",
"args": [
"--from",
"contextcrumb[mcp]",
"contextcrumb-mcp",
"--use-service",
"--service-url",
"http://127.0.0.1:8765"
]
}
}
}

Service mode prevents every MCP server process from loading its own model.