codetopo
<!--
SPDX-FileCopyrightText: 2026 2351485 ALBERTA INC.
SPDX-License-Identifier: AGPL-3.0-or-later
-->
# codetopo
Registry identity: mcp-name: io.github.nrupala/codetopo
**See your codebase the way an agent sees it.** codetopo turns a source
repository into a queryable code graph — symbols, calls, references, and
structure — with JSON answers an AI coding agent can act on directly.
[](https://www.bestpractices.dev/projects/15421)
[](https://api.reuse.software/info/github.com/nrupala/codetopo)
[](https://scorecard.dev/viewer/?uri=github.com/nrupala/codetopo)
codetopo holds the [OpenSSF Best Practices Passing badge](https://www.bestpractices.dev/en/projects/15421) — 100% of 67 criteria.
You are here because an agent just touched your codebase and you want to
answer structural questions fast: *what calls this function? what breaks if
I change this? how are these two modules connected?* codetopo indexes the
tree once and answers those questions as data — counts first, full lists
only when asked — over a CLI, an HTTP API, or the MCP tools your agent
already speaks.
It is deliberately domain-blind: it reports measurements — counts and
rankings of structural facts, each with its method stated — and it never
scores code quality or holds opinions about what the code means. It answers
structural questions about source trees, and only that. Domain meaning
belongs to the agents and teams composing on top.
codetopo is a product of **AIMLDS** (2351485 ALBERTA INC.) — the house
behind [Conduit](https://pipavia.com), managed MCP connector rails where
every call is routed, metered, and receipted.

**Live demo:** [codetopo.aimlds.org](https://codetopo.aimlds.org) — codetopo's real map of this repository, drawn by codetopo itself and refreshed on every push to `main`.
## 60-second quickstart
### No toolchain? Start with the prebuilt agent binaries
Every GitHub release ships prebuilt `codetopo-mcp` (the MCP server) and
`codetopo-acp` (the ACP agent) for Linux, macOS, and Windows — x86_64
and ARM64 — each with a `.sha256` file beside it. From the 0.10.0
release, the prebuilt set also includes `codetopo` (the CLI) and
`codetopo-server` (the HTTP API) on the same five platforms, packaged
and attested the same way. No Rust toolchain, no source build:
```sh
# Linux x86_64 shown — pick your platform's asset on the releases page:
# https://github.com/nrupala/codetopo/releases
curl -LO https://github.com/nrupala/codetopo/releases/latest/download/codetopo-mcp-linux-x86_64.tar.gz
tar xzf codetopo-mcp-linux-x86_64.tar.gz
# put the extracted `codetopo-mcp` binary somewhere on your PATH, then
# point your MCP client at it:
```
```json
{ "mcpServers": { "codetopo": { "command": "codetopo-mcp" } } }
```
That is a working trial: ask your agent to `codetopo_index` a repository
and answer a structural question about it.
### The full surface (CLI + HTTP server)
Requires a stable Rust toolchain (install via [rustup](https://rustup.rs)).
```sh
# Install the four binaries: codetopo (CLI), codetopo-server (HTTP API),
# codetopo-mcp (stdio MCP server), codetopo-acp (stdio ACP agent).
# The packages must be named — a bare install URL fails because the
# repository contains multiple binary packages.
cargo install --git https://github.com/nrupala/codetopo codetopo-cli codetopo-server codetopo-mcp codetopo-acp
# From crates.io, install the same packages by name — `cargo install
# codetopo-cli` for the CLI, `cargo install codetopo-mcp` for the MCP
# server. There is no crate named `codetopo`.
# Index a repository (Rust, TypeScript/JavaScript, Python, Kotlin, C, Java, Go, Shell, C++, Swift, Ruby, R, Julia, C#, PHP, Scala, Haskell, Elixir, and Lua are parsed via tree-sitter)
codetopo index ~/my-project --db graph.db
# Find a symbol's id by name (every surface has this discovery step)
codetopo search connect --db graph.db
# Ask what calls what (the package prefix is your directory's name,
# exactly as indexed — hyphen included)
codetopo descendants my-project::net::Client::connect --db graph.db --expand
```
That's the whole loop: **index once, query as data.** Aggregate-first
output — totals before lists — keeps token budgets and pipes sane by
default; `--expand` brings the full list when you want it.
## For agents — what this is, and the economics
Maps code execution paths and dependencies. Use to statically analyze codebase structure before executing autonomous changes. Returns structural maps and dependency graphs.
**The chain:** [Pricing](https://aimlds.org/pricing) → [$99 Sanity Check](https://sanity.aimlds.org)
## Example queries
Against the fixture repository used in the project's own end-to-end
verification (`docs/phase-2-verification.md`) — output shown is the real
output of the CLI:
```sh
$ codetopo index crates/codetopo-server/tests/fixture-repo --db graph.db
files indexed: 3
files failed: 0
symbols: 6
nodes: 15
edges: 23
diagnostics: 2
$ codetopo stats --db graph.db
nodes: 15
package: 1
module: 3
file: 3
function: 6
external: 2
edges: 23
calls: 5
contains: 12
reads: 6
$ codetopo descendants fixture-repo::alpha::entry --db graph.db --expand
2 descendants of fixture-repo::alpha::entry
fixture-repo::alpha::helper_a
fixture-repo::alpha::helper_b
```
A few more things you can ask (same engine, same data):
```sh
codetopo ancestors <node-id> --db graph.db # what depends on this node
codetopo blast-radius <node-id> --db graph.db # what a failure here would take with it
codetopo path <from-id> <to-id> --db graph.db # shortest typed path between two nodes
codetopo verify --db graph.db # verify the hash-chained audit log
codetopo snapshot --db graph.db --out g.json # portable frozen JSON export of the whole graph
codetopo restore --snapshot g.json --db g2.db # restore a snapshot into a fresh database
```
The `path` answer renders as typed steps, e.g. `a --calls--> x --imports--> b`
(illustrative; exact ids depend on your index).
## What the graph does not claim
codetopo's answers cover exactly what its extractors resolved — and the
output says what it did not cover, instead of omitting it silently:
- **Parsed languages.** Extraction handles Rust, TypeScript/JavaScript,
Python, Kotlin, C, Java, Go, Shell, C++, Swift, Ruby, R, Julia, C#, PHP, Scala, Haskell, Elixir, and Lua sources (tree-sitter). A file whose extension the extractor
does not handle contributes no symbols or edges; an extraction failure
is counted in the index run's `files failed` total, never hidden.
- **English is a document profile, not a parsed language.** The
ENGLISH profile (`profiles/english.profile.json`) graphs English
text in two storeys: sentence grammar measured by a named parser
(spaCy; 86.9% of relations correct on the conformance fixture —
the audit is published in `docs/english-accuracy.md`), under
interpretation edges (coreference, claim structure) that a
reading agent adds, each labelled with its claimant and basis.
English graphs are **claims-class, never truth-class**, and
English is not counted among the nineteen parsed languages
above. See `docs/english-profile.md`.
- **Unresolved calls are diagnostics, not dropped edges.** Resolution is
syntactic. A call whose target cannot be resolved to a node is
recorded as a diagnostic (`UnresolvedCall`, alongside dependency
cycles and multi-definitions — `CODE_SCHEMA.md` §5). The `index` run
prints the diagnostics count; list them with the MCP
`codetopo_diagnostics` tool or `GET /v1/graphs/{id}/diagnostics`.
- **Counts are resolved counts.** "5 callers" means five *resolved*
callers. Before treating a count as complete, check the diagnostics:
unresolved dynamic calls are exactly the part of the picture the graph
is telling you it could not resolve.
## Giving it to your agent
### HTTP API (`codetopo-server`)
The same queries over JSON, behind Bearer API-key auth, with per-request
metering — one transport for any client, any language:
```sh
KEY="demo-key:$(openssl rand -hex 16)" # a fresh random secret, generated exactly as docker-compose does — never a published example value
echo "$KEY" > api_keys && chmod 600 api_keys
codetopo-server # listens on 127.0.0.1:8080 by default
curl -H "Authorization: Bearer $KEY" -X POST localhost:8080/v1/index \
-H 'Content-Type: application/json' -d '{"repo_path": "~/my-project"}'
# {"index_id": "<uuid>", "files_indexed": 3, "files_failed": 0, "nodes": 15, "edges": 23, "diagnostics": 2}
curl -H "Authorization: Bearer $KEY" \
"localhost:8080/v1/graphs/<uuid>/descendants?node=<node-id>&expand=true"
```
Twenty-one endpoints under `/v1`, one index operation plus twenty
read-only queries: `POST /v1/index`, `GET /v1/graphs/{id}/{descendants, ancestors,
blast-radius, path, stats, verify, snapshot, neighborhood, symbol,
search, diagnostics, rank, diagnose-hotspot, diff, metrics, history, communities, topo-sort, render}`, `GET /v1/schema`. Full contract in
[`schemas/openapi.yaml`](schemas/openapi.yaml) (OpenAPI 3.1.0), env knobs
(`CODETOPO_BIND`, `CODETOPO_DATA_DIR`, `CODETOPO_KEYS_FILE`,
`CODETOPO_METERING_LOG`) documented in [`schemas/README.md`](schemas/README.md).
### MCP (`codetopo-mcp`)
A stdio JSON-RPC server exposing the same handler layer as twenty-one
tools — twenty atomic tools plus one composite. The atomic tools are
the sixteen query/integrity tools (`codetopo_index`, `codetopo_descendants`,
`codetopo_ancestors`, `codetopo_blast_radius`, `codetopo_path`,
`codetopo_stats`, `codetopo_verify`, `codetopo_snapshot`,
`codetopo_diagnostics`, `codetopo_rank`, `codetopo_diff`,
`codetopo_metrics`, `codetopo_history`, `codetopo_communities`,
`codetopo_topo_sort`, `codetopo_render`) plus discovery
(`codetopo_search_symbols`, `codetopo_get_symbol`,
`codetopo_neighborhood`, `codetopo_describe_schema`). The composite is
`codetopo_diagnose_hotspot`: a task-level hotspot diagnosis composed
from the atomics (rank, blast radius, neighborhood, diagnostics) — it
orchestrates and presents, and adds no measurement of its own. So an
in-process agent learns one surface and gets both. MCP answers are identical to the HTTP answers by
construction: both call the same `codetopo-core` queries.
```json
{ "mcpServers": { "codetopo": { "command": "codetopo-mcp" } } }
```
### ACP (`codetopo-acp`)
A stdio agent speaking the Agent Client Protocol — for editors and clients
that converse with agents instead of calling tools. Open a session on a
working directory and ask code-structure questions in plain language:
```
→ {"jsonrpc":"2.0","id":1,"method":"initialize","params":{}}
← {"jsonrpc":"2.0","id":1,"result":{"agent":"codetopo","protocolVersion":"1.0",
"agentCapabilities":{"read_only":true,"code_structure":true},"agentInfo":{"name":"codetopo"}}}
→ {"jsonrpc":"2.0","id":2,"method":"session/new","params":{"cwd":"/path/to/repo"}}
→ {"jsonrpc":"2.0","id":3,"method":"session/prompt",
"params":{"sessionId":"<id>","prompt":"blast radius of auth::login"}}
← {"jsonrpc":"2.0","id":3,"result":{"answer":"Blast radius of 'auth::login': 14 nodes — …"}}
```
Deterministic intent routing (descendants / ancestors / blast-radius / path /
stats / snapshot / verify) straight to the same `codetopo-core` queries —
no LLM, no network, no file writes. Edit requests get an honest read-only
refusal. stdout carries only protocol frames; diagnostics go to stderr.
## Hosted API (`codetopo` Hosted)
The same HTTP API, run by us, always on. We host the index; you send a
repository (public git URL or archive upload) and query the graph from
anywhere with your key — no local install, no server to run.
### Pricing
| Tier | Price | What it is |
|---|---|---|
| Free | US$0 | The local CLI, MCP server, and ACP agent in this repository — free and open source (AGPL-3.0), run on your own machine. |
| Team | US$19/month per key | The hosted API, run by us. |
| Guardrails | US$49/month per key | The hosted API at the Guardrails service level — the higher of the two hosted tiers. |
Included limits, by tier:
| Included | Team | Guardrails |
|---|---|---|
| Active indexes | 25 | 100 |
| Queries | 10,000 / month | 50,000 / month |
| Repository size | up to 50,000 files per index | up to 250,000 files per index |
How it works:
1. Subscribe — [Team](https://buy.stripe.com/cNi00j0hYbEIbT9bz89Zm02) · [Guardrails](https://buy.stripe.com/5kQ3cvd4K6kog9p32C9Zm0k) — checkout is handled by Stripe.
2. After payment you land on a claim page. Claim your API key there —
it is shown exactly once, so save it when it appears.
3. Call the API at `https://codetopo-api.aimlds.org` with
`Authorization: Bearer <key_id>:<secret>`, the same contract as the
self-hosted server (see `schemas/`).
Cancel any time from the Stripe receipt link; the key stays active
until the end of the paid period and is then revoked.
The hosted tiers are this same product, served: the local tools stay
free and open source and are unchanged — a hosted tier is for when you
want the graph served, not installed.
## Architecture
```
┌─────────────┐ tree-sitter ┌──────────────┐
│ source tree │ ───────────────► │ codetopo- │ extract symbols,
└─────────────┘ Rust, TS/JS, Py │ extract │ calls, references
└──────┬───────┘
▼
┌──────────────┐
│ codetopo-core│ graph model:
│ │ nodes, edges,
│ │ traversal queries
└──────┬───────┘
▼
┌──────────────┐
│ codetopo- │ SQLite store +
│ store │ hash-chained
│ │ audit log
└──────┬───────┘
│
┌──────────────────────────────────┼─────────────────────────────┐
▼ ▼ ▼ ▼
┌──────────────┐ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ codetopo │ │ codetopo- │ Bearer auth │ codetopo- │ stdio │ codetopo- │ stdio
│ (CLI) │ │ server │ JSONL │ mcp │ JSON-RPC │ acp │ ACP
└──────────────┘ └──────────────┘ metering └──────────────┘ └──────────────┘
```
| Crate | Role |
|---|---|
| `codetopo-core` | Graph model, node/edge kinds, all traversal queries, snapshots |
| `codetopo-extract` | tree-sitter extractors (Rust, TypeScript/JavaScript, Python, Kotlin, C, Java, Go, Shell, C++, Swift, Ruby, R, Julia, C#, PHP, Scala, Haskell, Elixir, Lua) |
| `codetopo-store` | SQLite persistence + tamper-evident, hash-chained audit log |
| `codetopo-cli` | `codetopo` headless CLI — the reference query surface |
| `codetopo-server` | `codetopo-server` axum HTTP API (thin adapter over core) |
| `codetopo-mcp` | `codetopo-mcp` stdio MCP server (thin adapter over core) |
| `codetopo-acp` | `codetopo-acp` stdio ACP agent — conversational sessions over the Agent Client Protocol (thin adapter over core) |
The CLI, HTTP, MCP, and ACP surfaces are all thin adapters over the same
handlers — they cannot disagree. `schemas/` keeps the machine-readable
contracts (OpenAPI 3.1, MCP tool catalogue) checked against the running
servers. The store's audit log follows the trust-primitive pattern used
across this product line: a hash-chained, append-only record, verified by
`codetopo verify` / `GET …/verify`.
## Docs
- [Development log](https://codetopo.aimlds.org/log/) — how codetopo got here and where it is going, in plain words (kept with the releases; also linked from the demo site)
- [`SKILL.md`](SKILL.md) — agent onboarding: when to reach for codetopo instead of grep, and the counts-first workflow
- [`docs/render.md`](docs/render.md) — deterministic render: the frozen layout spec (JSON) + SVG rules behind `codetopo render`
- [`docs/english-profile.md`](docs/english-profile.md) — the ENGLISH document profile: measured grammar under labelled claims, and what it never claims
- [`docs/english-accuracy.md`](docs/english-accuracy.md) — the ENGLISH profile's published accuracy statement (the parser audit behind its numbers)
- [`docs/protocol-proof.md`](docs/protocol-proof.md) — MCP/ACP conformance evidence: strict stdio clients + official-schema validation
- [`docs/scale-gate.md`](docs/scale-gate.md) — the 10,000-file scale gate and its measured record
- [`Dockerfile`](Dockerfile) + [`docker-compose.yml`](docker-compose.yml) — self-hosted container: the HTTP API over your own indexes
- [`docs/phase-2-design.md`](docs/phase-2-design.md) — API design: endpoints, auth, metering, aggregate-first discipline
- [`docs/phase-2-verification.md`](docs/phase-2-verification.md) — end-to-end verification report (fixture numbers above come from here)
- [`docs/phase-3-acp-design.md`](docs/phase-3-acp-design.md) — ACP agent design: wire protocol, intent routing, read-only guarantee
- [`docs/phase-3-acp-verification.md`](docs/phase-3-acp-verification.md) — ACP verification report
- [`docs/quickstart-verification.md`](docs/quickstart-verification.md) — clean-machine verification of the quickstart and example queries above
- [`schemas/README.md`](schemas/README.md) — the two agent-facing contracts and where the spec departs from the design doc
- [`CODE_SCHEMA.md`](CODE_SCHEMA.md) — the graph schema (§6 sets the aggregate-first rule)
## Privacy Policy
codetopo runs entirely on your machine. The MCP server (`codetopo-mcp`), the CLI, and the index databases they create never send your code, your queries, or any usage data anywhere: there are no accounts, no API keys, no telemetry, and no network calls at runtime. Indexing reads only the repositories you point it at and writes only the database paths you give it. To delete your data, delete the index database files (the `.db` files, or the HTTP server's data directory) — nothing is held on any server, so there is nothing elsewhere to erase. To take your data with you, export it with the `snapshot` command, which writes the whole graph as one portable JSON file. Questions about privacy: info@aimlds.org.
## License
- Engine (`codetopo-*` crates): **AGPL-3.0-or-later** (see `LICENSES/`)
- Agent-facing contracts (`schemas/`: OpenAPI 3.1 spec, MCP tool catalogue): **Apache-2.0** (see `schemas/LICENSE-APACHE`)
Owned by [Nrupal Akolkar](https://nrupalakolkar.com) · Built with [Muse by Meta](https://muse.ai/join).
TDQS
Scored across 21 tools
Most tools have sharply distinct purposes (stats vs verify vs snapshot vs diagnostics are clearly separated, and composite tools like diagnose_hotspot and rank explicitly state they only orchestrate atomic queries). The main confusion risk is the cluster of graph-traversal tools — neighborhood, descendants, ancestors, blast_radius, and path — which all return related node sets, though the descriptions do disambiguate direction and edge kinds. A few analysis tools (metrics, rank, communities, diagnose_hotspot) overlap in flavor but differ in output.
Every tool uses the codetopo_ prefix with snake_case, which is highly predictable. The only minor deviation is that some names are verb-first (get_symbol, search_symbols, describe_schema, topo_sort) while others are bare nouns (metrics, stats, diagnostics, communities, history), but this reads naturally rather than chaotically.
21 tools is at the heavy end, but the domain (indexing, graph traversal, metrics, community detection, history, diffing, audit/snapshot) is genuinely broad and each tool maps to a distinct analysis. It could be trimmed by folding e.g. ancestors/descendants or stats/diagnostics, but nothing feels gratuitous.
The surface covers the full lifecycle: index creation, querying, structural traversal, measurement, visualization specs, snapshots, and audit verification. The notable gap is index management — there is no way to list existing indexes or delete/drop one, and no raw/arbitrary graph query escape hatch, so agents working with multiple indexes have a dead end.