An MCP server that gives AI agents a cited, searchable memory of a codebase.
pip install codebase-brain-mcp==0.2.1 Copy PIP instructions
An MCP server that gives AI assistants a cited, searchable memory of a codebase, including its history. Point it at a local folder or a public git URL. Claude, Cursor or any MCP client can then answer questions about the code with exact path:start-end citations.
Claude Code asks why TimestampSigner.unsign looks the way it does, what breaks if it changes, and whether its docs are current. Codebase Brain answers with commits, callers, tests and doc findings, all cited. (Waiting time sped up.)
AI coding assistants are good at writing new code but struggle to understand code that already exists:
A plug-in for any AI assistant that turns a codebase into something it can actually look things up in:
Also included: the resource brain://repos, and the prompt answer_with_citations.
Codebase Brain runs on your own machine, so there's no server or account, and it's free. It works with any MCP-compatible assistant. All you need is uv, and every client runs the same command: uvx codebase-brain-mcp.
claude mcp add codebase-brain -- uvx codebase-brain-mcp Cursor: ~/.cursor/mcp.json (all projects) or .cursor/mcp.json (one project)
{ "mcpServers": { "codebase-brain": { "command": "uvx", "args": ["codebase-brain-mcp"] } } } Claude Desktop: Settings → Developer → Edit Config (claude_desktop_config.json), then restart the app
{ "servers": { "codebase-brain": { "type": "stdio", "command": "uvx", "args": ["codebase-brain-mcp"] } } } Windsurf: ~/.codeium/windsurf/mcp_config.json. Gemini CLI: ~/.gemini/settings.json. Both use the same mcpServers block as Cursor.
codex mcp add codebase-brain -- uvx codebase-brain-mcp Tool doesn't start? Desktop apps often don't see your shell's PATH. Run which uvx and put that full path in "command", for example "/Users/you/.local/bin/uvx".
Optional: install the skill. It tells the agent which tool fits which question, to cite every claim, to check history before removing odd code, and to run impact analysis before editing. For Claude Code, run the commands below. Other agents that read SKILL.md files take the same file in their own skills folder.
mkdir -p ~/.claude/skills/codebase-brain curl -fsSL https://raw.githubusercontent.com/Nomannazir/codebase-brain-mcp/main/skills/codebase-brain/SKILL.md \ -o ~/.claude/skills/codebase-brain/SKILL.md Quick start uv sync uv run codebase-brain index https://github.com/pallets/itsdangerous uv run codebase-brain search "how is the signature timestamp checked for expiry" 0.0313 src/itsdangerous/timed.py:72-158 method TimestampSigner.unsign 0.0311 docs/timed.rst:1-28 code 0.0301 src/itsdangerous/timed.py:170-228 class TimedSerializer Ask why it looks like that. explain_history(symbol="TimestampSigner.unsign") returns its line-by-line history:
src/itsdangerous/timed.py:72-158 3edfbbbc 2022-03-24 handle OverflowError in timed unsign on 32-bit systems 177196d3 2022-03-09 catch OSError on Windows 37f09970 2022-03-08 catching year overflow ValueError c30678d1 2019-05-31 don't allow timestamps from the future 910a7a94 2020-04-17 datetimes are timezone-aware utc ... Use a local checkout instead (for development) claude mcp add codebase-brain -- uv run --directory /path/to/codebase-brain-mcp codebase-brain Run it as a remote server (Streamable HTTP) export CODEBASE_BRAIN_TOKEN="$(python -c 'import secrets; print(secrets.token_urlsafe(32))')" uv run codebase-brain serve --transport streamable-http --host 0.0.0.0 --port 8765 Clients connect to http:// :8765/mcp with Authorization: Bearer . GET /healthz is open for load balancers. Remote mode is locked down by default:
docker build -t codebase-brain-mcp . docker run -p 8765:8765 -e CODEBASE_BRAIN_TOKEN="$CODEBASE_BRAIN_TOKEN" -v brain-data:/data codebase-brain-mcp The image runs as a non-root user and includes the embedding model, so it starts fast and needs no download at runtime. It has a health check, and keeps indexes in the /data volume. Indexing uses about 1.2 GB of memory, so give the container 2 GB.
Does search actually put the right code in front of the model? codebase-brain eval answers that with a benchmark. There are two, each with 32 questions pinned to one commit, and each question lists the code or docs a good answer must come from. The questions were written by reading the code before any results were measured, and haven't been changed since.
32 questions about pallets/itsdangerous at commit 672971d, in evals/datasets/itsdangerous.toml.
32 questions about sindresorhus/ky at commit 3541888, in evals/datasets/ky.toml. The readme is one 2,000-line file, so docs questions must find the right section, not just the file.
Reproduce either benchmark (the first run downloads the repo and the embedding model):
uv run codebase-brain eval evals/datasets/itsdangerous.toml --out evals/results uv run codebase-brain eval evals/datasets/ky.toml --out evals/results How it's measured:
source ─► resolve (local dir / blobless https clone) ─► list files (.gitignore-aware, skips binaries and lockfiles) ─► chunk (ast / tree-sitter / headings / windows) ─► embed (fastembed) ─► SQLite: chunks + vectors + FTS5 query ─► BM25 top 50 ┐ ─► vector top 50 ┴─► reciprocal-rank fusion ─► filters ─► cited sources Security Clones are blobless (--filter=blob:none): full history, with file contents fetched only when needed. Commit authors are shown by name only; email addresses are never stored or returned. Only https:// clone URLs are accepted. Git runs with GIT_ALLOW_PROTOCOL=https:file and no terminal prompts. read_lines resolves paths and refuses anything outside the indexed repository. Repo names are validated, so they can't escape the index directory. All query tools are marked read-only. In HTTP mode: a required bearer token (constant-time check), git URLs only, repo size limits, DNS-rebinding protection, and a non-root container. Development uv run pytest # 67 tests, offline (hash embedder, temporary git repos, in-process MCP client) uv run ruff check . # lint uv run ruff format . # format uv run pyright # types Roadmap Git history and PR discussions: explain_history, search_history Symbol references and transitive dependents: impact_of_change find_doc_drift: Markdown and reStructuredText, signatures, imports, settings, flags, staleness JavaScript and TypeScript (tree-sitter): chunking, references, impact analysis More languages (Go, Rust, Java) with tree-sitter Retrieval evals with confidence intervals (codebase-brain eval) Larger held-out eval set, then retrieval tuning (reranking, query expansion) Streamable HTTP with bearer-token auth, Docker image PyPI package, MCP Registry listing Hosted demo OpenTelemetry tracing Project links Data verified by PyPI on Nov 7, 2026 Data provided by the project maintainers, verified at the time the release was uploaded to PyPI. Homepage Issues Repository Key dates PyPI data Data sourced directly from PyPI's database. Released: Nov 7, 2026 Latest release 1 maintainer PyPI data Data sourced directly from PyPI's database. nomannazir Credits Author: Noman Nazir
Both files in this release have provenance metadata.
mcp model-context-protocol rag code-search ai-agents claude git
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 7, 2026.
Both files in this release have been uploaded with provenance metadata.
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.




