You've got CodeGraph MCP installed and a graph built. Here's where to go next.
Understand the model
- How It Works — the extraction → storage → resolution → sync pipeline.
- The Knowledge Graph — the node and edge kinds the graph is built from.
- Runtime Telemetry Reconciliation — reconciling static AST edges against live recorded traces.
- Database Lineage & Schema — tracing mutating SQL writers, columns, and ORM models.
- Resolution & Frameworks — how references and framework routes get connected.
Put it to work
- Indexing a Project — full index, incremental sync, and the file watcher.
-
Reading Your Graph in the Browser —
codegraph ui: callers, source and callees on one screen. - Framework Routes — link URL patterns to their handlers.
- Affected Tests in CI — run only the tests a change touches.
- Database Schema & Writers — find all tables, models, and mutating SQL queries.
- MCP Tools Reference — 56 verified tools exposed over Model Context Protocol.
Introduction
CodeGraph MCP is a deterministic, local-first code-intelligence engine for AI coding agents. Instead of letting agents waste context tokens repeatedly running grep, find, and reading hundreds of random files, CodeGraph MCP pre-indexes the structural relationships of a repository.
It parses code locally using Tree-sitter to deterministically extract symbols, definitions, class hierarchies, import chains, and function call relationships. The extracted graph is stored local-first inside a project-level SQLite database with WAL mode and FTS5 full-text search.
Quickstart
Install CodeGraph MCP from PyPI with complete CLI and FastMCP server bindings:
pip install "codegraph-engine[mcp]"
Initialize and index your repository:
cd /path/to/project codegraph init . codegraph index . codegraph status .
Configuration
Add CodeGraph MCP to Claude Code, Cursor, Windsurf, or Antigravity via your standard MCP config:
{
"mcpServers": {
"codegraph": {
"command": "codegraph",
"args": ["serve", "."]
}
}
}
How It Works
CodeGraph MCP operates through a deterministic four-phase pipeline:
- Tree-sitter Parsing: Source files are parsed incrementally into concrete ASTs. Zero LLM hallucinations.
- Relational Graph Storage: Symbols, calls, imports, and routes are stored in SQLite with foreign-key constraints.
- Deterministic Resolution: Canonical IDs, qualified names, and route endpoints are resolved with explicit ambiguity states.
- MCP Tool Serving: FastMCP stdio server serves 56 verified tools with token-bounded context packets.
Runtime Telemetry Reconciliation
Static analysis alone cannot detect runtime dynamic dispatch, monkey-patching, or live test coverage. CodeGraph MCP reconciles static AST graph edges against recorded runtime execution traces.
RUNTIME_OBSERVED edges. If a static path is not triggered during tests, it is flagged as NOT_OBSERVED_AT_RUNTIME without claiming it cannot execute.
Database Lineage & Schema Intelligence
CodeGraph MCP indexes relational databases, migrations, and ORMs (SQLAlchemy, Prisma, Django ORM). It connects tables and columns to the exact Python or TypeScript functions that read or write them.
INSERT, UPDATE, or DELETE queries before performing breaking database migrations.
Indexing a Project
Run codegraph index . to scan and parse all files in your repository. Incremental indexing utilizes content hashes so subsequent runs finish in milliseconds.
Reading Your Graph in the Browser
Launch the local interactive visualizer with codegraph ui to explore callers, callees, and database relationships directly in your browser.
Framework Routes
CodeGraph MCP automatically traces routes for FastAPI, Flask, Django, and Express.js, connecting HTTP verbs and path templates directly to their handler symbols.
Affected Tests in CI
Use find_related_tests to discover the exact subset of unit and integration tests covering a modified symbol, optimizing continuous integration test run times.
Database Schema & Writers
Query find_db_tables, find_db_columns, and find_db_writers to audit data flow before performing database refactors.
MCP Tools Reference (56 Verified Tools)
Every tool exposed by CodeGraph MCP over Model Context Protocol, categorized into Database, Runtime, Graph, Core, Routes, Git, and Tests.
Database Lineage & Schema Tools (11)
Tools for table inspection, column typing, mutating SQL writers, and schema impact analysis.
Find database tables discovered across ORM models, raw SQL queries, and migrations. Use instead of grep when asking which database tables exist in this repository. Returns canonical IDs (`db.<dialect>.<schema>.<table>`), columns, ORM models, and evidence classes (`FRAMEWORK_VERIFIED`, `STATIC_VERIFIED`, `POSSIBLE`, `UNKNOWN`). Does not connect to live databases or execute SQL.
| Parameter | Type | Status | Default | Description |
|---|---|---|---|---|
| table | string | Optional | Table | |
| dialect | string | Optional | Dialect | |
| schema | string | Optional | Schema |
find_db_tables()
DatabaseTableListResult| Field | Type | Description |
|---|---|---|
| status | string | Status |
| tables | array | Tables |
| count | integer | Count |
Find database columns, data types, nullability, primary keys, and foreign keys across tables and ORM models. Use instead of grep when locating where a table column is defined or mapped (`MAPS_TO_COLUMN`, `HAS_PRIMARY_KEY`, `FOREIGN_KEY_TO`). Returns column definitions and source coordinates. Does not inspect live database catalogs.
| Parameter | Type | Status | Default | Description |
|---|---|---|---|---|
| table | string | Optional | Table | |
| column | string | Optional | Column |
find_db_columns(table="bills")
DatabaseColumnListResult| Field | Type | Description |
|---|---|---|
| status | string | Status |
| columns | array | Columns |
| count | integer | Count |
Find ORM models (SQLAlchemy, Flask-SQLAlchemy, Django ORM, SQLModel, Prisma) and their `MAPS_TO_TABLE` mappings. Use when asking which model class maps to a database table or vice versa. Returns model name, table, canonical ID, and `FRAMEWORK_VERIFIED` evidence. Does not import or execute application model modules.
| Parameter | Type | Status | Default | Description |
|---|---|---|---|---|
| model | string | Optional | Model | |
| table | string | Optional | Table |
find_db_models(table="products")
DatabaseModelListResult| Field | Type | Description |
|---|---|---|
| status | string | Status |
| models | string | Models |
| count | integer | Count |
Find database queries (`SELECT`, `INSERT`, `UPDATE`, `DELETE`) across ORM calls, query builders, and raw SQL strings. Use when asking which queries touch a table or what SQL a function executes. Returns `READS_TABLE`, `WRITES_TABLE`, `POSSIBLE_TABLE`, or `UNKNOWN_TABLE` with redacted snippets. Never exposes SQL literal secret parameters.
| Parameter | Type | Status | Default | Description |
|---|---|---|---|---|
| table | string | Optional | Table | |
| symbol | string | Optional | Symbol | |
| operation | string | Optional | Operation |
find_db_queries(table="orders")
DatabaseQueryListResult| Field | Type | Description |
|---|---|---|
| status | string | Status |
| queries | array | Queries |
| count | integer | Count |
Find all functions, methods, and upstream HTTP routes (`HANDLED_BY`) that read from or write to a database table. Use instead of grep when asking which code or route reaches a table. Returns direct accessors, upstream routes, relationships (`READS_TABLE`, `WRITES_TABLE`), and evidence classes. Does not prove runtime query frequency.
| Parameter | Type | Status | Default | Description |
|---|---|---|---|---|
| table | string | Required | - | Table |
find_db_callers(table="products")
DatabaseCallersResult| Field | Type | Description |
|---|---|---|
| status | string | Status |
| table | string | Table |
| direct_accessors | string | Direct Accessors |
| upstream_routes | array | Upstream Routes |
| count | integer | Count |
Find all symbols and queries that write (`INSERT`, `UPDATE`, `DELETE`) to a database table or column (`WRITES_TABLE`, `WRITES_COLUMN`). Use when investigating data mutations, state changes, or write blast radius. Returns writer symbols, operations, file:line citations, and redacted snippets. Does not execute database transactions.
| Parameter | Type | Status | Default | Description |
|---|---|---|---|---|
| table | string | Optional | Table | |
| column | string | Optional | Column |
find_db_writers(table="products")
DatabaseWritersResult| Field | Type | Description |
|---|---|---|
| status | string | Status |
| writers | array | Writers |
| count | integer | Count |
Find all symbols and queries that read (`SELECT`, `.query()`, `.objects.filter()`, `.findMany()`) from a database table or column (`READS_TABLE`, `READS_COLUMN`). Use when tracing where table data is consumed across services and views. Returns reader symbols, operations, and evidence classes. Does not prove runtime cache hits.
| Parameter | Type | Status | Default | Description |
|---|---|---|---|---|
| table | string | Optional | Table | |
| column | string | Optional | Column |
find_db_readers(table="users")
DatabaseReadersResult| Field | Type | Description |
|---|---|---|
| status | string | Status |
| readers | array | Readers |
| count | integer | Count |
Find database schema and ORM relationships (`FOREIGN_KEY_TO`, `ORM_RELATION`, `MAPS_TO_TABLE`, `HAS_PRIMARY_KEY`, `HAS_INDEX`, `MIGRATES_TABLE`). Use when inspecting foreign keys, table joins, or model associations. Preserves explicit database relationship types and never collapses them into generic `DEPENDS_ON`.
| Parameter | Type | Status | Default | Description |
|---|---|---|---|---|
| table | string | Optional | Table |
find_db_relationships(table="orders")
DatabaseRelationshipsResult| Field | Type | Description |
|---|---|---|
| status | string | Status |
| relationships | string | Relationships |
| count | integer | Count |
Return complete structural details for a database table including columns, primary keys, foreign keys, indexes, constraints, ORM models, readers, writers, migrations, and upstream routes. Use when inspecting a specific table's schema and code usage in one call. Does not query live database servers.
| Parameter | Type | Status | Default | Description |
|---|---|---|---|---|
| table | string | Required | - | Table |
get_db_table(table="products")
DatabaseTableDetailResult| Field | Type | Description |
|---|---|---|
| status | string | Status |
| table | string | Table |
| canonical_id | string | Canonical Id |
| dialect | string | Dialect |
| schema | string | Schema |
| columns | array | Columns |
| primary_keys | string | Primary Keys |
| foreign_keys | string | Foreign Keys |
| indexes | string | Indexes |
| orm_models | string | Orm Models |
| readers | array | Readers |
| writers | array | Writers |
| migrations | string | Migrations |
| upstream_routes | array | Upstream Routes |
Return a repository-wide database schema summary including all discovered tables, columns, ORM models, foreign keys, and migrations. Use for database architecture overviews or schema audits. Preserves `UNKNOWN` dialect and schema when not statically provable and never guesses database names.
| Parameter | Type | Status | Default | Description |
|---|---|---|---|---|
| dialect | string | Optional | Dialect | |
| schema | string | Optional | Schema |
get_db_schema()
DatabaseSchemaOverviewResult| Field | Type | Description |
|---|---|---|
| status | string | Status |
| dialects | string | Dialects |
| schemas | string | Schemas |
| tables | array | Tables |
| orm_models | string | Orm Models |
| foreign_keys | string | Foreign Keys |
| migrations | string | Migrations |
| env_variables | string | Env Variables |
Compute bidirectional Code <-> Database change impact for a table or column, returning affected ORM models, readers, writers, upstream HTTP routes, migrations, and statically linked tests. Use before renaming or altering a database table or column. Does not execute database migrations or tests.
| Parameter | Type | Status | Default | Description |
|---|---|---|---|---|
| table | string | Optional | Table | |
| column | string | Optional | Column |
get_db_impact(table="products", column="shop_id")
DatabaseImpactResult| Field | Type | Description |
|---|---|---|
| status | string | Status |
| table | string | Table |
| column | string | Column |
| affected_models | string | Affected Models |
| affected_readers | array | Affected Readers |
| affected_writers | array | Affected Writers |
| affected_routes | array | Affected Routes |
| affected_migrations | string | Affected Migrations |
| affected_tests | array | Affected Tests |
Runtime Telemetry & Reconciliation Tools (6)
Tools for execution trace recording, runtime observation reconciliation, and dynamic call tracing.
Compute deterministic multi-hop relationship paths between two symbols (`from_symbol` -> `to_symbol`). Use when tracing how an entrypoint, route, or caller reaches a downstream service or database function. Returns ordered hop edges with relationship types and evidence classes. Does not prove runtime branch conditions along the path.
| Parameter | Type | Status | Default | Description |
|---|---|---|---|---|
| from_symbol | string | Optional | From Symbol | |
| to_symbol | string | Optional | To Symbol | |
| start_symbol | string | Optional | Start Symbol | |
| target_symbol | string | Optional | Target Symbol | |
| source_symbol | string | Optional | Source Symbol | |
| max_depth | integer | Optional | 5 | Max Depth |
trace_path(from_symbol="login_endpoint", to_symbol="find_by_email", max_depth=4)
PathTraceResult| Field | Type | Description |
|---|---|---|
| status | string | Status |
| from_symbol | string | From Symbol |
| to_symbol | string | To Symbol |
| path | string | Path |
| paths | string | Paths |
| hops | string | Hops |
| evidence_class | string | Evidence Class |
| confidence | string | Confidence |
Traverse callers, callees, or both from a single `symbol` (`canonical_id` supported as alias) up to `depth` with confidence and relationship labels. Use when exploring upstream and/or downstream call trees from one symbol without a known second endpoint. Does not prove runtime branch execution.
| Parameter | Type | Status | Default | Description |
|---|---|---|---|---|
| symbol | string | Optional | Symbol | |
| canonical_id | string | Optional | Canonical Id | |
| depth | integer | Optional | 2 | Depth |
| callers | boolean | Optional | True | Callers |
| callees | boolean | Optional | False | Callees |
| both | boolean | Optional | False | Both |
trace_call(symbol="verify_password", depth=2, callers=True)
DirectionalCallTraceList| Field | Type | Description |
|---|---|---|
| source | string | Source |
| target | string | Target |
| relationship | string | Relationship |
| confidence | string | Confidence |
| evidence_class | string | Evidence Class |
| depth | integer | Depth |
| file | string | File |
| start_line | integer | Start Line |
Trace multi-hop upstream callers and downstream callees around a single symbol (`symbol`; `canonical_id` supported as alias) up to `depth`. Use when exploring bidirectional execution flow around a function or handler without a known second endpoint. Does not prove runtime branch execution; use trace_path when both endpoints are known.
| Parameter | Type | Status | Default | Description |
|---|---|---|---|---|
| symbol | string | Optional | Symbol | |
| canonical_id | string | Optional | Canonical Id | |
| depth | integer | Optional | 2 | Depth |
| callers | boolean | Optional | True | Callers |
| callees | boolean | Optional | False | Callees |
| both | boolean | Optional | False | Both |
trace_flow(symbol="place_order", depth=2)
DirectionalCallTraceList| Field | Type | Description |
|---|---|---|
| source | string | Source |
| target | string | Target |
| relationship | string | Relationship |
| confidence | string | Confidence |
| evidence_class | string | Evidence Class |
| depth | integer | Depth |
| file | string | File |
| start_line | integer | Start Line |
Ingest optional runtime observation traces (OpenTelemetry JSON, structured JSON/JSONL events, or SQL query logs) into CodeGraph's `RUNTIME_OBSERVED` layer. Use when grounding static analysis with recorded runtime traces. Automatically strips headers/cookies/bodies, redacts SQL bind parameters and secrets, and never converts runtime observations into static `AST_VERIFIED` proof.
| Parameter | Type | Status | Default | Description |
|---|---|---|---|---|
| source_path | string | Optional | Source Path | |
| format | string | Optional | auto | Format |
| payload | string | Optional | Payload | |
| max_events | integer | Optional | 5000 | Max Events |
| sample_rate | number | Optional | 1.0 | Sample Rate |
ingest_runtime_traces(source_path="traces/scan_bill.json")
RuntimeIngestResult| Field | Type | Description |
|---|---|---|
| status | string | Status |
| runtime_generation | string | Runtime Generation |
| events_ingested | string | Events Ingested |
| edges_recorded | array | Edges Recorded |
| redacted_fields | string | Redacted Fields |
Retrieve aggregated runtime execution edges (`RUNTIME_OBSERVED`) and reverse maps (`table -> runtime writers/readers`, `route -> runtime tables`) with `observation_count`, `first_seen`, `last_seen`, and `runtime_generation`. Use when asking what actually happened at runtime. Does not treat unobserved paths as impossible.
| Parameter | Type | Status | Default | Description |
|---|---|---|---|---|
| route | string | Optional | Route | |
| symbol | string | Optional | Symbol | |
| table | string | Optional | Table |
get_runtime_trace(route="/api/scan-bill")
RuntimeTraceResult| Field | Type | Description |
|---|---|---|
| status | string | Status |
| edges | array | Edges |
| observations | string | Observations |
| reverse_maps | string | Reverse Maps |
| count | integer | Count |
Reconcile static repository edges against ingested runtime observations, classifying edges into `CONFIRMED_RUNTIME_PATH`, `STATIC_RUNTIME_CONFLICT`, `NOT_OBSERVED_AT_RUNTIME`, and `RUNTIME_ONLY_OBSERVED`. Use when comparing static code analysis with runtime behavior. Never treats `NOT_OBSERVED_AT_RUNTIME` as proof that a path cannot execute.
| Parameter | Type | Status | Default | Description |
|---|---|---|---|---|
| symbol | string | Optional | Symbol | |
| route | string | Optional | Route | |
| table | string | Optional | Table |
reconcile_static_runtime(route="/api/scan-bill")
StaticRuntimeReconciliationResult| Field | Type | Description |
|---|---|---|
| status | string | Status |
| confirmed_runtime_paths | string | Confirmed Runtime Paths |
| static_runtime_conflicts | string | Static Runtime Conflicts |
| not_observed_at_runtime | boolean | Not Observed At Runtime |
| runtime_only_observed | boolean | Runtime Only Observed |
| summary | string | Summary |
Graph Traversal & Call Hierarchy Tools (8)
Directional call hierarchies, caller/callee graphs, and change impact propagation.
Return statically verified callers of a symbol with confidence and evidence_class. Primary input: `symbol` (also accepts `canonical_id` as a compatibility alias using the exact same resolution path). Use for multi-file call-relationship and upstream impact questions. Does not prove runtime dispatch unless evidence_class indicates framework/dataflow verification.
| Parameter | Type | Status | Default | Description |
|---|---|---|---|---|
| symbol | string | Optional | Symbol | |
| canonical_id | string | Optional | Canonical Id |
get_callers(symbol="verify_password")
CallerListResult| Field | Type | Description |
|---|---|---|
| status | string | Status |
| canonical_id | string | Canonical Id |
| callers | array | Callers |
| source | string | Source |
| relationship | string | Relationship |
| evidence_class | string | Evidence Class |
| confidence | string | Confidence |
| file | string | File |
| start_line | integer | Start Line |
Return symbols called or invoked by the specified symbol with evidence_class classification. Primary input: `symbol` (also accepts `canonical_id` as a compatibility alias using the exact same resolution path). Use to inspect downstream dependencies invoked by a function or handler. Does not resolve dynamic callbacks passed as opaque runtime arguments.
| Parameter | Type | Status | Default | Description |
|---|---|---|---|---|
| symbol | string | Optional | Symbol | |
| canonical_id | string | Optional | Canonical Id |
get_callees(symbol="process_checkout")
CalleeListResult| Field | Type | Description |
|---|---|---|
| status | string | Status |
| canonical_id | string | Canonical Id |
| callees | array | Callees |
| target | string | Target |
| relationship | string | Relationship |
| evidence_class | string | Evidence Class |
| confidence | string | Confidence |
| file | string | File |
| start_line | integer | Start Line |
Compute downstream callers, dependents, affected routes, and related tests if a symbol (`symbol`; `canonical_id` supported as alias) is modified. Use before refactoring or changing a function/class signature. Does not prove runtime failure without inspecting call sites.
| Parameter | Type | Status | Default | Description |
|---|---|---|---|---|
| symbol | string | Optional | Symbol | |
| canonical_id | string | Optional | Canonical Id | |
| max_depth | integer | Optional | 3 | Max Depth |
analyze_impact(symbol="DatabasePool.acquire", max_depth=3)
SymbolImpactResult| Field | Type | Description |
|---|---|---|
| symbol | string | Symbol |
| direct_callers | array | Direct Callers |
| transitive_callers | array | Transitive Callers |
| dependent_files | array | Dependent Files |
| affected_routes | array | Affected Routes |
| related_tests | array | Related Tests |
Find functions and methods that call the specified symbol (`symbol`; `canonical_id` supported as alias) up to `max_results`. Use instead of grep or search_code when answering 'who calls X?'. Does not prove runtime execution of conditional branches; preserves POSSIBLE and UNKNOWN evidence classes.
| Parameter | Type | Status | Default | Description |
|---|---|---|---|---|
| symbol | string | Optional | Symbol | |
| canonical_id | string | Optional | Canonical Id | |
| max_results | integer | Optional | 20 | Max Results |
find_callers(symbol="place_order", max_results=20)
CallerEdgeList| Field | Type | Description |
|---|---|---|
| source | string | Source |
| target | string | Target |
| relationship | string | Relationship |
| confidence | string | Confidence |
| evidence_class | string | Evidence Class |
| file | string | File |
| start_line | integer | Start Line |
Find functions and methods called by the specified symbol (`symbol`; `canonical_id` supported as alias) up to `max_results`. Use instead of reading multiple files manually when answering 'what does X call?'. Does not resolve opaque runtime callbacks; preserves POSSIBLE and UNKNOWN evidence classes.
| Parameter | Type | Status | Default | Description |
|---|---|---|---|---|
| symbol | string | Optional | Symbol | |
| canonical_id | string | Optional | Canonical Id | |
| max_results | integer | Optional | 20 | Max Results |
find_callees(symbol="place_order", max_results=20)
CalleeEdgeList| Field | Type | Description |
|---|---|---|
| source | string | Source |
| target | string | Target |
| relationship | string | Relationship |
| confidence | string | Confidence |
| evidence_class | string | Evidence Class |
| file | string | File |
| start_line | integer | Start Line |
Compute the multi-hop call graph rooted at `symbol` (`canonical_id` supported as alias) up to `depth` and `max_results`. Use when exploring the multi-hop call neighborhood around a central service or controller. Does not prove runtime reachability for specific inputs.
| Parameter | Type | Status | Default | Description |
|---|---|---|---|---|
| symbol | string | Optional | Symbol | |
| canonical_id | string | Optional | Canonical Id | |
| depth | integer | Optional | 2 | Depth |
| max_results | integer | Optional | 100 | Max Results |
get_call_graph(symbol="AuthService.authenticate", depth=2, max_results=50)
CallGraphEdgeList| Field | Type | Description |
|---|---|---|
| source | string | Source |
| target | string | Target |
| relationship | string | Relationship |
| confidence | string | Confidence |
| evidence_class | string | Evidence Class |
| depth | integer | Depth |
| file | string | File |
| start_line | integer | Start Line |
Return module-level `IMPORTS` graph edges across the repository or filtered to `file_path`. Use when inspecting raw module-to-module import topology. Does not prove symbol-level call invocation; prefer get_imports or get_dependents for targeted queries.
| Parameter | Type | Status | Default | Description |
|---|---|---|---|---|
| file_path | any | Optional | None | File Path |
get_dependency_graph(file_path="src/auth/service.py")
DependencyGraphEdgeList| Field | Type | Description |
|---|---|---|
| source | string | Source |
| target | string | Target |
| relationship | string | Relationship |
| confidence | string | Confidence |
| evidence | string | Evidence |
Return up to `limit` (1..500) parser-confirmed definition and import graph edges with evidence metadata. Use for inspecting raw structural `DEFINES` and `IMPORTS` edges in small repositories or diagnostics. Does not replace targeted relationship tools like get_callers or trace_path.
| Parameter | Type | Status | Default | Description |
|---|---|---|---|---|
| limit | integer | Optional | 200 | Limit |
get_graph(limit=50)
GraphEdgeList| Field | Type | Description |
|---|---|---|
| source | string | Source |
| target | string | Target |
| relationship | string | Relationship |
| confidence | string | Confidence |
| evidence_class | string | Evidence Class |
| file | string | File |
| line | integer | Line |
Core Symbol Inspection & Context Tools (23)
Canonical symbol resolution, bounded context packets, file slices, and evidence verification.
Resolve a symbol name, qualified name, canonical ID, or route into its canonical repository identity and file/line location. Use as the first step before relationship queries when exact symbol identity is unknown or potentially ambiguous. Primary input: `symbol` (also accepts `canonical_id` or `name` as compatibility aliases). Returns canonical_id, ambiguity_state, and candidate alternatives. Does not prove runtime execution or dynamic monkey-patching.
| Parameter | Type | Status | Default | Description |
|---|---|---|---|---|
| symbol | string | Optional | Symbol | |
| canonical_id | string | Optional | Canonical Id | |
| name | string | Optional | Name |
resolve_symbol(symbol="AuthService")
SymbolResolutionResult| Field | Type | Description |
|---|---|---|
| status | string | Status |
| canonical_id | string | Canonical Id |
| qualified_name | string | Qualified Name |
| file | string | File |
| start_line | integer | Start Line |
| end_line | integer | End Line |
| ambiguity_state | string | Ambiguity State |
| matches | array | Matches |
| alternatives | array | Alternatives |
Search indexed repository symbols by partial name or keyword with ranked relevance. Use when exact symbol spelling is unknown and you need candidate symbol definitions. Returns ranked symbol definitions with file paths and line spans. Does not return module import graphs or call relationships.
| Parameter | Type | Status | Default | Description |
|---|---|---|---|---|
| query | string | Required | - | Query |
| top_k | integer | Optional | 20 | Top K |
search_symbols(query="verify_password", top_k=10)
SymbolSearchResult| Field | Type | Description |
|---|---|---|
| status | string | Status |
| query | string | Query |
| results | string | Results |
| canonical_id | string | Canonical Id |
| qualified_name | string | Qualified Name |
| kind | string | Kind |
| file | string | File |
| start_line | integer | Start Line |
| end_line | integer | End Line |
Return authoritative signature, kind, parent scope, decorators, and bounded source snippet for a symbol. Primary input: `symbol` (also accepts `canonical_id` or `name` as compatibility aliases). Use when you have a symbol name or canonical_id and need its declaration metadata. Does not traverse multi-hop call graphs.
| Parameter | Type | Status | Default | Description |
|---|---|---|---|---|
| symbol | string | Optional | Symbol | |
| canonical_id | string | Optional | Canonical Id | |
| name | string | Optional | Name |
get_symbol(symbol="login_endpoint")
SymbolDetailResult| Field | Type | Description |
|---|---|---|
| status | string | Status |
| canonical_id | string | Canonical Id |
| qualified_name | string | Qualified Name |
| kind | string | Kind |
| signature | string | Signature |
| decorators | string | Decorators |
| file | string | File |
| start_line | integer | Start Line |
| end_line | integer | End Line |
| snippet | string | Snippet |
Open and inspect a repository file's structural AST outline or a bounded line range (`path`, `start_line`, `end_line`, `max_lines`). Use after `search_code`, `find_symbol`, or `find_routes` identifies a target file and line span across Python, HTML, Jinja, JS, TS, CSS, YAML, JSON, or Markdown. Blocks path traversal, binary files, and sensitive files; does not prove cross-file callers.
| Parameter | Type | Status | Default | Description |
|---|---|---|---|---|
| path | string | Required | - | Path |
| start_line | any | Optional | None | Start Line |
| end_line | any | Optional | None | End Line |
| max_lines | integer | Optional | 200 | Max Lines |
| include_content | boolean | Optional | False | Include Content |
get_file(path="templates/dashboard.html", start_line=40, end_line=110)
FileStructureResult| Field | Type | Description |
|---|---|---|
| status | string | Status |
| path | string | Path |
| file | string | File |
| start_line | integer | Start Line |
| end_line | integer | End Line |
| content | string | Content |
| truncated | boolean | Truncated |
| category | string | Category |
| file_category | string | File Category |
| artifact_type | string | Artifact Type |
| symbols | array | Symbols |
| imports | string | Imports |
| freshness | boolean | Freshness |
Return verified and candidate references to a symbol across the repository with evidence_class labels. Primary input: `symbol` (also accepts `canonical_id` or `name` as compatibility aliases). Use for cross-file reference, registration, dispatch, or DI binding lookup. Does not guarantee dynamic reflection targets when evidence_class is UNKNOWN or POSSIBLE.
| Parameter | Type | Status | Default | Description |
|---|---|---|---|---|
| symbol | string | Optional | Symbol | |
| canonical_id | string | Optional | Canonical Id | |
| name | string | Optional | Name |
get_references(symbol="command_registry")
ReferenceListResult| Field | Type | Description |
|---|---|---|
| status | string | Status |
| canonical_id | string | Canonical Id |
| references | string | References |
| relationship | string | Relationship |
| evidence_class | string | Evidence Class |
| confidence | string | Confidence |
| file | string | File |
| start_line | integer | Start Line |
Return parser-extracted module and symbol imports for a file or symbol (`file` or `symbol`; `canonical_id` and `path` supported as aliases). Use for forward dependency and package boundary questions. Does not return reverse importers (use get_dependents for reverse dependencies).
| Parameter | Type | Status | Default | Description |
|---|---|---|---|---|
| symbol | any | Optional | None | Symbol |
| file | any | Optional | None | File |
| canonical_id | any | Optional | None | Canonical Id |
| path | any | Optional | None | Path |
get_imports(file="src/auth/routes.py")
ImportsResult| Field | Type | Description |
|---|---|---|
| status | string | Status |
| file | string | File |
| imports | string | Imports |
| source | string | Source |
| target | string | Target |
| relationship | string | Relationship |
| evidence_class | string | Evidence Class |
Return files, symbols, and packages that import or depend on the target symbol or file (`symbol` or `file`; `canonical_id` and `path` supported as aliases). Use for blast-radius, change-impact, and package boundary analysis. Does not prove runtime failure without checking test and caller evidence.
| Parameter | Type | Status | Default | Description |
|---|---|---|---|---|
| symbol | any | Optional | None | Symbol |
| file | any | Optional | None | File |
| canonical_id | any | Optional | None | Canonical Id |
| path | any | Optional | None | Path |
get_dependents(file="src/auth/repository.py")
DependentsResult| Field | Type | Description |
|---|---|---|
| status | string | Status |
| dependents | string | Dependents |
| source | string | Source |
| target | string | Target |
| relationship | string | Relationship |
| evidence_class | string | Evidence Class |
| file | string | File |
Return structural repository overview including modules, workspace packages (`DEPENDS_ON_PACKAGE`), entrypoints, and layer relationships. Use for high-level architecture, monorepo package boundary, and onboarding questions. Does not replace symbol-level evidence for specific bug fixes.
| Parameter | Type | Status | Default | Description |
|---|---|---|---|---|
| No arguments required. | ||||
get_architecture()
ArchitectureOverviewResult| Field | Type | Description |
|---|---|---|
| status | string | Status |
| modules | string | Modules |
| packages | string | Packages |
| package_dependencies | string | Package Dependencies |
| entrypoints | string | Entrypoints |
| routes | array | Routes |
| summary | string | Summary |
Compile a token-bounded, coverage-optimized ContextPacket containing verified symbols, compressed relationships, routes, DI providers, packages, and related tests. Primary input: `query` (natural-language question, symbol, or task description; `task` is also supported as a compatibility alias for string or structured TaskSpec dict). Budget controls: `max_tokens` (default 4000, hard cap 20000), `max_files` (default 15, hard cap 30), `max_lines` (default 500, hard cap 1500). Preserves UNKNOWN, POSSIBLE, and AMBIGUOUS states explicitly. Does not return full raw files; use targeted get_file or read_file only if exact omitted lines are needed afterward.
| Parameter | Type | Status | Default | Description |
|---|---|---|---|---|
| query | string | Optional | Query | |
| task | any | Optional | Task | |
| intent | any | Optional | None | Intent |
| max_tokens | integer | Optional | 4000 | Max Tokens |
| max_files | integer | Optional | 15 | Max Files |
| max_lines | integer | Optional | 500 | Max Lines |
| top_k | integer | Optional | 15 | Top K |
| plan | any | Optional | None | Plan |
| mode | string | Optional | BALANCED | Mode |
| explain | boolean | Optional | False | Explain |
| resource_mode | any | Optional | None | Resource Mode |
get_context(query="How does UserRepository get injected into UserController", intent="DEBUG", max_tokens=4000)
ContextPacket| Field | Type | Description |
|---|---|---|
| symbols | array | Symbols |
| relationships | string | Relationships |
| routes | array | Routes |
| tests | array | Tests |
| packages | string | Packages |
| unknowns | string | Unknowns |
| conflicts | string | Conflicts |
| uncertainties | string | Uncertainties |
| freshness | boolean | Freshness |
| selected_tokens | integer | Selected Tokens |
| candidate_tokens | integer | Candidate Tokens |
| selected_files | array | Selected Files |
| selected_lines | integer | Selected Lines |
| coverage_score | string | Coverage Score |
| truncated | boolean | Truncated |
| candidate_token_estimate | string | Candidate Token Estimate |
| selected_token_estimate | string | Selected Token Estimate |
| context_reduction_pct | string | Context Reduction Pct |
| coverage | string | Coverage |
Read a bounded line range (1..500 lines) of a non-sensitive repository file. Use AFTER CodeGraph tools identify the exact file and line span, or directly for trivial single-file edits. Blocks path traversal and sensitive credential files. Does not compute cross-file relationships.
| Parameter | Type | Status | Default | Description |
|---|---|---|---|---|
| path | string | Required | - | Path |
| start_line | integer | Optional | 1 | Start Line |
| end_line | integer | Optional | 200 | End Line |
read_file(path="src/auth/service.py", start_line=10, end_line=45)
FileContentSlice| Field | Type | Description |
|---|---|---|
| file | string | File |
| start_line | integer | Start Line |
| end_line | integer | End Line |
| content | string | Content |
Search literal text, HTML/Jinja template IDs, UI strings, CSS selectors, config keys, or route paths across readable repository files and indexed code chunks. Use instead of grep when searching for exact text, button labels, or template strings. Does not prove semantic call, import, or route relationships; never creates semantic graph edges from text matches.
| Parameter | Type | Status | Default | Description |
|---|---|---|---|---|
| query | string | Required | - | Query |
| top_k | integer | Optional | 10 | Top K |
| path_filter | any | Optional | None | Path Filter |
| file_types | any | Optional | None | File Types |
| include_tests | boolean | Optional | True | Include Tests |
| include_configs | boolean | Optional | True | Include Configs |
| max_results | integer | Optional | 20 | Max Results |
search_code(query="Add Manual Entry", top_k=10)
CodeChunkSearchResult| Field | Type | Description |
|---|---|---|
| path | string | Path |
| file | string | File |
| line | integer | Line |
| start_line | integer | Start Line |
| end_line | integer | End Line |
| matched_text | string | Matched Text |
| snippet | string | Snippet |
| category | string | Category |
| file_category | string | File Category |
| match_type | string | Match Type |
| symbol | string | Symbol |
| score | string | Score |
| reason | string | Reason |
Find function, method, or class definitions by exact short name or qualified name (`symbol`; `name` and `canonical_id` supported as aliases). Use instead of grep when locating where a class, function, or method is defined. Does not return callers, callees, or ambiguity alternatives like resolve_symbol.
| Parameter | Type | Status | Default | Description |
|---|---|---|---|---|
| symbol | string | Optional | Symbol | |
| name | string | Optional | Name | |
| canonical_id | string | Optional | Canonical Id |
find_symbol(symbol="InventoryService")
SymbolLocationList| Field | Type | Description |
|---|---|---|
| symbol | string | Symbol |
| kind | string | Kind |
| file | string | File |
| start_line | integer | Start Line |
| end_line | integer | End Line |
Find textual occurrences and references of a symbol name (`symbol`; `name` and `canonical_id` supported as aliases) across indexed code chunks. Use when locating references or mentions of an identifier across files. Does not prove semantic call edges; use get_references when full relationship classification is required.
| Parameter | Type | Status | Default | Description |
|---|---|---|---|---|
| symbol | string | Optional | Symbol | |
| name | string | Optional | Name | |
| canonical_id | string | Optional | Canonical Id |
find_references(symbol="parse_bill")
ChunkReferenceList| Field | Type | Description |
|---|---|---|
| file | string | File |
| symbol | string | Symbol |
| start_line | integer | Start Line |
| end_line | integer | End Line |
Normalize a developer question or task (`query`; `task` supported as string or TaskSpec dict alias) into a structured `TaskSpec`, ground targets against the index, detect ambiguities, and build a `RetrievalPlan`. Use before get_context when you want to inspect target resolution and ambiguity candidates prior to context retrieval. Does not retrieve source code snippets.
| Parameter | Type | Status | Default | Description |
|---|---|---|---|---|
| query | string | Optional | Query | |
| task | any | Optional | Task | |
| max_tokens | integer | Optional | 20000 | Max Tokens |
| resource_mode | string | Optional | BALANCED | Resource Mode |
compile_task(query="Debug AuthService")
CompiledTaskPlan| Field | Type | Description |
|---|---|---|
| task_spec | string | Task Spec |
| ambiguity | string | Ambiguity |
| ambiguities | string | Ambiguities |
| entry_points | string | Entry Points |
| retrieval_plan | string | Retrieval Plan |
| recommended_next_step | string | Recommended Next Step |
Construct a deterministic `RetrievalPlan` for a question or task (`query`; `task` supported as alias) without executing graph or source retrieval. Use to inspect planned retrieval steps, token budgets, and query expansions. Does not return code snippets or relationship edges.
| Parameter | Type | Status | Default | Description |
|---|---|---|---|---|
| query | string | Optional | Query | |
| task | any | Optional | Task | |
| max_tokens | integer | Optional | 20000 | Max Tokens |
| resource_mode | string | Optional | BALANCED | Resource Mode |
plan_retrieval(query="Trace payment processing")
RetrievalPlanDict| Field | Type | Description |
|---|---|---|
| intent | string | Intent |
| steps | string | Steps |
| token_budget | string | Token Budget |
| expanded_queries | array | Expanded Queries |
| ambiguities | string | Ambiguities |
Return repository indexing status, generation counter, freshness state (`FRESH` or `STALE`), symbol counts, and modified/deleted file lists. Use to check whether the index is fresh before trusting cached graph facts after disk edits. Does not re-index the repository automatically.
| Parameter | Type | Status | Default | Description |
|---|---|---|---|---|
| No arguments required. | ||||
get_repository_status()
RepositoryStatusReport| Field | Type | Description |
|---|---|---|
| repository | string | Repository |
| generation | string | Generation |
| freshness | boolean | Freshness |
| freshness_detail | boolean | Freshness Detail |
| files_indexed | array | Files Indexed |
| symbols_indexed | array | Symbols Indexed |
| graph_edges | array | Graph Edges |
| framework_routes | array | Framework Routes |
| modified_files | array | Modified Files |
| deleted_files | array | Deleted Files |
| parse_failed_files | array | Parse Failed Files |
Return up to 500 indexed repository-relative source file paths in deterministic sorted order. Use for a flat inventory of indexed files when exploring a small project. Does not return package dependency graphs or entrypoints (prefer get_architecture).
| Parameter | Type | Status | Default | Description |
|---|---|---|---|---|
| No arguments required. | ||||
get_project_structure()
IndexedFilePathList| Field | Type | Description |
|---|---|---|
| path | string | Path |
List up to 500 raw parser-extracted `(source_path, imported)` rows from the imports table. Use for bulk inspection of raw import statements across the repository. Does not resolve workspace package boundaries; prefer get_imports or get_architecture.
| Parameter | Type | Status | Default | Description |
|---|---|---|---|---|
| No arguments required. | ||||
get_dependencies()
RawImportRowList| Field | Type | Description |
|---|---|---|
| source_path | string | Source Path |
| imported | string | Imported |
List extracted symbols (`symbol`, `kind`, `start_line`, `end_line`) in a single repository-relative file. Use for a lightweight symbol table of one file when imports and artifact metadata are not needed. Does not return cross-file relationships; prefer get_file for full file outline.
| Parameter | Type | Status | Default | Description |
|---|---|---|---|---|
| path | string | Required | - | Path |
get_file_symbols(path="src/auth/service.py")
FileSymbolRowList| Field | Type | Description |
|---|---|---|
| symbol | string | Symbol |
| kind | string | Kind |
| start_line | integer | Start Line |
| end_line | integer | End Line |
Search local SQLite repository memory notes by keyword up to `limit` (1..100). Use only to recall previously stored local session notes. Never overrides current AST or source-file evidence; does not prove current repository state.
| Parameter | Type | Status | Default | Description |
|---|---|---|---|---|
| query | string | Required | - | Query |
| limit | integer | Optional | 20 | Limit |
search_memory(query="auth", limit=10)
MemoryNoteList| Field | Type | Description |
|---|---|---|
| key | string | Key |
| value | string | Value |
Return bounded source-derived `Evidence` citations (`file`, `start_line`, `end_line`, `symbol`, `snippet`, `content_hash`) for a non-sensitive file or symbol. Use when constructing hash-verifiable code citations. Blocks sensitive files and does not compute cross-file callers.
| Parameter | Type | Status | Default | Description |
|---|---|---|---|---|
| path | string | Required | - | Path |
| symbol | any | Optional | None | Symbol |
get_evidence(path="src/auth/service.py", symbol="AuthService.authenticate")
EvidenceCitationList| Field | Type | Description |
|---|---|---|
| file | string | File |
| start_line | integer | Start Line |
| end_line | integer | End Line |
| symbol | string | Symbol |
| snippet | string | Snippet |
| content_hash | string | Content Hash |
Verify that a cited evidence span (`file_path`, `start_line`, `end_line`) exists on disk, matches `expected_hash`, and is not stale. Use to validate whether previously retrieved evidence is still current after repository edits. Does not re-index modified files.
| Parameter | Type | Status | Default | Description |
|---|---|---|---|---|
| file_path | string | Required | - | File Path |
| start_line | integer | Required | - | Start Line |
| end_line | integer | Required | - | End Line |
| expected_hash | any | Optional | None | Expected Hash |
| symbol | any | Optional | None | Symbol |
verify_evidence(file_path="src/auth/service.py", start_line=1, end_line=20)
EvidenceVerificationResult| Field | Type | Description |
|---|---|---|
| valid | string | Valid |
| file | string | File |
| start_line | integer | Start Line |
| end_line | integer | End Line |
| reason | string | Reason |
| current_hash | string | Current Hash |
Return current resource governor state including memory usage, pressure level, concurrency limits, and activity mode. Use for diagnosing server resource pressure or throttling behavior. Does not inspect repository source code or symbols.
| Parameter | Type | Status | Default | Description |
|---|---|---|---|---|
| No arguments required. | ||||
get_resource_status()
ResourceGovernorState| Field | Type | Description |
|---|---|---|
| mode | string | Mode |
| pressure | string | Pressure |
| rss_mb | string | Rss Mb |
| active_tasks | string | Active Tasks |
Framework Route Discovery Tools (2)
Framework-aware HTTP route mapping for FastAPI, Flask, Django, and Express.
Return HTTP/RPC framework routes, mounted router prefixes (`MOUNTS`), methods, and handler symbols. Use when locating API endpoints, route handlers, or mounted sub-applications (FastAPI, Flask, Django, Express, NestJS). Does not prove runtime middleware authentication unless traced via get_context or trace_path.
| Parameter | Type | Status | Default | Description |
|---|---|---|---|---|
| framework | any | Optional | None | Framework |
| method | any | Optional | None | Method |
| path | any | Optional | None | Path |
list_routes(method="POST", path="/api/v1/auth/login")
RouteListResult| Field | Type | Description |
|---|---|---|
| status | string | Status |
| routes | array | Routes |
| route_path | string | Route Path |
| http_method | string | Http Method |
| handler_name | string | Handler Name |
| canonical_id | string | Canonical Id |
| framework | string | Framework |
| file | string | File |
| line | integer | Line |
| evidence_class | string | Evidence Class |
Find HTTP/RPC framework routes, mounted router prefixes (`MOUNTS`), methods, and handler symbols across FastAPI, Flask, Django, Express, and NestJS. Use instead of grep when locating API endpoints or route handlers. Does not prove runtime middleware authentication unless traced via trace_path or get_context.
| Parameter | Type | Status | Default | Description |
|---|---|---|---|---|
| framework | any | Optional | None | Framework |
| method | any | Optional | None | Method |
| path | any | Optional | None | Path |
find_routes(path="/api/scan-bill")
RouteListResult| Field | Type | Description |
|---|---|---|
| status | string | Status |
| routes | array | Routes |
| route_path | string | Route Path |
| http_method | string | Http Method |
| handler_name | string | Handler Name |
| canonical_id | string | Canonical Id |
| framework | string | Framework |
| file | string | File |
| line | integer | Line |
| evidence_class | string | Evidence Class |
Git History & Change Impact Tools (4)
Recent file commit history, changed files, and git diff impact analysis.
Compute deterministic change impact between Git refs (`base`..`head`), including modified symbols, downstream callers, affected packages, and covering tests. Use for PR review, regression analysis, and pre-commit blast-radius checks. Does not execute tests; reports static test-to-symbol coverage edges.
| Parameter | Type | Status | Default | Description |
|---|---|---|---|---|
| base | string | Optional | HEAD~1 | Base |
| head | string | Optional | HEAD | Head |
get_git_impact(base="HEAD~1", head="HEAD")
GitImpactResult| Field | Type | Description |
|---|---|---|
| status | string | Status |
| base | string | Base |
| head | string | Head |
| changed_files | array | Changed Files |
| modified_symbols | array | Modified Symbols |
| impacted_callers | array | Impacted Callers |
| affected_packages | string | Affected Packages |
| related_tests | array | Related Tests |
Return repository files modified between two Git refs (`since`..`until`) in a read-only sandboxed query. Use when reviewing recent commits or identifying which files changed before running impact analysis. Does not compute downstream symbol callers; use get_git_impact for symbol-level blast radius.
| Parameter | Type | Status | Default | Description |
|---|---|---|---|---|
| since | string | Optional | HEAD~10 | Since |
| until | string | Optional | HEAD | Until |
get_recent_changes(since="HEAD~5", until="HEAD")
GitChangedFilesList| Field | Type | Description |
|---|---|---|
| path | string | Path |
| status | string | Status |
Return recent Git commits touching a specific repository file (`path`, up to `n` commits). Use when investigating when and why a specific file was recently modified. Does not return full commit diffs or cross-file dependency impact.
| Parameter | Type | Status | Default | Description |
|---|---|---|---|---|
| path | string | Required | - | Path |
| n | integer | Optional | 10 | N |
get_file_history(path="src/auth/service.py", n=5)
FileCommitHistoryList| Field | Type | Description |
|---|---|---|
| commit | string | Commit |
| author | string | Author |
| date | string | Date |
| subject | string | Subject |
Analyze changed files, modified symbols, downstream callers, and related tests between Git refs `since` and `until`. Use for commit-range impact analysis when `since`/`until` parameter naming is preferred. Does not execute tests at runtime.
| Parameter | Type | Status | Default | Description |
|---|---|---|---|---|
| since | string | Optional | HEAD~1 | Since |
| until | string | Optional | HEAD | Until |
analyze_change_impact(since="HEAD~2", until="HEAD")
ChangeImpactReport| Field | Type | Description |
|---|---|---|
| changed_files | array | Changed Files |
| modified_symbols | array | Modified Symbols |
| callers | array | Callers |
| related_tests | array | Related Tests |
Test Discovery & Coverage Tools (2)
Deterministic symbol-to-test suite mapping.
Find test files and test functions statically linked to a target symbol (`symbol`; `canonical_id` supported as alias) via direct calls, imports, fixtures, or route invocation. Use instead of grep when answering 'what tests cover symbol X?'. Does not execute tests at runtime and never fabricates coverage from lexical similarity alone.
| Parameter | Type | Status | Default | Description |
|---|---|---|---|---|
| symbol | string | Optional | Symbol | |
| canonical_id | string | Optional | Canonical Id | |
| max_results | integer | Optional | 10 | Max Results |
find_tests(symbol="parse_bill")
RelatedTestsResult| Field | Type | Description |
|---|---|---|
| test_symbol | string | Test Symbol |
| file | string | File |
| start_line | integer | Start Line |
| end_line | integer | End Line |
| relationship | string | Relationship |
| evidence_class | string | Evidence Class |
| confidence | string | Confidence |
| reason | string | Reason |
CLI Commands Reference (13 Commands)
CodeGraph MCP provides 13 deterministic terminal commands for repository indexing, health auditing, MCP server hosting, and context extraction.
Initialize repository indexing and configuration.
codegraph init .
| Flag | Description |
|---|---|
| --repository, -r <path> | Repository path |
| --json | Machine-readable JSON output |
Initialized CodeGraph repository at /path/to/repo (indexed 190 files)
Perform incremental AST & relationship indexing with 16-phase telemetry.
codegraph index . --verbose
| Flag | Description |
|---|---|
| --verbose, -v | Show phase-by-phase timings and memory usage |
| --quiet, -q | Suppress progress blocks |
| --json | Output phase metrics as JSON |
Phase: Repository Scan [190/190 files, 100%] elapsed: 0.09s Phase: Final Commit & Checkpoint scanned=190 indexed=1 unchanged=189 removed=0
Inspect index freshness, file counts, and resource consumption in < 5ms.
codegraph status .
| Flag | Description |
|---|---|
| --repository, -r <path> | Repository path |
{
"status": "FRESH",
"files": 190,
"symbols": 1944,
"graph_edges": 14293,
"resource_profile": "BALANCED"
}
Verify SQLite schema integrity, foreign keys, FTS search, and orphaned processes.
codegraph doctor --database
| Flag | Description |
|---|---|
| --database | Run deep schema & foreign key checks |
| --processes | Audit active MCP processes and parent PIDs |
| --json | Output diagnostic report as JSON |
{
"status": "OK",
"database_version": 8,
"foreign_keys": true,
"issues": []
}
Zero-friction runtime telemetry interceptor.
codegraph run npm run dev # or codegraph run uvicorn main:app --reload
| Flag | Description |
|---|---|
| --sample-rate <float> | Trace sampling rate (0.0 to 1.0, default 1.0) |
>> Dev server active on port 8000 [CodeGraph Runtime Interceptor: Captured 14 HTTP spans -> .codegraph/runtime.sqlite3]
Run the Model Context Protocol (MCP) server over stdio or SSE HTTP.
codegraph serve . --transport sse --port 8765
| Flag | Description |
|---|---|
| --profile <name> | Tool profile (core | minimal | agent | developer | full) |
| --transport, -t <stdio|sse> | Transport layer (default: stdio) |
| --host <str> | Host for SSE server (default: 127.0.0.1) |
| --port, -p <int> | Port for SSE server (default: 8765) |
CodeGraph MCP server running on http://127.0.0.1:8765/sse (56 tools registered)
Safely terminate active CodeGraph background processes and release SQLite file locks.
codegraph stop --json
| Flag | Description |
|---|---|
| --all, -a | Stop all CodeGraph processes across all repositories |
| --timeout <sec> | Graceful shutdown timeout before SIGKILL |
| --json | Output machine-readable JSON |
{
"status": "ok",
"stopped_count": 1,
"stale_cleaned_count": 0
}
Idempotently detect and configure AI coding agents.
codegraph install --yes --target auto --location local
| Flag | Description |
|---|---|
| --target, -t <auto|all|agent> | Target specific agents |
| --location, -l <local|global> | Project (.cursor/mcp.json) vs user global (~/.claude.json) |
| --yes, -y | Non-interactive confirmation |
| --dry-run | Preview changes without writing |
Configured Claude Code (CLAUDE.md, .mcp.json) Configured Cursor (.cursor/mcp.json, .cursorrules) Configured Antigravity (.agents/mcp_config.json, AGENTS.md)
Search symbols and text chunks with AST-verified evidence.
codegraph search "create_order" -r .
| Flag | Description |
|---|---|
| --repository, -r <path> | Repository path |
| --top_k <int> | Number of results to return (default: 10) |
| --json | Machine-readable JSON output |
Found 1 symbol match: src/app/orders.py:42 function create_order(user_id: int, items: list) -> Order
Discover HTTP endpoints with composed router mount prefixes.
codegraph routes -r . --limit 3
| Flag | Description |
|---|---|
| --limit <int> | Bounded pagination limit (default: 50) |
| --offset <int> | Pagination offset (default: 0) |
| --json | Output routes as JSON |
Found 3 route(s):
[GET] /api/v1/health -> health_check (src/api.py:14)
[POST] /api/v1/orders -> create_order (src/orders.py:42)
[GET] /api/v1/users/{id} -> get_user (src/users.py:88)
Trace a symbol definition, callers, and callees with explicit confidence labels.
codegraph trace OrderService.create_order -d 2
| Flag | Description |
|---|---|
| -d, --depth <int> | Traversal depth (default: 1) |
| --json | Output call hierarchy as JSON |
Symbol: OrderService.create_order (src/services/order.py:28)
▲ Callers (1):
- [AST_VERIFIED] api.create_order_endpoint (src/api.py:52)
▼ Callees (2):
- [AST_VERIFIED] UserRepository.get_by_id (src/db/users.py:15)
- [AST_VERIFIED] OrderRepository.insert (src/db/orders.py:40)
Compile token-budgeted ContextPacket for an AI agent task.
codegraph context "fix order validation error" --intent DEBUG
| Flag | Description |
|---|---|
| --intent <str> | Task intent (UNDERSTAND | DEBUG | TRACE | REVIEW | IMPACT) |
| --max-tokens <int> | Token limit (default: 8000) |
| --json | Output serialized ContextPacket |
ContextPacket compiled (540 tokens, reduction: 78.4%): - 4 confirmed symbols, 2 database tables, 1 covering test
Verify repository privacy boundaries and ensure no sensitive data is indexed.
codegraph privacy .
| Flag | Description |
|---|---|
| --json | Output privacy audit as JSON |
Privacy Audit PASSED: 0 sensitive files indexed, 0 exposed secrets found.
Scaling Benchmarks
Empirically measured scaling metrics across codebases from 10,000 to over 1,000,000 lines of code.
| Scale | Cold Index Time | Warm Re-index | Query Latency | Database Size | Memory Footprint |
|---|---|---|---|---|---|
| Small (10k LOC) | 0.42 s | 0.08 s | 12 ms | 2.4 MB | < 35 MB |
| Medium (100k LOC) | 2.85 s | 0.31 s | 24 ms | 18.2 MB | < 85 MB |
| Large (500k LOC) | 11.40 s | 1.15 s | 42 ms | 76.5 MB | < 180 MB |
| Monorepo (1M+ LOC) | 23.10 s | 2.40 s | 58 ms | 152.0 MB | < 320 MB |