ContextBrain
The mutable hippocampus for autonomous coding agents

Index the code.
Keep the rules.Answer in one query.

ContextBrain parses your repositories into a symbol graph and stores what the code can't tell you — the library versions you're pinned to, the business rules, the patterns you expect every agent to follow. Agents reach all of it through 71 MCP tools.

71
MCP tools
4
languages parsed
L1·L2·L3
knowledge layers
3
ways in: MCP, CLI, REST
Worked example — one search, two retrievers

Lexical BM25

Semantic kNN vectors

Reciprocal rank fusion

score = Σ 1 / (60 + rank)  ·  ×1.5 architecture layer  ·  ×1.2 project index
Illustrative results. The constants are the ones the ranker actually uses.
Why the failure modes this exists for

A model that has read everything knows nothing about your repo.

Training data contains every version of every library and none of your decisions. Left alone, an agent averages over all of it. These are the four ways that shows up in a diff.

Version contamination
The agent writes React 16 in a React 18 codebase. ContextBrain serves library docs filtered to the major version in your tech stack, so the wrong one is never in context.
Rules that evaporate
"Orders over $10k need manager approval" survives one session. Rules live in L2 with domain, priority and relationships to each other, and any agent can query them before it writes code.
Patterns nobody enforces
One agent uses the repository layer, the next writes raw SQL. Architecture patterns live in L3 and are boosted 1.5× in every search, so they surface ahead of everything else.
Knowledge that quietly rots
The rule was true six months ago. Knowledge is anchored to the files it describes, re-verified against current code, and reported as gaps, staleness and contradictions instead of being trusted forever.
Position data provider, not another agent

Your agent is the brain. This is the memory.

ContextBrain does no reasoning about your task. It doesn't rank your intent, plan your work or summarise your code into something lossy. It stores, indexes and returns — the agent decides what to ask for and what to do with it.

The agent does

Understand, decide, synthesise, write

Reads the request, picks which tools to call, combines results, plans the implementation, and hands back new knowledge worth keeping.

ContextBrain does

Store, index, retrieve, persist

Keeps the symbol graph and three knowledge layers, answers exactly the query asked, and holds it all across sessions, agents and machines.

Memory the tri-layer protocol

Every fact belongs to exactly one layer.

The layer decides where a fact comes from, whether it can change, and how it is weighted at retrieval time. Nothing is stored without one.

L1_STACKimmutable

Library documentation, locked to your version

Crawled from official sources, chunked and indexed per library version. Search adds a version filter from your project's tech stack, so a Prisma 5 project never sees Prisma 4 answers.

Populated by deep research: an LLM finds the doc URLs, the crawler indexes them, the version is recorded.
L2_BIZcurated

Business rules, with relationships

Domain logic an agent cannot infer from the code: approval thresholds, tenancy constraints, what must never be deleted. Filterable by domain and priority.

Rules relate to each other: DEPENDS_ON · CONFLICTS_WITH · SUPERSEDES · PREREQUISITE_FOR · RELATES_TO
L3_ARCHmutable

Architecture patterns, discovered and taught

How this codebase does things — error handling, auth boundaries, data access. Detected by static analysis over your repo, and added by agents when they learn something worth repeating.

Weighted 1.5× in every search, because the way you build is the thing agents get wrong most often.
Graph what the parser knows

The repository, parsed into symbols and edges.

Tree-sitter parses TypeScript, JavaScript, Python and Java — including .tsx and .jsx — into files, symbols, imports, calls and dependency edges. Everything else about your repo is built on top of that table.

Structure

Symbols and files

Functions, classes, interfaces and types with their locations, plus the directory tree, entry points and config files.

Relationships

Four kinds of edge

References to a symbol, dependents of a file, its own dependencies, and the call hierarchy above and below a function.

Risk

Blast radius

Impact analysis crosses static dependents with git co-change history: the files that break, and the files that always move together anyway.

History

Commits, diffs, hotspots

Commits and their diffs are indexed too — search them by message, author or path, see blame-style history for a file, and find the files that churn.

Schema

Your database, as symbols

A PostgreSQL schema can be indexed into the same graph — tables and relations become symbols and edges — without storing the credential.

Discovery

Patterns from static analysis

Semgrep rule packs for architecture, database access, frameworks, security and validation propose L3 patterns from what the code actually does.

Retrieval one query, both retrievers, honest scores

Search that admits when it's stale.

Lexical and semantic search run against Elasticsearch and merge by reciprocal rank fusion. What comes back is graded, traceable, and checkable against the code it claims to describe.

Ranking

BM25 + vectors, fused

Both retrievers return a ranking; RRF merges them at k=60. Results from your project's own index get 1.2×, architecture patterns get 1.5×. No opaque re-ranker in between.

Reach

One project, or all of them

Search a single project, or every project you own at once. A separate graph query walks code dependencies, knowledge anchors, rules, documents and git co-changes in one call.

Anchors

Knowledge tied to code

Ask what knowledge covers a file, or what code implements a rule. Each link carries a confidence score, so weak claims look weak.

Health

Verification, not vibes

Anchors are re-checked against current code by an LLM after changes. A health report lists coverage gaps, stale rules and contradictions; an index report shows exactly what is indexed for full-text, vectors, both, or failed.

Artifacts what else lives in a project

Documents, diagrams and shared knowledge.

Documents

Versioned, and checked for drift

Eleven document types — architecture, ADR, API reference, runbook, requirements and more — each with version history, full-text search, and a drift check that reports CURRENT, OUTDATED, AHEAD or CONFLICT against the codebase.

Diagrams & templates

Source, not screenshots

Architecture, sequence, flowchart, ERD and class diagrams stored as Mermaid, PlantUML, D2 or Graphviz source. Document templates carry {{variables}} and render on demand.

Global knowledge

Lessons that outlive one repo

A cross-project store organised by namespace and tags. Entries are voted on, which moves a reliability score, and every edit keeps history — so what one project learns the rest can use, with a signal of how much to trust it.

Investigations

Structured, budgeted exploration

An agent can open an investigation session, record findings as it goes, and get back coverage and budget state. Sessions detect stalls and end with a result, instead of an agent wandering until its context fills.

Ingestion repository to answerable index

Point it at a repo. It stays current after that.

GitHub, GitLab, Gitea and Bitbucket, public or private. Credentials are encrypted at rest, and a push webhook can be registered for you so new commits re-index without anyone remembering to.

01

Clone

Repo fetched with a stored, encrypted credential. Multiple repos per project.

02

Discover

Source files selected, generated output and vendor directories skipped.

03

Parse

Tree-sitter extracts symbols, imports and calls; edges are written to the graph.

04

Detect

Tech stack and versions detected; static rules propose architecture patterns.

05

Embed

Chunks embedded and indexed for full-text and vector search.

06

Watch

Push webhook triggers incremental re-index; anchors get re-verified.

Tools the whole surface, nothing held back

Every tool an agent can call.

Served over MCP, and each one also reachable from the cb command line. Single purpose, composable in any order, no hidden orchestration.

71tools in 8 groups

Code graph 14

cb_symbolsfind functions, classes, types
cb_structuredirectory tree, entry points
cb_filefile content with line numbers
cb_graphreferences, dependents, dependencies, calls
cb_code_searchhybrid lexical + semantic code search
cb_code_statschunks by language and symbol kind
cb_impactblast radius for a file
cb_historyhotspots and recent commits
cb_commitssearch indexed commits
cb_blamecommits that touched a path
cb_indexqueue a re-index
cb_db_indexindex a PostgreSQL schema
cb_cross_searchsearch every project you own
cb_quickstartonboard a repo in one call

Knowledge 11

cb_searchunified search across all sources
cb_rulesL2 business rules, with relations
cb_patternsL3 patterns: list, deprecate, delete
cb_teachstore a business rule
cb_learnstore an architecture pattern
cb_rule_relatelink rules to each other
cb_extract_rulespull rules out of prose
cb_knowledge_graphcode, knowledge and git in one query
cb_anchorswhat knowledge covers this file
cb_verifyre-check anchors against the code
cb_healthgaps, stale rules, contradictions

Library documentation 9

cb_docsversion-locked docs for a library
cb_index_docsqueue documentation indexing
cb_library_listlibraries linked or available
cb_library_addlink a library version
cb_library_removeunlink a library version
cb_library_statuscrawl state and chunk counts
cb_research_startdiscover and crawl a library's docs
cb_research_statusprogress of a research job
cb_research_listresearch jobs for this project

Context 8

context_searchsearch knowledge by layer
context_addadd knowledge to a layer
context_updatereplace a document's content
context_deprecateretire without deleting
context_crawlcrawl a URL into context
context_researchdeep research on a library
context_build_orientationhints before starting a task
context_build_deep_divemulti-facet exploration

Documents, diagrams, templates 15

document_listdocuments by type or status
document_searchfull-text across documents
document_geta document, any version
document_writecreate or version a document
document_drift_checkis this still true of the code
document_deletearchive or remove
diagram_listdiagrams by type or format
diagram_getdiagram source and metadata
diagram_writecreate or update a diagram
diagram_deleteremove a diagram
template_listtemplates for the project
template_gettemplate with placeholders
template_writecreate or update a template
template_renderfill a template's variables
template_deleteremove a template

Global knowledge 5

cb_global_searchcross-project entries by namespace
cb_global_getan entry, with history and votes
cb_global_addshare knowledge across projects
cb_global_updateedit, keeping an audit trail
cb_global_votemove an entry's reliability

Investigations 4

start_investigationopen a budgeted session
record_findinglog a result as you go
end_investigationclose with a conclusion
get_investigation_statusbudget, coverage, result

Project 5

cb_statusstack, indexing, knowledge counts
cb_techstackread or set pinned versions
cb_git_configrepos, and push webhooks
cb_credentialencrypted git tokens
cb_index_healthwhat is indexed, what is stale
Connect four ways in, one project

Add it to an agent in one config block.

The MCP server speaks streamable HTTP, so any MCP client — Claude Code, Claude Desktop, your own runner — connects with a URL and a key. People sign in through BitBot's device flow; agents and CI use a project API key.

For agents

MCP server

71 tools at my.contextbrain.ai/api/mcp, authenticated per project.

For people

cb command line

35 commands over the same tools, with JSON and quiet output for scripts.

For services

REST API

Knowledge, code graph, documents, libraries and webhooks over plain HTTP.

For oversight

Dashboard

Projects, indexing state, knowledge and keys in the web console.

MCP client configuration
// .mcp.json
{
  "mcpServers": {
    "contextbrain": {
      "type": "http",
      "url": "https://my.contextbrain.ai/api/mcp",
      "headers": {
        "X-API-Key": "proj_yourproject_…"
      }
    }
  }
}
Command line
# install; the checksum is verified before anything lands
curl -fsSL https://contextbrain.ai/cli/install.sh | bash

# sign in, pick a project, look around
cb login
cb project join myapp
cb status

# the same tools your agents call
cb symbols createOrder
cb impact src/services/order-service.ts
cb rules --domain billing
cb search "how do we handle refunds" -o json | jq
Stack what it is made of

Boring infrastructure, on purpose.

A TypeScript monorepo: API, MCP server, background worker, web dashboard and CLI, over Postgres, Elasticsearch and Redis. Nothing in the hot path waits on a model.

Runtime

  • Node 20+, TypeScript, ESM
  • Fastify 5 — API and MCP transport
  • SvelteKit — dashboard
  • BullMQ — nine job queues

Storage

  • PostgreSQL 17 with Prisma
  • Elasticsearch 8 — text and vectors
  • Redis 7 — queues and sessions
  • Encrypted git credentials at rest

Analysis

  • Tree-sitter — TS, JS, Python, Java
  • Semgrep rule packs — pattern discovery
  • OpenAI embeddings, or local Ollama
  • Claude — rule extraction and verification
Access what this actually is

Infrastructure for an agent fleet, not a signup page.

ContextBrain is one of the tools behind the BitBot ecosystem — identity, deployment, testing, task management and memory, built to be run together. It is not self-serve, and there is no free tier to click through. If you want a project on the hosted instance, or want to run it in your own cluster, say what you're building and we'll answer.

Identity and limits
accounts     BitBot — one identity across every tool
people       cb login — device flow, no password in a terminal
agents & CI  CB_API_KEY=proj_… — non-interactive, scoped to one project
limits       per-project rate limits, set by the plan on the account
repos        GitHub · GitLab · Gitea · Bitbucket, public or private