Skip to main content

Batho MCP Server

The Batho MCP (Model Context Protocol) server exposes your codebase's structural intelligence to AI agents. Instead of agents issuing dozens of grep and read calls to understand your code, they query pre-built Arrow IPC artifacts with sub-millisecond latency and minimal token consumption.

What It Does

CapabilityDescription
Zero-copy readsMemory-mapped Arrow IPC — no database, no parsing at query time
Dual-outputCompact markdown for the model (34–38% fewer tokens) + structured JSON for programmatic use
10 toolslist_repos, add_repo, remove_repo, graph_overview, graph_query, get_entity, trace_path, get_file_graph, search_entities, get_delta
Community detectionLeiden clustering produces architectural summaries at build time
Multi-repo registryRegister multiple repos via add_repo tool — one MCP config entry serves all repos
Incremental updatesAfter batho patch, the server serves the latest generation — no restart needed
Token budgeting25K token default with automatic truncation and pagination hints

Architecture

Architecture diagram showing the MCP data flow: source code is built by batho build into Arrow IPC artifacts, the MCP server reads a registry of repos, and serves queries to AI agents over stdio. Agents can add/remove repos via the registry.

Tool Matrix

ToolPurposeKey Parameters
list_reposList all registered repos with artifact status and entity counts
add_repoRegister a repository in the MCP registryname, path
remove_repoRemove a repository from the registryname
graph_overviewHigh-level codebase summary: entity counts, relationship breakdown, communitiesrepo, response_format, max_tokens
graph_queryFiltered graph query with file/type/name/pattern filtersrepo, file_path, entity_types, name_pattern, limit, offset
get_entityDetailed info for a single entity including relationshipsentity_id, repo, include_source
trace_pathShortest path between two entities via BFSsource_entity_id, target_entity_id, repo, max_depth
get_file_graphAll entities and relationships within a filefile_path, repo, include_cross_file_refs
search_entitiesSubstring/regex search across entity namesquery, repo, entity_types, limit
get_deltaIncremental changes from the latest patch runrepo, run_id, change_kind, file_path

How It Works

  1. Build — Run batho build --root /path/to/repo to create Arrow IPC artifacts in .batho/artifact/
  2. Start — Run batho mcp to start the stdio-based MCP server (auto-loads ~/.batho/mcp-repos.json)
  3. Connect — Your AI agent (Claude Desktop, Cursor, Windsurf) connects via MCP protocol — one-time config
  4. Register — The agent calls add_repo(name, path) to register repos in the registry
  5. Query — The agent calls tools with repo="name" to explore specific repos without reading raw files

The server reads artifacts using zero-copy memory-mapped I/O. No database process, no network calls, no file parsing at query time. Each tool returns dual output: markdown content for the model and JSON structuredContent for programmatic consumers.

Next Steps