DevContext
Workspace-aware MCP server that provides AI clients with structural code understanding via AST parsing, hybrid retrieval, and git history, enabling accurate code search, definition lookup, and blame analysis.
README
DevContext — Workspace-Aware MCP Intelligence Server
DevContext is a powerful, context middleware engine running entirely on the Model Context Protocol (MCP) standard over standard I/O (stdio) transport. It fundamentally bridges the gap between advanced LLM clients (like Claude Desktop and Cursor) and deep local software repositories by giving AI immediate, high-fidelity awareness of your codebase.
Instead of relying on blind flat-text line slicing, DevContext natively understands your code structurally and chronologically. By replacing naive text chunks with syntax-tree definitions and history-aware structural blocks, it delivers highly accurate, context-dense retrieval payloads that exponentially improve the reliability of LLM code generation and analysis.
System Architecture Layout
+-------------------------------------------------------------+
| MCP Client Host (Claude / Cursor) |
+------------------------------+------------------------------+
|
v
+------------------------------+------------------------------+
| FastMCP Protocol Interface |
| (stdio transport layer) |
+------------------------------+------------------------------+
|
+-------------------+-------------------+
| | |
v v v
+--------------------+ +--------------------+ +--------------------+
| AST-Parser | | Lexical Indexer | | Git Historian |
| (tree-sitter) | | (rank-bm25) | | (gitpython) |
+--------------------+ +--------------------+ +--------------------+
| | |
+-------------------+-------------------+
|
v
+------------------------------+------------------------------+
| Weighted Hybrid Ranking Core |
| (50% Semantic | 35% Lexical | 15% Recency Decay) |
+------------------------------+------------------------------+
|
v
+------------------------------+------------------------------+
| Unified Context Payload |
| (Structured blocks returned to MCP Client) |
+-------------------------------------------------------------+
Deep-Dive Feature Breakdown
AST-Aware Structural Ingestion
DevContext completely eliminates disjointed, fragmented retrieval context. It leverages tree-sitter and tree-sitter-python to parse code into live concrete syntax trees. By surgically targeting function_definition and class_definition nodes and extracting them alongside their precise 1-based editor line coordinates, the LLM receives unbroken logical blocks of code. For flat data text documents (like .md or .json), the system gracefully defaults to a smart, overlapping windowed character-fallback layer.
3-Signal Hybrid Retrieval Optimization
When querying the workspace, the retriever fuses three distinct scoring signals to return hyper-relevant results:
- Signal 1 (Dense Semantic Vectors - 50% weight): Powered by local ChromaDB and Sentence-Transformers (
all-MiniLM-L6-v2), it calculates semantic distance representations mapped tightly via a normalized cosine approximation scaled at1.0 - (L2_Distance / 2.0). - Signal 2 (Sparse Lexical Keywords - 35% weight): Exact term overlapping powered by
BM25Okapi. The token frequencies are normalized against the maximum score array to prevent generic keyword flooding. - Signal 3 (Temporal Git Recency Decay - 15% weight): Employs
gitpythonlog delta tracking to ascertain code volatility. Applying categorical priority boosts based on the modification history age (≤ 7 days = 1.0 boost, ≤ 30 days = 0.5 boost), DevContext ensures the AI pays the most attention to code actively being worked on.
Workspace Dependency Graph Resource
Exposes the fundamental routing layout of your application dynamically. DevContext sniffs top-level import_statement and import_from_statement syntax nodes using tree-sitter and serializes the topological relationships into a clean, read-only JSON mapping available directly as an MCP Resource.
Complete Protocol Matrix Interface
| Type | Name | Protocol URI / Signature | Functional Responsibility |
|---|---|---|---|
| Tool | search_files | search_files(query: str, workspace_path: str) |
Hybrid semantic, BM25, and git recency decay search across all workspace files. |
| Tool | find_definition | find_definition(symbol: str, workspace_path: str) |
Locate specific function or class definitions across the AST-indexed workspace. |
| Tool | git_blame | git_blame(filepath: str, line_number: int, workspace_path: str) |
Retrieve exact chronological telemetry (Author, Date, Commit Message) for any code line. |
| Resource | workspace://dependency-graph | workspace://dependency-graph |
Expose a complete JSON-serialized import graph mapping structural file relationships. |
Full Tech Stack Glossary
- Python (Asynchronous core): Delivers high-performance backend logic handling concurrent multi-process file indexing.
- FastMCP (Protocol wrapper): A highly efficient bridge facilitating rapid tool and resource orchestration over the MCP stdio standard.
- ChromaDB (Local vector storage): Zero-latency embedded vector storage operating entirely locally.
- Sentence-Transformers (API-key-free execution embeddings): Runs
all-MiniLM-L6-v2locally on your CPU for completely air-gapped security and rapid dense embedding calculations. - tree-sitter (Concrete syntax tree structures): Provides robust, fault-tolerant C-based syntax parsers for deeply structural code extraction.
- rank-bm25 (Statistical term filtering): Filters keyword densities efficiently to heavily anchor semantic queries to precise variables and terminology.
- gitpython (Chronological git telemetry parsing): Harvests local repository history, commits, and blames to measure code age and activity.
Installation, Integration & Quickstart Verification
Quickstart
Clone the repository and spin up the environment:
git clone https://github.com/YOUR_USERNAME/devcontext-mcp
cd devcontext-mcp
pip install -r requirements.txt
python server.py
Cursor Editor Integration
DevContext provides out-of-the-box support for the Cursor IDE. A .cursor/mcp.json file is already baked into the repository footprint. Simply open the devcontext-mcp folder inside Cursor and restart the IDE. DevContext will dynamically appear inside Cursor's MCP tools panel.
Claude Desktop App Integration
Open your Claude Desktop configuration JSON file and append the following block within the mcpServers object. Be sure to supply the absolute path to your local server.py file:
{
"mcpServers": {
"devcontext": {
"command": "python",
"args": ["YOUR_ABSOLUTE_PATH_TO/devcontext-mcp/server.py"]
}
}
}
Restart Claude Desktop to finalize the connection.
Test Suite Verification
Ensure your local sandbox operates perfectly. Run the fully isolated, 4-layer sandboxed regression sequence:
python tests/test_suite.py
You should expect 4/4 tests passed. validating your local DB write locks, tree-sitter parsing bindings, and FastMCP integrations.
Real-World Developer Use Cases
Unleash the LLM in your prompt window with requests like:
- "Query DevContext and search the codebase for our user authentication and JWT validation logic."
- "Invoke the
find_definitiontool and show me the exact parameters required by theDatabaseConnectionPoolclass." - "There is a bug on line 42 of
server.py. Fetch thegit_blamehistory for that line and tell me what the developer was trying to achieve." - "Fetch the
workspace://dependency-graphresource. Write a short report detailing exactly which files import theosandsysmodules." - "Using DevContext, find the core retrieval function, read its dependencies, and write unit tests covering its edge cases."
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。