Local MCP server for semantic code search
Project description
semantic-code-mcp
Local MCP server that provides semantic code search for Claude Code. Instead of iterative grep/glob, it indexes your codebase with embeddings and returns ranked results by meaning.
Python only for now — multi-language support (JS/TS, Rust, Go) is planned.
How It Works
Claude Code ──(MCP/STDIO)──▶ semantic-code-mcp server
│
┌───────────────┼───────────────┐
▼ ▼ ▼
AST Chunker Embedder LanceDB
(tree-sitter) (sentence-trans) (vectors)
- Chunking — tree-sitter parses Python into functions, classes, and methods
- Embedding — sentence-transformers encodes each chunk (all-MiniLM-L6-v2, 384d)
- Storage — vectors stored in LanceDB (embedded, like SQLite)
- Search — hybrid semantic + keyword search with recency boosting
Indexing is incremental (mtime-based) and uses git ls-files for fast file discovery. The embedding model loads lazily on first query.
Installation
# Via uvx (recommended)
uvx semantic-code-mcp
# Or install globally
uv tool install semantic-code-mcp
Claude Code Integration
claude mcp add --scope user semantic-code -- uvx semantic-code-mcp
MCP Tools
search_code
Search code by meaning, not just text matching. Auto-indexes on first search.
| Parameter | Type | Default | Description |
|---|---|---|---|
query |
str |
required | Natural language description of what you're looking for |
project_path |
str |
required | Absolute path to the project root |
limit |
int |
10 |
Maximum number of results |
Returns ranked results with file_path, line_start, line_end, name, chunk_type, content, and score.
index_codebase
Index a codebase for semantic search. Only processes new and changed files unless force=True.
| Parameter | Type | Default | Description |
|---|---|---|---|
project_path |
str |
required | Absolute path to the project root |
force |
bool |
False |
Re-index all files regardless of changes |
index_status
Check indexing status for a project.
| Parameter | Type | Default | Description |
|---|---|---|---|
project_path |
str |
required | Absolute path to the project root |
Returns is_indexed, files_count, and chunks_count.
Configuration
All settings are environment variables with the SEMANTIC_CODE_MCP_ prefix (via pydantic-settings):
| Variable | Default | Description |
|---|---|---|
SEMANTIC_CODE_MCP_CACHE_DIR |
~/.cache/semantic-code-mcp |
Where indexes are stored |
SEMANTIC_CODE_MCP_LOCAL_INDEX |
false |
Store index in .semantic-code/ within each project |
SEMANTIC_CODE_MCP_EMBEDDING_MODEL |
all-MiniLM-L6-v2 |
Sentence-transformers model |
SEMANTIC_CODE_MCP_DEBUG |
false |
Enable debug logging |
SEMANTIC_CODE_MCP_PROFILE |
false |
Enable pyinstrument profiling |
Tech Stack
| Component | Choice | Rationale |
|---|---|---|
| MCP Framework | FastMCP | Python decorators, STDIO transport |
| Embeddings | sentence-transformers | Local, no API costs, good quality |
| Vector Store | LanceDB | Embedded (like SQLite), no server needed |
| Chunking | tree-sitter | AST-based, respects code structure |
Development
uv sync # Install dependencies
uv run python -m semantic_code_mcp # Run server
uv run pytest # Run tests
uv run ruff check src/ # Lint
uv run ruff format src/ # Format
Architecture decisions are documented in docs/decisions/. Project planning lives in TODO.md.
License
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file semantic_code_mcp-0.1.0.tar.gz.
File metadata
- Download URL: semantic_code_mcp-0.1.0.tar.gz
- Upload date:
- Size: 113.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
adbd11e90758607d70b9435b208ab16cd3a121d032b4f26cc4bb8b5c9d780cc1
|
|
| MD5 |
3f1a3b4f021e46efaf25237ca4575167
|
|
| BLAKE2b-256 |
0f48b1c7a9e929e6fad7af18904bf76a1847f69c69ee09272ee32064185c39ee
|
File details
Details for the file semantic_code_mcp-0.1.0-py3-none-any.whl.
File metadata
- Download URL: semantic_code_mcp-0.1.0-py3-none-any.whl
- Upload date:
- Size: 30.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4ce04b9c8c3522e1845e3ba365a6098c40e5ec0a5f60b724491c63b3ed40accc
|
|
| MD5 |
c9334a4bd431af45d6f1e29906f9f9fb
|
|
| BLAKE2b-256 |
417c72cf3807488b894a2b1c891236608b9396c63f3aeab5e88b68ccf2f1cc3a
|