About Semantic Context Mcp
Semantic Context Mcp indexes code into a local vector database and serves semantic code search for developers. It tracks changes incrementally and exposes indexing and query operations through MCP.
Key features
- 01AST parsing across several languages
- 02Merkle Tree change detection
- 03Incremental background indexing
- 04Natural-language semantic code search
- 05Local ChromaDB storage
Use cases
- 01Find code by describing its purpose
- 02Refresh an index after code changes
MCP support
Exposes `full_index`, `status`, and `query` tools to MCP clients for indexing and searching a codebase.
Configuration
Local server config is the same for every client. Copy it into your client’s MCP config file.
We haven’t collected a package or remote endpoint for this server. Follow the instructions in the project README.
Tools
Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.
Details
From the project README中文
🚀 Overview
Semantic Context MCP Server is a Model Context Protocol (MCP) server that leverages a vector database to efficiently index and perform semantic searches across your codebase.
It intelligently parses your code into structural blocks (like functions and classes), converts them into vector embeddings, and stores them in a local vector database. This allows you to find semantically relevant code snippets using natural language queries, rather than just keyword matching.
The server runs in the background, automatically tracking file changes and incrementally updating its index, ensuring your code context is always up-to-date.
✨ Features
- Incremental Indexing: Uses a Merkle Tree to detect file changes, ensuring only modified files are re-indexed, which is highly efficient.
- Multi-Language Support: Employs AST (Abstract Syntax Tree) parsing to support a wide range of languages, including Python, Java, C++, JavaScript, TypeScript, and Go.
- Semantic Code Search: Find code based on meaning and context, not just keywords.
- Background Automation: Automatically performs an initial full index and then runs periodic incremental updates every 5 minutes.
- Simple MCP Interface: Provides easy-to-use tools (
full_index,status,query) for integration with other systems. - Local First: All data (vector database, index metadata) is stored locally in your user home directory (
~/.chromadb).
🛠️ How It Works
- Detect Changes: A Merkle Tree is built from file content hashes to quickly identify added, modified, or deleted files.
- Parse Code: Changed files are parsed using an AST parser to extract meaningful code blocks (functions, classes, etc.).
- Generate Embeddings: The extracted code blocks are converted into numerical representations (vector embeddings) using an embedding model (e.g., Jina, OpenAI).
- Store in Vector DB: These embeddings and associated metadata are stored in a local ChromaDB instance.
- Query: When a query is received, it's converted into an embedding and used to find the most similar code blocks in the vector database.
📂 Project Structure
.
├── vector_search/
│ ├── ast_parser.py # Smart AST parser for multiple languages
│ ├── code_change_tracker.py # Detects file changes using a Merkle Tree
│ ├── code_indexer.py # Main logic for incremental and full indexing
│ ├── fast_mcp_server.py # The MCP server exposing the tools
│ └── vector_db.py # Vector database manager (ChromaDB wrapper)
├── LICENSE
├── README_zh.md
└── README.md
⚙️ Prerequisites
- Python 3.8+
- An OpenAI-compatible API for generating embeddings. You need to set the following environment variables:
export OPENAI_API_KEY="your_api_key" export OPENAI_BASE_URL="your_api_base_url" export OPENAI_MODEL_NAME="your_embedding_model_name"
📦 Installation
- Clone the repository:
git clone https://github.com/zishengwu/semantic-context-mcp cd semantic-context-mcp
🚀 Usage
- config
MCP JSON filein IDE:
{
"mcpServers": {
"Semantic Context MCP Server": {
"command": "fastmcp",
"args": [
"run",
"your_code_base/semantic-context-mcp/vector_search/fast_mcp_server.py:mcp"
],
"env": {
"OPENAI_API_KEY": "your_api_key",
"OPENAI_BASE_URL": "your_api_base_url",
"OPENAI_MODEL_NAME": "your_embedding_model_name"
}
}
}
}
Enjoy it!👏
Comments
New to MCP?
From what the protocol is to installing your first server, these answers cover most first questions.
An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.