codebase-mcp is a high-performance, local-first MCP server for codebase exploration and safe filesystem workflows. It runs over stdio, exposes 34 tools, and is designed for agents that need precise reads, search, code intelligence, structured edits, and compact responses from real repositories.
- Serves MCP tools over standard JSON-RPC
stdioframing. - Reads files and snippets without dumping entire repositories into context.
- Searches code with literal/regex matching, glob filters, and large-repo friendly limits.
- Builds a persistent workspace index with LMDB path metadata and an optional Tantivy content sidecar.
- Provides Tree-sitter based symbols, imports/exports, references, definitions, symbol bodies, and call graphs.
- Supports safe writes with structured errors plus undo/redo history.
- Inspects Markdown, JSON, SQLite databases, archives, diffs, and workspace structure.
Use codebase-mcp when your MCP client or coding agent needs to explore, search, and safely edit a local repository without loading large files or full directory trees into context.
It is especially useful for:
- Large repositories where targeted reads and scoped searches matter.
- Agents that need structured filesystem, search, and code-intelligence tools.
- Workflows that benefit from undoable file edits.
- Local-only code analysis without relying on an external indexing service.
- Use
fuzzy_find,project_map, orworkspace_statsto understand the repository shape. - Use
text_searchto locate relevant files, symbols, strings, or patterns. - Use
read_file_range,read_snippets, orfile_summaryto inspect focused content. - Use
get_symbols,find_definition,find_references, orread_symbol_bodyfor code navigation. - Use
edit_file,create_file,create_directory, ordelete_fileto make changes. - Use
history_status,undo_last_change, orredo_last_changeto review or revert supported edits.
- Package:
codebase-mcp - Version:
1.2.0 - License: Apache-2.0
- Runtime: Rust + Tokio
- Transport: MCP
stdio - MCP protocol version returned by the server:
2024-11-05 - Tool count: 34
- Rust stable toolchain
- An MCP-compatible client such as Claude Code, Codex, Cursor, Windsurf, Cline, Roo, or VS Code MCP integrations
Build a release binary:
cargo build --releaseRun directly during development:
cargo run --releaseRelease binary locations:
- Windows:
target/release/codebase-mcp.exe - Linux/macOS:
target/release/codebase-mcp
Use the release binary as a stdio MCP server.
{
"mcpServers": {
"codebase-mcp": {
"command": "C:\\path\\to\\codebase-mcp\\target\\release\\codebase-mcp.exe",
"args": []
}
}
}{
"mcpServers": {
"codebase-mcp": {
"command": "/absolute/path/to/codebase-mcp/target/release/codebase-mcp",
"args": []
}
}
}{
"servers": {
"codebase-mcp": {
"type": "stdio",
"command": "/absolute/path/to/codebase-mcp/target/release/codebase-mcp",
"args": []
}
}
}On Windows, point command to the .exe file.
| Variable | Purpose |
|---|---|
CODEBASE_MCP_LOG |
Log level: error, warn, info, debug, or trace. Defaults to info. |
CODEBASE_MCP_LOG_FILE |
Writes logs to a file instead of stderr. |
CODEBASE_MCP_WORKSPACE_ROOT |
Preferred workspace root for relative tool paths when client roots are unavailable. |
CODEBASE_MCP_WALK_THREADS |
Thread count for directory walking. Defaults to a conservative value up to 4. |
CODEBASE_MCP_INDEX_DIR |
Overrides the persistent index cache directory. |
CODEBASE_MCP_INDEX_STALE_SECS |
Seconds before completed path metadata is considered stale. |
CODEBASE_MCP_INDEX_MAP_SIZE_MB |
LMDB map size in MB. Defaults to 4096. |
CODEBASE_MCP_TANTIVY_ENABLED |
Enables the Tantivy content sidecar. Defaults to true. |
CODEBASE_MCP_TANTIVY_MAX_FILE_BYTES |
Maximum file size read for Tantivy content indexing. Defaults to 1048576. |
CODEBASE_MCP_TANTIVY_MAX_ZONE_BYTES |
Maximum bytes per warmed content zone. Defaults to 1073741824. |
CODEBASE_MCP_TANTIVY_MAX_WORKSPACE_BYTES |
Maximum bytes per workspace content sidecar. Defaults to 4294967296. |
Legacy TURBO_* aliases are still accepted for backward compatibility where implemented.
The server keeps one index per canonical workspace root.
- Windows default:
%LOCALAPPDATA%\codebase-mcp\index-v2\<workspace_hash>\ - Linux/macOS default:
$XDG_CACHE_HOME/codebase-mcp/index-v2/<workspace_hash>/or~/.cache/codebase-mcp/index-v2/<workspace_hash>/ - Custom root:
<CODEBASE_MCP_INDEX_DIR>\index-v2\<workspace_hash>\ - Tantivy sidecar:
<workspace_index_dir>\tantivy-content\
LMDB stores path metadata. Tantivy is used as an optional sidecar for warmed content zones. When a query or scope cannot be served from the content index, tools fall back to filesystem scanning where appropriate.
resolve_pathread_file_rangecount_file_linesread_snippetsconvert_file_formatcreate_filecreate_directorydelete_fileedit_filefile_summaryhistory_statusundo_last_changeredo_last_change
text_searchfuzzy_findproject_mapworkspace_statsmarkdown_outlineread_markdown_sectionfind_json_pathsextract_json_schema
get_symbolsread_symbol_bodyfind_definitionfind_referenceslist_importslist_exportsget_call_graphcompare_symbolsdiff_two_snippets
sqlite_inspectpeek_archiveserver_healthbatch_tool_call
Search Rust files with regex:
{
"name": "text_search",
"arguments": {
"query": "TODO|FIXME",
"paths": ["/workspace"],
"mode": "regex",
"includes": ["*.rs"],
"max_results": 50
}
}Read multiple focused snippets in one call:
{
"name": "read_snippets",
"arguments": {
"max_total_bytes": 24000,
"requests": [
{ "path": "/workspace/src/main.rs", "start_line": 1, "end_line": 80 },
{ "path": "/workspace/src/lib.rs", "start_line": 1, "end_line": 60 }
]
}
}Find a symbol body with its signature:
{
"name": "read_symbol_body",
"arguments": {
"symbol": "processPayment",
"paths": ["/workspace/src"],
"include_signature": true
}
}Batch related calls in one MCP round trip:
{
"name": "batch_tool_call",
"arguments": {
"calls": [
{ "tool": "file_summary", "args": { "path": "/workspace/README.md" } },
{ "tool": "project_map", "args": { "path": "/workspace", "max_depth": 2 } }
]
}
}- The server exposes tools only; it does not expose MCP resources, prompts, or templates.
- Tool responses are returned in the standard MCP
contentarray shape. batch_tool_callexecutes calls sequentially and rejects recursive batch calls.- Mutating tools record history metadata for undo/redo where supported.
- Write tools return structured success or error payloads instead of free-form text.
read_file_rangeand search-oriented tools keep output bounded for agent context.- Tool calls default to a 60 second timeout. Clients may request longer calls with
timeout_seconds,timeout_secs,timeout_s, ortimeout_ms; values are capped at 600 seconds. - A global rate limiter protects the server from excessive request volume.
server_healthreports uptime and indexing status for readiness checks.
- Scope
pathsto the smallest relevant subtree. - Prefer concrete path tokens and basenames for
fuzzy_find. - Keep
project_mapshallow, for examplemax_depth <= 2. - Use recursive glob excludes such as
third_party/**,node_modules/**,target/**,dist/**, andout/**. - Use
read_snippetsafter search results instead of reading full files. - Treat Tree-sitter results as local syntactic intelligence, not as a replacement for full semantic language servers.
Format, lint, and test:
cargo fmt
cargo clippy --all-targets --all-features -- -D warnings
cargo test --releaseUseful local checks:
cargo test
cargo run --releasesrc/
main.rs MCP stdio server, JSON-RPC handling, logging, timeouts
mcp.rs JSON-RPC request/response types
common.rs shared path and environment helpers
version.rs package version export
indexer/ LMDB/Tantivy workspace indexing
history/ write-history and undo/redo support
security/ path guarding and rate limiting
tools/ MCP tool implementations and schemas
tests/ integration and behavior tests
Apache-2.0. See LICENSE.