Token Context MCP (v0.3.5)
🌐 English:
README.md| 🇻🇳 Tiếng Việt:README.vi.md| 🇨🇳 简体中文:README.cn.md| 📝 Prompt Protocol:sample_prompt.md| 📋 Changelog:CHANGELOG.md
token-context-mcp is an on-demand, budget-governed Model Context Protocol (MCP) server for autonomous AI coding agents (Claude Code, Cursor, Codex, Google Antigravity). Instead of blindly dumping an entire repository or compressing it into a static snapshot that strips function bodies down to signatures, it provides an interactive AST-level pull pipeline that delivers exact code symbols and downstream impact graphs with verified file:line + SHA-256 evidence.
🖼️ Architecture & Benchmark Infographics (2x Retina Dark Green)
🔍 View detailed technical architecture & comparison diagrams (Click to expand)
1. 3-Layer Governance Microkernel & 5-Step Progressive Pull Pipeline
2. Context Paradigms: Flat Dump vs. Static Pack vs. Interactive MCP Pull
3. Empirical Benchmarks: 59-Task Head-to-Head & M10 Equal-Budget Suite
4. 7-Dimension Technical Comparison Matrix (vs. ContextCraft v0.3.2)
⚡ Core Architectural Pillars
- 3-Layer Governance Microkernel (
kernel/):- Every request is governed by a lightweight execution pipeline:
- Layer 1 — Clean AST-Boundary Cap: Enforces
max_response_tokensat syntactic boundaries without cutting functions in half. - Layer 2 — Per-Tool Async Timeout Gate: Prevents runaway hangs on large monorepos (
10sforget_repo_map,5sforsearch_source). - Layer 3 — 150K Session Budget Circuit Breaker: Emits a telemetry warning at 80% usage and halts runaway loops at 150,000 cumulative tokens to prevent bill shocks.
- Layer 1 — Clean AST-Boundary Cap: Enforces
- Every request is governed by a lightweight execution pipeline:
- Zero Schema Bloat:
- The default
tools/listpayload exposes only 10 core read-only retrieval tools (keeping 10 extension tools and 2 admin tools off the wire until requested). Server-side JSON schemas are slimmed to reduce initial prompt tax.
- The default
- Incremental Tree-sitter AST & Persistent SQLite Graph (
index/):- Fast
mtime_ns+ SHA-256 change detection across Python, JavaScript/TypeScript, Go, Rust, Java, C/C++, and C# with symlink-escape and path traversal guards.
- Fast
📊 Empirical Benchmarks (tiktoken o200k_base Audited)
All numbers are measured using OpenAI's o200k_base tokenizer across two real-world open-source repositories: rich (Python, 213 files, 507k tokens) and fastify (JS/TS, 291 files, 538k tokens):
| Benchmark Suite | Metric | token-context-mcp | Baseline / Alternative | Empirical Takeaway |
|---|---|---|---|---|
| 59-Task Head-to-Head (Equal budget: ~7.6k tokens) | Target function in context with Full Body ($\ge 90%$ lines) | 33 / 59 (55.9%) | 2 / 59 (3.4%) (ContextCraft 8k --focus) |
16.5× more full function bodies at equal token budget |
| 59-Task H2H (Sensitivity) (vs. 4× static budget: 32k tokens) | Full Body vs. Signature Only | 33 / 59 Full Body (at 7.6k) | 6 / 59 Full Body, 40 / 59 (67.8%) Signature Only (ContextCraft 32k) | Static packing prunes bodies to signatures to fit whole-repo maps; interactive MCP pull focuses 100% of budget on the target symbol |
M10 Equal-Budget Suite (rich, n=30, ~1.9k tokens) |
File Recall & Symbol Recall (95% Bootstrap CI) | 0.90 File Recall 0.54 Symbol Recall |
0.57 File Recall 0.10 Symbol Recall (Truncated Grep) |
+58% file recall, 5.4× symbol recall over truncated grep at identical token cost |
C1 Single-Call Cost (fastify 538k source baseline) |
Orientation map get_repo_map@512 |
682 tokens | 538,799 tokens (raw source files) | Compact repo map occupies 0.13% of the repository (~790× smaller) |
🚀 Quick Start
Option 1: Run instantly with uvx (Recommended)
# Register, index, and print agent config for the current directory
uvx token-context-mcp quickstart .
Option 2: Install via pip
pip install token-context-mcp
# Register a codebase and launch server
token-context register --repo-id my-project --root /path/to/project
token-context index --repo-id my-project
token-context serve
Desktop GUI Controller (PySide6)
Includes hardware telemetry, CPU/RAM monitoring, and repository status overview:
uvx --from "token-context-mcp[gui]" token-context-gui
🤖 Coding Agent Setup
token-context-mcp communicates over local stdio. Add the configuration below to your agent:
1. Claude Code
claude mcp add --transport stdio --scope user token-context -- uvx token-context-mcp serve
2. Cursor
In Cursor Settings > Features > MCP Servers:
- Name:
token-context - Type:
command - Command:
uvx token-context-mcp serve
3. Claude Desktop
Add to %APPDATA%\Claude\claude_desktop_config.json (Windows) or ~/.config/Claude/claude_desktop_config.json (macOS/Linux):
{
"mcpServers": {
"token-context": {
"command": "uvx",
"args": ["token-context-mcp", "serve"]
}
}
}
4. Google Antigravity IDE / Gemini CLI
Add to mcp_config.json:
{
"mcpServers": {
"token-context": {
"command": "uvx",
"args": [
"token-context-mcp",
"serve",
"--output-mode", "text",
"--schema-profile", "gemini_safe"
]
}
}
}
🛠 Tool Reference Catalog (10 Default Core Tools)
By default, the server exposes 10 read-only retrieval tools to preserve agent context:
| Tool | Primary Purpose | Mode |
|---|---|---|
list_repositories |
Lists registered repo_ids (filesystem root paths are never leaked). |
Read-only |
get_index_status |
Returns snapshot metadata, indexed file count, commit SHA, and freshness. | Read-only |
get_repo_map |
PageRank-based symbol hierarchy within a token budget (@512). |
Read-only |
find_symbols |
Pattern-based symbol matching (*, ? wildcards) with file coordinates. |
Read-only |
search_source |
FTS5 code search returning matched lines and enclosing symbol spans. | Read-only |
get_file_skeleton |
File outline (imports, class/function signatures with elided bodies). | Read-only |
get_symbol_context |
Full function/class body, docstrings, and callers/callees (@1024). |
Read-only |
get_impact_slice |
Traverses downstream call graph dependencies before making changes (depth=2). |
Read-only |
get_module_dependents |
Tree-sitter import dependency graph between modules. | Read-only |
inspect_symbol |
Composite lookup: symbol resolution + full context + 1-hop impact graph. | Read-only |
(10 extension tools including SQLite multi-agent memory memory_*, lazy tool discovery *_tools, hardware-adaptive compressor sample_summarize, and 2 admin tools agent_control, audit_logs can be enabled via configuration).
🔒 Security Guarantees & Privacy
- No Remote Code Execution (RCE): No tool can execute shell commands, eval code, or modify repository source files.
- 100% Local & Private: All SQLite WAL indexes remain on your machine; zero cloud telemetry or external API calls.
- Automatic Secret Redaction: Regex-based redaction of API keys, tokens, and private keys (
[REDACTED: potential secret]) plus hard denial of sensitive files (.env*,.ssh,*.pem,id_rsa).
📚 Technical Documentation
sample_prompt.md: Standard two-phase prompt templates (EN / VI / CN).CHANGELOG.md: Release history and upgrade notes.launch/00_fact_sheet.md: Verified empirical benchmarks and measurement methodologies.docs/CLIENT_MATRIX.md: Step-by-step MCP client verification matrix.
Maintained by the Token Context MCP community. Licensed under MIT.
Metadata
Release files for token-context-mcp 0.3.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| token_context_mcp-0.3.5.tar.gz | 291.2 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| token_context_mcp-0.3.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 565.7 kB
Release files / token_context_mcp-0.3.5.tar.gz
| Download URL | token_context_mcp-0.3.5.tar.gz |
|---|---|
| Size | 291.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6b2e61a24a05c2039061d33a0ead2ce765dcf41af94bf7231b1e5f80b8243bca
|
|
BLAKE2b-256 checksum How to use checksums |
4dce7174b27d30c49a4fdd47ca73c3e316cf67e44f40e5796bc8d530634f79ef
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.
Transparency logRelease files / token_context_mcp-0.3.5-py3-none-any.whl
| Download URL | token_context_mcp-0.3.5-py3-none-any.whl |
|---|---|
| Size | 274.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1df2eafb547143acfce034f27fb2b182e7807b8738b737a97fdc776cbe0396b1
|
|
BLAKE2b-256 checksum How to use checksums |
84e0a4c64ebfb7b8605cfaa977c5f4d73972eb7ca56034a3e52c3bf847f88f87
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.
Transparency logSecurity for token-context-mcp 0.3.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for token_context_mcp-0.3.5.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.