ChunkHound MCP¶
Code search for large codebases — regex always available, semantic search and architecture analysis when an embedding provider is configured.
Source: chunkhound/chunkhound
Enabling¶
The server is included in servers.yaml with enabled: false. To activate it permanently:
Or enable for the current session only:
Server Config¶
chunkhound:
type: stdio
command: chunkhound
args:
- "mcp"
timeout: 30
inherit_env: true # Required: passes CHUNKHOUND_EMBEDDING__API_KEY
enabled: true
Setup¶
-
Install ChunkHound:
-
Create
.chunkhound.jsonin the project root: -
Set your embedding API key (never put it in
.chunkhound.json): -
Index the project — run once from the project root, re-run only after significant changes:
Note
inherit_env: true is required so the server inherits CHUNKHOUND_EMBEDDING__API_KEY at runtime.
Embedding Providers¶
| Provider | base_url |
|---|---|
| OpenRouter (recommended) | https://openrouter.ai/api/v1 |
| OpenAI direct | https://api.openai.com/v1 |
| Ollama (local) | http://localhost:11434/v1 |
Tools¶
| Tool | Requires | Description |
|---|---|---|
search_regex |
index | Fast regex search — always available after indexing |
search_semantic |
index + embedding key | Finds conceptually related code without knowing exact names |
code_research |
index + embedding + llm | Multi-hop architecture analysis |
Usage Patterns¶
- Exact pattern known: use
search_regex— faster, no API key required - Symbol name unknown: use
search_semanticwith a description (e.g.,"function that parses JWT tokens") - Architecture questions: use
code_research(requires embedding + llm config) - Scope results: pass
path="src/"to any tool to limit search to a directory
Examples¶
1. Find all function definitions matching a name pattern¶
Quickly locate every function or method named after a concept — no IDE needed.
2. Find all usages of a specific import¶
See every file that imports a module — useful before refactoring or deprecating a dependency.
3. Search by concept rather than name¶
Find authentication-related code when you don't know the exact function name.
chunkhound.search_semantic(query="validate API token and check permissions", page_size=5)
# Returns semantically similar code chunks — no exact keyword match needed
4. Find all TODO and FIXME comments¶
Surface technical debt across the entire codebase in one call.
5. Scope search to a specific directory¶
Search only inside src/ to exclude tests and docs from results.
6. Find error handling patterns¶
Locate every try/except block to audit error handling consistency.
7. Find test files for a module¶
Quickly navigate from source to its tests.
8. Understand how a feature is implemented¶
Ask a natural-language question about architecture — ChunkHound traces relationships across files.
chunkhound.search_semantic(
query="how MCP proxy servers are started and managed",
page_size=8,
path="src/"
)
Common Mistakes to Avoid¶
- Don't enable the server before running
chunkhound index— it will return empty results or errors - Don't set API key values inside
.chunkhound.json— useCHUNKHOUND_EMBEDDING__API_KEYenv var - Don't re-index on every session — only re-run after significant code changes
- Don't ignore a
db.wal.corruptfile — delete it and re-index, or it will hang on every start