Sourcerer MCP is an MCP (Model Context Protocol) server focused on semantic code search and navigation, with the goal of helping AI agents work efficiently and avoid consuming large amounts of expensive tokens. Instead of having the agent read entire files, it allows the agent to search by concept and jump directly to the specific functions, classes, and code blocks it needs.
Main capabilities
-
Code parsing and chunking: Uses Tree-sitter to parse source files into ASTs and extract meaningful code blocks (functions, classes, methods, types), generating a stable ID for each block. Each block contains the source code, location information, and a context summary. The block ID format is: file.ext::Type::method.
-
File system integration: Listens for file changes via fsnotify, respects .gitignore file rules with the help of git check-ignore, automatically reindexes changed files, and stores metadata to track modification times.
-
Vector database: Uses chromem-go to persistently store vector data in .sourcerer/db/, and generates embedding vectors via OpenAI's API to achieve semantic similarity, thereby supporting concept search rather than just text matching. The database maintains code blocks, their embedding vectors, and metadata.
Usage
The server provides the following tools:
- semantic_search: Use semantic search to find relevant code
- get_chunk_code: Retrieve a specific code block by ID
- find_similar_chunks: Find similar code blocks
- index_workspace: Manually trigger reindexing
- get_index_status: Check indexing progress
Prerequisites
- OpenAI API Key: Required for generating embedding vectors (local embeddings are planned)
- Git: Must be a git repository (will follow the .gitignore file)
- Add .sourcerer/ to .gitignore: This directory stores the embedding vector database
Use cases
This approach allows AI agents to find relevant code without reading entire files, significantly reducing token usage and cognitive burden, and is suitable for development scenarios that require AI agents to perform efficient search and navigation in a codebase.
Supported languages
Language support requires, for each language,writing Tree-sitter queries to identify functions, classes, interfaces, and other code structures. Currently supported: Go, JavaScript, Markdown, Python, TypeScript. Planned support: C, C++, Java, Ruby, Rust, and other languages. Contributions are welcome; see CONTRIBUTING.md for details.
Limitations
Currently only the five languages above are supported; local embedding support is still planned and not yet available; an OpenAI API Key and a git repository environment are required.