chuk-mcp-code-raptor
Deep code intelligence for MCP — an MCP server that gives AI agents semantic understanding of codebases via RAPTOR hierarchical indexing and code property graphs.
README
chuk-mcp-code-raptor
Deep code intelligence for MCP — an MCP server that gives AI agents semantic understanding of codebases via RAPTOR hierarchical indexing and code property graphs.
Pure intelligence, no filesystem. This server only provides capabilities the client doesn't already have — semantic search, dependency graphs, hierarchical context, AST-aware symbol lookup.
What It Does
Every MCP client (Claude Code, Cursor, etc.) already has file reading, text search, and shell access. This server adds the intelligence layer on top:
| What clients have | What this server adds |
|---|---|
| Keyword search (grep) | Semantic search — "how does auth work" finds the right code across abstraction levels |
| File reading | Hierarchical context — where a symbol sits in the architecture, what it affects |
| Symbol grep | AST-aware symbol lookup — knows the difference between a class and a function with the same name |
| Manual exploration | Dependency graphs — what imports what, data flow, blast radius analysis |
| Nothing | Project detection — auto-detect language, framework, test runner, package manager |
| Nothing | Code outline — symbols with signatures, line numbers, docstrings |
Tools
10 tools across 5 groups. All return structured Pydantic JSON, not raw file contents.
Session — Project Selection (1 tool)
| Tool | Description |
|---|---|
set_project |
Set the active project directory and build the index. Falls back to CODE_RAPTOR_PROJECT env var if no path given. Must be called before other tools. |
Orient — Project Awareness (2 tools)
| Tool | Description |
|---|---|
get_project_info |
Detect language, framework, package manager, test framework, entry points |
get_outline |
Show symbols in a file or directory with line numbers, signatures, docstrings |
Find — Search & Discovery (3 tools)
| Tool | Description |
|---|---|
search_semantic |
Semantic code search across RAPTOR hierarchy levels. Supports max_results, token_budget |
find_symbol |
Find a class, function, or method by name. Optional kind filter |
find_references |
Find everywhere a symbol is used — imports, calls, data flow |
Understand — Context & Relationships (2 tools)
| Tool | Description |
|---|---|
get_context |
Hierarchical context — where a symbol sits in the architecture, related components, impact scope |
get_dependencies |
Import and data-flow graph — what a symbol depends on and what depends on it |
Maintenance — Index Management (2 tools)
| Tool | Description |
|---|---|
reindex |
Full index rebuild after major changes |
reindex_file |
Incremental update after editing a single file |
All intelligence tools are read-only (readOnlyHint=True). Session and maintenance tools are idempotent (idempotentHint=True).
Installation
Using uv (Recommended)
# Install from PyPI
uv pip install chuk-mcp-code-raptor
# Or clone and install from source
git clone https://github.com/chrishayuk/chuk-mcp-code-raptor.git
cd chuk-mcp-code-raptor
uv sync --dev
Using pip
pip install chuk-mcp-code-raptor
Optional dependencies
# Local embeddings (sentence-transformers, recommended)
pip install "chuk-mcp-code-raptor[embeddings-local]"
# OpenAI embeddings
pip install "chuk-mcp-code-raptor[embeddings-openai]"
# Anthropic summarization (Phase 2)
pip install "chuk-mcp-code-raptor[summarization-anthropic]"
Usage
With mcp-cli (uv)
Add to your server_config.json or ~/.mcp.json:
{
"servers": {
"code-raptor": {
"command": "uv",
"args": ["run", "--directory", "/path/to/chuk-mcp-code-raptor", "chuk-mcp-code-raptor"],
"type": "stdio"
}
}
}
Then in the chat, call set_project to choose a codebase:
💬 You: set_project to /path/to/my/repo then tell me the architecture
With Claude Desktop
Add to your Claude Desktop configuration:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%/Claude/claude_desktop_config.json
{
"mcpServers": {
"code-raptor": {
"command": "chuk-mcp-code-raptor",
"env": {
"CODE_RAPTOR_PROJECT": "/path/to/your/project"
}
}
}
}
With CODE_RAPTOR_PROJECT set, call set_project() (no argument) to auto-initialize from the env var.
Standalone
# STDIO mode (default, for MCP clients)
python -m chuk_mcp_code_raptor
# HTTP mode (for web access)
python -m chuk_mcp_code_raptor http
From Python
from chuk_mcp_code_raptor.config import ServerConfig
from chuk_mcp_code_raptor.state import ServerState, set_state
from chuk_mcp_code_raptor.tools.find import search_semantic
# Initialize the index
config = ServerConfig(target_repo="/path/to/project")
state = ServerState(config=config)
await state.initialize()
set_state(state)
# Semantic search
result = await search_semantic("how does authentication work")
Examples
Four runnable demos in the examples/ directory:
# Tool registration and schema inspection
uv run examples/server_demo.py
# Agent workflow with hardcoded data (no indexing required)
uv run examples/agent_workflow_demo.py
# Full indexing pipeline — creates a project, indexes it, calls all 9 tools
uv run examples/live_indexing_demo.py
# MCP protocol interaction via ToolRunner
uv run examples/mcp_client_demo.py
| Demo | What it shows |
|---|---|
server_demo.py |
Tool registration, schemas, MCP hints |
agent_workflow_demo.py |
How an agent would use the tools in sequence |
live_indexing_demo.py |
Full RAPTOR + CPG pipeline on a realistic project |
mcp_client_demo.py |
MCP protocol calls through ToolRunner |
Development
Setup
git clone https://github.com/chrishayuk/chuk-mcp-code-raptor.git
cd chuk-mcp-code-raptor
uv sync --dev
Running Tests
make test # Run tests
make test-cov # Run tests with coverage
make coverage-report # Show coverage report
Code Quality
make lint # Run linters (ruff)
make format # Auto-format code
make typecheck # Run type checking (mypy)
make security # Run security checks (bandit)
make check # Run all checks (lint + typecheck + security + test)
Building
make build # Build package
make version # Show current version
make bump-patch # Bump patch version
make publish # Create tag and trigger automated release
Architecture
src/chuk_mcp_code_raptor/
├── __init__.py
├── __main__.py # python -m chuk_mcp_code_raptor
├── server.py # MCP server instance, tool registration
├── config.py # ServerConfig (Pydantic)
├── state.py # ServerState — holds index, CPG, RAPTOR builder
├── constants.py # All enums and constants (no magic strings)
├── protocols.py # Structural typing protocols
├── models/ # Pydantic models for tool I/O
│ ├── orient.py # ProjectInfo, SymbolInfo, OutlineResult
│ ├── find.py # SemanticMatch, SymbolMatch, ReferenceLocation
│ ├── understand.py # HierarchyContext, DependencyGraph
│ └── maintenance.py # ReindexResult, FileReindexResult
├── tools/ # Tool handlers (pure async functions)
│ ├── session.py # set_project
│ ├── orient.py # get_project_info, get_outline
│ ├── find.py # search_semantic, find_symbol, find_references
│ ├── understand.py # get_context, get_dependencies
│ └── maintenance.py # reindex, reindex_file
├── indexing/ # Index pipeline
│ ├── pipeline.py # Orchestration: scan → chunk → embed → RAPTOR → CPG
│ ├── scanner.py # Project detection (language, framework, tests)
│ ├── converters.py # chuk-code-raptor ↔ Pydantic adapters
│ └── providers/
│ ├── embeddings.py # EmbeddingProvider protocol + implementations
│ └── summarization.py # SummarizationProvider protocol (Phase 2)
└── utils/
├── async_bridge.py # run_sync() — wraps sync calls in executor
├── paths.py # Path resolution and validation
├── subprocess.py # Async subprocess runner
└── diff.py # Unified diff generation
Design Principles
- Async native — every I/O-touching function is
async def - Pydantic native — all data boundaries use typed models, not raw dicts
- No magic strings — every repeated string is an enum or constant
- Composable — tools don't know about transport, indexing doesn't know about MCP
- Pure intelligence — no file reading, no shell, no git — only what clients can't do themselves
Dependencies
| Package | Role |
|---|---|
| chuk-mcp-server | MCP framework (@tool decorator, transports, ToolRunner) |
| chuk-code-raptor | RAPTOR hierarchy, CPG, chunking engine, intelligent search |
| pydantic | Data validation and serialization |
| tree-sitter-python | Python AST parsing |
Roadmap
See ROADMAP.md for the full phased delivery plan.
- Phase 0 — Scaffold (complete)
- Phase 1 — Working Intelligence (complete)
- Phase 1.5 — MCP Client Integration (complete)
- Phase 2 — LLM Summarization
- Phase 3 — File Watching & Persistence
- Phase 4 — Production Hardening
License
Apache License 2.0 — see LICENSE for details.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。