code-cache-mcp
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@code-cache-mcpquery the code cache for the UserService class details"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
code-cache-mcp
A lightweight, tree-sitter-backed code knowledge cache for AI agents — delivered as an MCP server.
轻量级代码知识缓存 MCP 服务,基于 tree-sitter 语法分析,专为 AI 编码助手设计。
Overview / 概述
AI agents repeatedly read source files to answer code questions — burning tokens every time. code-cache-mcp changes this: the agent queries the cache first, gets symbol positions + inheritance + call graph, and only reads the specific line range on a true miss.
Code structure is parsed once using tree-sitter and stored in SQLite. Only structure is persisted — symbol names, kinds, line ranges, inheritance edges, call graph. No raw source code is ever stored.
AI 助手反复读源文件查符号,每次都烧 token。code-cache-mcp 先查缓存:返回符号位置 + 继承关系 + 调用图,仅在 miss 时才按行范围精确读取。代码结构用 tree-sitter 一次解析存入 SQLite,仅存结构不存源码。
Related MCP server: code-analyze-mcp
Features / 功能特性
Symbol cache — classes, interfaces, enums, methods, functions, fields with line ranges
Inheritance graph —
extends/implementsrelationships, resolved lazilyCall graph — method invocation edges (caller → callee)
AI location memory — auto-persisted when query hits, instant retrieval in future sessions
Auto-invalidation — FileWatcher detects file changes, re-parses automatically
Cold-start auto-index — indexes cwd in background when cache is empty
Multi-language — Java, TypeScript/JavaScript, Python, Go, Rust
Zero infrastructure — single SQLite file, no server process
Lightweight — 66MB node_modules (vs 389MB in v0.1), lazy WASM loading
MCP Tools / MCP 工具
v0.2 provides 3 tools (v0.1 had 8):
Tool | Description | Parameters |
| FAST symbol lookup: file:line + hierarchy + call graph |
|
| Parse and cache a source file's structure |
|
| Batch-index all source files in a directory |
|
query_code_cache auto-indexes on miss and retries — no manual setup needed. Cache hits automatically persist as AI locations for future sessions.
query_code_cache 在 miss 时自动索引并重试——无需手动 setup。命中自动存储为 AI location,供后续会话直接命中。
Supported Languages / 支持语言
Language | Extension |
Java |
|
TypeScript / TSX |
|
JavaScript / JSX |
|
Python |
|
Go |
|
Rust |
|
Setup / 安装配置
Prerequisites / 前提条件
Node.js ≥ 18
Install / 安装
cd /path/to/code-cache-mcp
npm installRegister with Claude Code / 注册到 Claude Code
claude mcp add code-cache-mcp npx tsx "$(pwd)/packages/server/src/index.ts"Or add manually to ~/.claude.json under mcpServers:
"code-cache-mcp": {
"type": "stdio",
"command": "npx",
"args": ["tsx", "/absolute/path/to/code-cache-mcp/packages/server/src/index.ts"]
}Environment Variables / 环境变量
Variable | Default | Description |
|
| Directory for the SQLite database |
Architecture / 架构
code-cache-mcp/
├── packages/
│ ├── sdk/ # Core library (no MCP dependency)
│ │ └── src/
│ │ ├── types.ts # Shared interfaces
│ │ ├── db.ts # SQLite schema + queries
│ │ ├── code-cache.ts # CodeCacheStore — orchestrator
│ │ ├── parser-*.ts # Language-specific parsers
│ │ ├── parser-registry.ts # Lazy language dispatcher
│ │ └── watcher.ts # FileWatcher (debounced fs.watch)
│ ├── server/ # MCP server entry point
│ │ └── src/
│ │ ├── index.ts # CLI entry
│ │ └── mcp.ts # 3 tool registrations
│ └── wasm/ # tree-sitter WASM grammar binariesDatabase schema / 数据库结构
Table | Contents |
| File path, hash, language, line count |
| Every class / method / field with line range |
| Inheritance / implementation edges |
| Method invocation graph |
| Auto-persisted AI query hits with reason |
| Global cache hit/miss counters, tokens saved |
v0.2 Changes from v0.1 / v0.2 相比 v0.1 的变化
Metric | v0.1 | v0.2 | Change |
MCP tools | 8 | 3 | -62% |
query parameters | 11 | 4 | -64% |
node_modules | 389MB | 66MB | -83% |
mcp.ts lines | 783 | ~290 | -64% |
DB tables | 10 | 6 | -40% |
Dependencies | ~200+ | ~102 | -50% |
Removed in v0.2
Semantic search (
@xenova/transformers, 45MB + 23MB model cache)TokenTracker (
@anthropic-ai/sdk)PostgreSQL metrics (
pgdual-write)Cross-session query history (SHA-256 hashing, diff computation)
Code snippet similarity (Jaccard token matching, unified diff)
Session dedup cache and session stats table
AST nodes table and
include_astparameter5 MCP tools:
cache_hotness,invalidate_cache,store_ai_location,get_ai_locations,cache_clearreport.tsandclaude-log-reader.ts
Tech Stack / 技术栈
Component | Technology |
Language | TypeScript (ESM) |
Runtime | Node.js + npx tsx |
Database | SQLite via |
Code parsing |
|
MCP SDK |
|
Validation |
|
Guiding AI to Use the Cache / 引导 AI 使用缓存
AI agents default to Read / grep / LSP because they're familiar. To increase adoption:
SessionStart hook — Add to
~/.claude/settings.json:
"SessionStart": [{ "hooks": [{ "type": "command", "command": "cat ~/.claude/code-cache-hint.txt" }] }]Create ~/.claude/code-cache-hint.txt:
When navigating code, prefer query_code_cache over Read/grep for symbol lookups. It returns file:line positions, inheritance, and call graph — faster than reading whole files. After reading a source file, call store_code_context to cache it.Cold-start auto-index — Built-in. When cache is empty, indexes cwd in background automatically.
Teaching tip — Built-in. Cache hits include:
"tip": "3 symbols found via cache. Use Read with offset/limit for the specific line ranges above."CLAUDE.md — Add to project root:
## Code Navigation
- Use `query_code_cache` BEFORE `Read` to find symbols. Returns file:line + hierarchy + call graph.
- After `Read` on a source file, call `store_code_context` to build cache.License / 许可证
MIT
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/eurekame2000/code-cache-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server