MCP Hub
Back to servers

semantic-code-mcp

Stars
1
Updated
Jan 31, 2026

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)
  1. Chunking — tree-sitter parses Python into functions, classes, and methods
  2. Embedding — sentence-transformers encodes each chunk (all-MiniLM-L6-v2, 384d)
  3. Storage — vectors stored in LanceDB (embedded, like SQLite)
  4. 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.

ParameterTypeDefaultDescription
querystrrequiredNatural language description of what you're looking for
project_pathstrrequiredAbsolute path to the project root
limitint10Maximum 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.

ParameterTypeDefaultDescription
project_pathstrrequiredAbsolute path to the project root
forceboolFalseRe-index all files regardless of changes

index_status

Check indexing status for a project.

ParameterTypeDefaultDescription
project_pathstrrequiredAbsolute 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):

VariableDefaultDescription
SEMANTIC_CODE_MCP_CACHE_DIR~/.cache/semantic-code-mcpWhere indexes are stored
SEMANTIC_CODE_MCP_LOCAL_INDEXfalseStore index in .semantic-code/ within each project
SEMANTIC_CODE_MCP_EMBEDDING_MODELall-MiniLM-L6-v2Sentence-transformers model
SEMANTIC_CODE_MCP_DEBUGfalseEnable debug logging
SEMANTIC_CODE_MCP_PROFILEfalseEnable pyinstrument profiling

Tech Stack

ComponentChoiceRationale
MCP FrameworkFastMCPPython decorators, STDIO transport
Embeddingssentence-transformersLocal, no API costs, good quality
Vector StoreLanceDBEmbedded (like SQLite), no server needed
Chunkingtree-sitterAST-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

Reviews

No reviews yet

Sign in to write a review