Codebase Memory MCP — Code Knowledge Graph Server
High-performance MCP server that indexes codebases into persistent knowledge graphs. Supports 66 languages, sub-millisecond queries, and claims 99% fewer tokens than raw file context. 1,100+ stars.
这个资产会安全暂存
这个资产会先安全暂存。复制的指令会要求 Agent 读取暂存文件,并在激活脚本、MCP 配置或全局配置前先确认。
npx -y tokrepo@latest install 0f381b11-cd15-40db-89c5-293d07a36dea --target codex先暂存文件;激活前需要读取暂存 README 和安装计划。
What it is
Codebase Memory MCP is a high-performance MCP server that indexes your codebase into a persistent knowledge graph. It supports 66 programming languages, provides sub-millisecond queries, and reduces the tokens needed for code context by replacing raw file content with structured graph lookups. The server runs locally and integrates with AI assistants through the Model Context Protocol.
The project targets developers using AI coding assistants who want better code understanding without sending entire files as context. By pre-indexing the codebase into a graph of functions, classes, imports, and dependencies, the MCP server provides precise answers to structural queries.
How it saves time or tokens
Sending raw files to an AI assistant wastes tokens on irrelevant code. Codebase Memory MCP indexes your codebase once and serves targeted queries: 'what calls this function,' 'what does this class depend on,' 'show me the type hierarchy.' Each query returns only the relevant graph nodes, potentially using 99% fewer tokens than raw file context. The persistent index survives restarts, so re-indexing only processes changed files.
How to use
- Add to your MCP configuration:
{
"mcpServers": {
"codebase-memory": {
"command": "npx",
"args": ["-y", "codebase-memory-mcp"]
}
}
}
- Restart Claude Code. The server indexes your codebase automatically on first use.
- Ask Claude structural questions about your codebase, and it will use the knowledge graph for precise answers.
Example
Queries the knowledge graph can answer efficiently:
# Instead of reading entire files, the MCP server returns graph data:
> What functions call processPayment()?
- checkout.ts:handleCheckout (line 45)
- subscription.ts:renewSubscription (line 112)
- admin.ts:manualCharge (line 78)
> What are the dependencies of the AuthService class?
- UserRepository (import from ./repositories)
- TokenManager (import from ./utils)
- Logger (import from @/shared)
> Show the type hierarchy for BaseController
- BaseController
- UserController
- ProductController
- OrderController
Related on TokRepo
- MCP GitHub Integration — GitHub access through MCP for code repositories
- AI Memory Providers — persistent memory solutions for AI agents
Common pitfalls
- Initial indexing of large codebases (100K+ files) can take several minutes; subsequent incremental updates are faster
- The knowledge graph is local to your machine; team members each maintain their own index
- Language support varies in depth; popular languages (TypeScript, Python, Go) have richer graph structures than niche languages
常见问题
Codebase Memory MCP supports 66 programming languages through tree-sitter parsers. Coverage depth varies: mainstream languages like TypeScript, Python, Go, and Java have full function/class/import extraction, while less common languages may have basic file-level indexing.
Yes. Add the MCP server to your .mcp.json configuration and restart Claude Code. The server integrates through the standard Model Context Protocol, providing code structure tools that Claude can call during conversations.
The knowledge graph is typically 5-15% of the source code size. A 100MB codebase produces roughly a 10MB index. The index is stored locally and persists across sessions.
By default, the server skips binary files, node_modules, vendor directories, and other common non-source paths. You can customize the ignore patterns in the configuration.
After the initial full index, the server watches for file changes and only re-indexes modified files. This keeps the knowledge graph current without re-processing the entire codebase.
引用来源 (3)
- Codebase Memory MCP GitHub— Codebase Memory MCP server
- MCP Specification— Model Context Protocol specification
- Tree-sitter— Tree-sitter parsing framework
TokRepo 相关
来源与感谢
Created by DeusData. Licensed under Apache 2.0.
codebase-memory-mcp — ⭐ 1,100+
讨论
相关资产
Codebase Memory MCP — Code Intelligence for AI Agents
High-performance code intelligence MCP server. Indexes repos in milliseconds via tree-sitter AST, supports 66 languages, sub-ms graph queries. MIT, 1,300+ stars.
Memory MCP — Persistent AI Agent Knowledge Graph
MCP server that gives AI agents persistent memory using a local knowledge graph. Stores entities, relationships, and observations across sessions for Claude Code.
Context+ — Semantic Code Intelligence MCP Server
MCP server combining RAG, Tree-sitter AST parsing, and spectral clustering to turn large codebases into searchable feature graphs. 99% accuracy on monorepos. 1,700+ GitHub stars.
Serena — Semantic Code Agent via MCP
Serena is a coding agent MCP server with semantic code retrieval and editing. 22K+ stars. Understands classes, functions, symbols for precise context-aware edits. MIT.