MCP Tools Reference
All Batho MCP tools return dual output:
contentβ Compact markdown for the AI model (token-optimized)structuredContentβ Full JSON for programmatic consumers
All graph tools accept repo as an optional parameter. If omitted, the first registered repo is used. Use list_repos to see available repos.
Tool Surface (20 tools)β
| Tier | Tools | Default |
|---|---|---|
| Registry | list_repos, add_repo, remove_repo | enabled |
| Retrieval | graph_overview, graph_query, get_entity, trace_path, get_file_graph, file_connectivity, search_entities, get_delta | enabled |
| Diagnostics | batho_status, batho_list_runs, batho_history | enabled |
| Admin (Tier-3) | batho_patch, batho_fix | enabled |
| Admin (Tier-3) | batho_build, batho_export, batho_load, batho_gc | disabled (CLI-first) |
Annotations (MCP tool hints)β
Every tool declares ToolAnnotations so hosts can auto-approve read-only
calls and gate destructive ones:
| Tool | readOnlyHint | destructiveHint | idempotentHint | openWorldHint |
|---|---|---|---|---|
list_repos | true | false | true | false |
add_repo | false | true | β | false |
remove_repo | false | true | β | false |
graph_overview | true | false | true | false |
graph_query | true | false | true | false |
get_entity | true | false | true | false |
trace_path | true | false | true | false |
get_file_graph | true | false | true | false |
file_connectivity | true | false | true | false |
search_entities | true | false | true | false |
get_delta | true | false | true | false |
batho_status | true | false | true | false |
batho_list_runs | true | false | true | false |
batho_history | true | false | true | false |
batho_build | false | true | β | true |
batho_patch | false | true | true | true |
batho_export | false | true | β | true |
batho_gc | false | true | β | false |
batho_fix | false | true | β | false |
batho_load | false | true | β | false |
outputSchema (structured outputs)β
The 8 dual-output tools declare an outputSchema (MCP 2025-06-18) matching
their structuredContent shape, so hosts can validate and render typed UIs:
| Tool | Top-level keys |
|---|---|
graph_overview | overview, meta |
graph_query, get_entity, get_file_graph | graph (nodes, edges), meta |
trace_path | path, depth, meta |
file_connectivity | file, depends_on, depended_on_by, external, stats, meta |
search_entities | results, meta |
get_delta | changes, delta_stats, run_info |
Tool descriptions follow a USE when / DO NOT USE when template (biggest
measured lever on tool-selection accuracy), and the server ships a top-level
instructions string with Batho-first routing guidance. Tool groups can be
gated via mcp.toolsets in batho.yaml (retrieval, diagnostics,
registry, admin) β defaults are unchanged when the section is absent.
list_reposβ
List all registered repos with artifact status and entity counts.
Parametersβ
None.
Exampleβ
list_repos()
Outputβ
Markdown:
## Registered Repos
- **frontend** β /projects/frontend (β ready, 892 entities)
- **backend** β /projects/backend (β ready, 650 entities)
JSON:
{
"repos": [
{"name": "frontend", "path": "/projects/frontend", "has_artifact": true, "entity_count": 892},
{"name": "backend", "path": "/projects/backend", "has_artifact": true, "entity_count": 650}
],
"total": 2
}
add_repoβ
Register a repository in the Batho MCP registry. The repo must have a .batho artifact (run batho build first).
Parametersβ
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
name | string | Yes | β | Repo name (unique identifier in registry) |
path | string | Yes | β | Absolute path to the repository root |
watch | boolean | No | false | Enable file watching for automatic re-indexing |
debounce_ms | integer | No | 2000 | Debounce interval in milliseconds for file watch events |
max_file_size_kb | integer | No | null | Maximum file size in KB to index (null for default) |
Exampleβ
add_repo(name="myapp", path="/projects/myapp")
Outputβ
Markdown:
## Repo Registered
- **myapp** β /projects/myapp
- Entities: 892
- Artifact: β ready
JSON:
{"name": "myapp", "path": "/projects/myapp", "entity_count": 892, "has_artifact": true}
remove_repoβ
Remove a repository from the Batho MCP registry.
Parametersβ
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
name | string | Yes | β | Repo name to remove |
Exampleβ
remove_repo(name="myapp")
Outputβ
Markdown:
## Repo Removed
- **myapp** β removed from registry
JSON:
{"name": "myapp", "removed": true}
graph_overviewβ
Get a high-level overview of the codebase: entity counts, relationship breakdown, file list, community summaries, and ambiguous edge count.
Parametersβ
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
repo | string | No | Registry default | Repo name from registry |
response_format | string | No | "summary" | Output detail level: summary, concise, detailed |
max_tokens | int | No | 25000 | Token budget for markdown output |
Exampleβ
graph_overview(repo="myapp", response_format="summary")
Outputβ
Markdown (content):
# Codebase Overview
**Stats:** 1542 entities, 4823 relationships, 312 files
**Run:** abc-123 | commit: a1b2c3d | branch: main
## Entity Breakdown
- function: 892
- class: 124
- method: 387
## Communities
1. **UserService** β 45 entities across 8 files
2. **ApiClient** β 32 entities across 5 files
JSON (structuredContent):
{
"overview": {
"stats": {
"total_entities": 1542,
"total_relationships": 4823,
"total_files": 312,
"entity_breakdown": {"function": 892, "class": 124},
"unresolved_refs": 87,
"relationship_breakdown": {"calls": 2100, "imports": 1800},
"ambiguous_edge_count": 0,
"run_id": "abc-123",
"git_commit": "a1b2c3d"
},
"communities": [
{
"id": 0,
"name": "UserService",
"entity_count": 45,
"file_count": 8,
"top_entities": ["AuthManager", "UserRepo"],
"description": "src/auth Β· key: AuthManager, UserRepo",
"file_paths": ["src/auth/manager.py", "..."]
},
{"id": -1, "name": "β¦ 6 smaller communities", "entity_count": 58, "file_count": 0, "top_entities": [], "description": "", "file_paths": [], "is_aggregate": true}
]
},
"meta": {
"artifact_generation": 3,
"tokens_used": 1840,
"token_budget": 25000,
"truncated": false
}
}
stats.unresolved_refs counts quarantined unresolved: reference stubs (cross-file references that did not resolve to a concrete entity); entity-type counts and total_entities cover resolved entities only. overview.communities lists the top-N communities by entity count (N = community_detection.overview_top_n, default 12), each labeled by a heuristic name with a one-line description; singleton communities are hidden, and any communities beyond the top-N collapse into a single trailing aggregate entry (id: -1, is_aggregate: true).
graph_queryβ
Query the code graph with optional filters. Returns paginated nodes and edges.
Parametersβ
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
repo | string | No | Registry default | Repo name from registry |
file_path | string | No | β | Filter entities by file path |
entity_types | list[string] | No | β | Filter by entity type (e.g., ["function", "class"]) |
relation_types | list[string] | No | β | Filter relationships by type |
symbol_roles | list[string] | No | β | Filter relationships by symbol role (OR semantics). Valid: Definition, Import, WriteAccess, ReadAccess, Generated, Declaration, Dynamic, Heuristic (case-insensitive) |
confidence_threshold | float | No | β | Only return relationships with confidence >= threshold (0.0β1.0). See Confidence Tiers |
relation_direction | string | No | "both" | Filter by edge direction: outgoing (entity is source), incoming (entity is target), both |
name_pattern | string | No | β | Regex pattern to match entity names |
entity_categories | list[string] | No | β | Filter by entity category (expands to member types). Valid: code, external, infrastructure, markup, structural (case-insensitive). Combines with entity_types using OR semantics |
response_format | string | No | "concise" | Output format: concise, detailed |
limit | int | No | 50 | Max entities to return |
offset | int | No | 0 | Pagination offset |
max_tokens | int | No | 25000 | Token budget |
include_unresolved | bool | No | false | Include unresolved: reference stubs in node results. Default false: stubs are quarantined so node lists show resolved entities only (edges referencing them are unaffected) |
include_quarantined | bool | No | false | Include entities quarantined by rules (bsg.noise/bsg.quarantined metadata). Default false: quarantined entities are hidden; the suppressed count is reported in meta.quarantined_suppressed and a markdown footer line |
Exampleβ
graph_query(repo="myapp", file_path="src/auth/", entity_types=["function"], limit=20)
graph_query(repo="myapp", symbol_roles=["WriteAccess"], confidence_threshold=0.85)
graph_query(repo="myapp", relation_types=["CALLS"], relation_direction="incoming")
Outputβ
Returns nodes (entities) and edges (relationships) matching the filters, with pagination metadata in structuredContent.
get_entityβ
Get detailed information about a single entity, including its relationships and optionally source code.
Parametersβ
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
entity_id | string | Yes | β | Entity ID from previous query results |
repo | string | No | Registry default | Repo name from registry |
include_source | bool | No | false | Include source code snippet |
response_format | string | No | "detailed" | Output format |
Exampleβ
get_entity(entity_id="src/auth.py:AuthManager.validate_token", repo="myapp", include_source=true)
Outputβ
Returns the entity's metadata (name, type, file, line range), all relationships where it appears as source or target, and optionally the source code from storage_views.
trace_pathβ
Find the shortest path between two entities in the code graph using BFS traversal.
Traversal is default-deny: only whitelisted structural edge kinds are expanded β CALLS > INHERITS/IMPLEMENTS > IMPORTS > READS/WRITES > CONTAINS > other structural relations (USES, DEFINES, OVERRIDES, STACK_BOUNDARY, WRAPPED_BY, DEPENDS_ON_API, CLEANED_BY, HAS_ATTRIBUTE, LINKS_TO, IMPORTS_STYLE, REFERENCES). Non-structural kinds (RATIONALE_FOR, or any future annotation/inferred relation) are never traversed, even when they would produce a shorter path. An explicit relation_types filter can only narrow this whitelist, never widen it β requesting only non-structural kinds returns a CLIENT_ERROR. Among equal-length paths, the one whose earliest hops use higher-priority edge kinds wins; remaining ties resolve deterministically by entity_id ordering.
Parametersβ
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
source_entity_id | string | Yes | β | Starting entity ID |
target_entity_id | string | Yes | β | Target entity ID |
repo | string | No | Registry default | Repo name from registry |
max_depth | int | No | 5 | Maximum BFS depth (hops; clamped to 1β20) |
relation_types | list[string] | No | β | Only traverse these relationship types. Can only narrow the structural whitelist β non-structural kinds are dropped (reported in meta.edge_priority.non_traversable_requested); if none remain, returns CLIENT_ERROR |
symbol_roles | list[string] | No | β | Only traverse edges matching the specified roles (OR semantics). Valid: Definition, Import, WriteAccess, ReadAccess, Generated, Declaration, Dynamic, Heuristic |
confidence_threshold | float | No | β | Only traverse edges with confidence >= threshold (0.0β1.0). See Confidence Tiers |
relation_direction | string | No | "outgoing" | Direction of edges to traverse: outgoing (sourceβtarget), incoming (targetβsource, reverse BFS), both |
response_format | string | No | "concise" | Output format |
Exampleβ
trace_path(
source_entity_id="api.routes.login.handle_login",
target_entity_id="auth.SessionHandler.create",
repo="myapp",
max_depth=10
)
# Trace only high-confidence import edges (reverse direction)
trace_path(
source_entity_id="auth.SessionHandler.create",
target_entity_id="api.routes.login.handle_login",
repo="myapp",
symbol_roles=["Import"],
confidence_threshold=0.85,
relation_direction="incoming"
)
Outputβ
Markdown:
## Path Trace
handle_login
β [CALLS] AuthManager.validate_token
β [CALLS] SessionHandler.create
Depth: 3 hops
JSON:
{
"path": [
{"entity_id": "api.routes.login.handle_login", "relation_type": "", "name": "handle_login"},
{"entity_id": "auth.AuthManager.validate_token", "relation_type": "CALLS", "name": "validate_token", "direction": "forward"},
{"entity_id": "auth.SessionHandler.create", "relation_type": "CALLS", "name": "create", "direction": "forward"}
],
"depth": 2,
"meta": {
"artifact_generation": 3,
"edge_priority": {
"preference": ["CALLS", "IMPLEMENTS", "INHERITS", "IMPORTS", "READS", "WRITES", "CONTAINS", "..."],
"path_edge_kinds": ["CALLS", "CALLS"],
"excluded_edge_kinds": {"RATIONALE_FOR": 4},
"non_traversable_requested": ["RATIONALE_FOR"]
},
"applied_filters": {"relation_types": ["CALLS"]}
}
}
Each path entry after the first carries an optional direction field: "forward" (sourceβtarget edge) or "reverse" (targetβsource edge, only when relation_direction is incoming or both); rendered as β/β in the markdown.
meta.edge_priority reports the traversal policy applied:
preferenceβ all traversable edge kinds in tie-break preference order.path_edge_kindsβ the edge kinds used at each hop of the returned path.excluded_edge_kindsβ non-structural kinds present in the filtered edge set that were excluded from traversal, with counts (only present when non-empty).non_traversable_requestedβ requestedrelation_typesdropped because they are not traversable structural edges (only present when non-empty).
get_file_graphβ
Get all entities and relationships within a single file. Optionally includes cross-file reference stubs.
Parametersβ
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
file_path | string | Yes | β | File path relative to repo root |
repo | string | No | Registry default | Repo name from registry |
include_cross_file_refs | bool | No | true | Include entities referenced from other files |
response_format | string | No | "concise" | Output format |
max_tokens | int | No | 25000 | Token budget |
Exampleβ
get_file_graph(file_path="src/auth/manager.py", repo="myapp", include_cross_file_refs=true)
Outputβ
Returns all entities defined in the file, all relationships within the file, and stub entities for cross-file references (when include_cross_file_refs is true).
file_connectivityβ
File-level dependency connectivity in both directions. Cross-file references (stored as unresolved stubs) are resolved to their defining files, then aggregated per file with relation-type counts and confidence. Ideal for dependency-graph UIs and impact analysis ("who breaks if I change this file?").
Parametersβ
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
file_path | string | Yes | β | File path relative to repo root (forward slashes) |
repo | string | No | Registry default | Repo name from registry |
direction | string | No | "both" | outgoing (files this file depends on), incoming (files that depend on it), both |
include_external | bool | No | false | Include stdlib/external references in the output |
min_confidence | float | No | β | Only include edges with confidence >= threshold (0.0β1.0) |
response_format | string | No | "concise" | Output format |
max_tokens | int | No | 25000 | Token budget |
Exampleβ
file_connectivity(file_path="src/auth/manager.py", repo="myapp", direction="both")
file_connectivity(file_path="src/auth/manager.py", repo="myapp", direction="incoming", include_external=true)
Outputβ
Markdown:
## File Connectivity: src/auth/manager.py
### Depends on (3 files)
- `src/api/routes.py` β callsΓ4, importsΓ2 (via handle_login, ApiClient)
- `src/models/user.py` β readsΓ2 (via User)
### Depended on by (2 files)
- `src/main.py` β callsΓ1 (via main)
2 outgoing Β· 1 incoming Β· 0 unresolved Β· generation 3
structuredContent includes file_dependencies (outgoing / incoming lists with per-relation-type counts, max confidence, and a via symbol list) plus optional external stdlib/unresolved counts.
The via list is direction-aware: depends_on cells name the referenced (remote) symbol; depended_on_by cells name the referencing (caller-side) symbol β "src/main.py β callsΓ1 (via main)" means main.py's main calls into this file. Endpoints with no resolvable name contribute no via entry (e.g. alias-named stubs, which are excluded from the name index). external.stdlib lists the stdlib root modules referenced (e.g. os, std); refs that resolve to no known module or stdlib root are counted in unresolved_stubs.
search_entitiesβ
Search for entities by name using substring or regex matching.
Parametersβ
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
query | string | Yes | β | Search query (substring or regex) |
repo | string | No | Registry default | Repo name from registry |
entity_types | list[string] | No | β | Filter by entity type |
entity_categories | list[string] | No | β | Filter by entity category (expands to member types). Valid: code, external, infrastructure, markup, structural (case-insensitive). Combines with entity_types using OR semantics |
symbol_roles | list[string] | No | β | Filter to entities that participate in relationships with the specified roles. Valid: Definition, Import, WriteAccess, ReadAccess, Generated, Declaration, Dynamic, Heuristic |
limit | int | No | 25 | Max results to return |
response_format | string | No | "concise" | Output format |
include_unresolved | bool | No | false | Also return unresolved: reference stubs (failed cross-file resolutions). Default false: stubs are quarantined so real definitions rank first; the suppressed count is reported in meta.unresolved_suppressed |
include_quarantined | bool | No | false | Also return entities quarantined by rules (bsg.noise/bsg.quarantined metadata). Default false: quarantined entities are hidden; the suppressed count is reported in meta.quarantined_suppressed and a markdown footer line |
Exampleβ
search_entities(query="validate", repo="myapp", entity_types=["function"], limit=10)
search_entities(query="config", repo="myapp", symbol_roles=["WriteAccess"])
Outputβ
Results are ranked by a deterministic scorer: exact > prefix > substring (regex-only name matches score at substring strength), with kind boosts (CLASS/METHOD/FUNCTION/INTERFACE > MODULE > others; COMMENT_BLOCK and EXTERNAL_SYMBOL penalized), exported-entity and fqn/file-path match bonuses, and ties broken by start_line, file, entity_id β identical queries always return identical order. Ranking reorders only; recall is unchanged.
Markdown:
## Search Results (8 matches, showing 8)
- validate_token [FUNCTION] src/auth/manager.py:L45-62 β `src/auth/manager.py:AuthManager.validate_token`
- validate_session [FUNCTION] src/auth/session.py:L12-28 β `src/auth/session.py:validate_session`
- validate_input [FUNCTION] src/api/middleware.py:L8-20 β `src/api/middleware.py:validate_input`
- β¦ 2 unresolved reference(s) suppressed (include_unresolved=true to show)
JSON (structuredContent):
{
"results": [
{
"id": "src/auth/manager.py:AuthManager.validate_token",
"name": "validate_token",
"type": "FUNCTION",
"file": "src/auth/manager.py",
"start_line": 45,
"end_line": 62,
"score": 155
}
],
"meta": {
"total_matches": 8,
"returned": 8,
"artifact_generation": 3,
"unresolved_suppressed": 2,
"applied_filters": {"entity_types": ["FUNCTION"]}
}
}
Each result carries a score β the deterministic ranking score described above. meta.unresolved_suppressed (only present when non-zero) counts unresolved: stubs hidden by the default quarantine; meta.applied_filters echoes active filters (including include_unresolved when set).
get_deltaβ
Get incremental changes from the latest patch run (or a specific run). Shows added, removed, modified, and renamed nodes.
Parametersβ
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
repo | string | No | Registry default | Repo name from registry |
run_id | string | No | Latest patch | Specific run UUID |
change_kind | string | No | All | Filter: added, removed, modified, renamed |
file_path | string | No | All | Filter changes by file path |
limit | int | No | 100 | Max changes to return |
offset | int | No | 0 | Pagination offset |
response_format | string | No | "concise" | Output format |
Exampleβ
get_delta(repo="myapp", change_kind="added", limit=20)
Outputβ
Returns node-level changes (entity name, change kind, file path, line range), delta stats (nodes added/removed/modified/renamed), and run metadata (git commit, branch, duration).
batho_statusβ
Show artifact and watcher status for one or all repos. Read-only.
Parametersβ
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
repo | string | No | All repos | Repo name to check (omit for all registered repos) |
Exampleβ
batho_status(repo="myapp")
Outputβ
Returns per-repo artifact status (ready/stale/missing), entity/relationship counts, last build run ID, and watcher state (active/inactive, pending changes).
batho_list_runsβ
List patch/build run IDs for a repo. Read-only.
Parametersβ
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
repo | string | No | Registry default | Repo name from registry |
limit | int | No | 20 | Max runs to return |
Exampleβ
batho_list_runs(repo="myapp", limit=10)
Outputβ
Returns a list of runs with UUID, timestamp, status, git commit, branch, entity/relationship counts, and duration.
batho_historyβ
Query node-level change history across runs, entities, or files. Read-only. (Formerly batho_diff.)
Parametersβ
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
repo | string | No | Registry default | Repo name from registry |
run_id | string | No | β | Specific run UUID to inspect (exactly one of run_id/entity_id/file_path required) |
entity_id | string | No | β | Full evolution history for a specific entity |
file_path | string | No | β | Node changes for a file across runs |
since | string | No | β | Run UUID lower bound (only with entity_id) |
Exampleβ
batho_history(repo="myapp", file_path="src/auth/manager.py")
Outputβ
Returns added, removed, modified, and renamed nodes with file paths, entity IDs, and changed-field names for each change.
batho_patchβ
Run an incremental patch on an existing artifact. Destructive β modifies the artifact database.
Parametersβ
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
repo | string | No | Registry default | Repo name from registry |
max_file_size_kb | int | No | Config default | Skip files exceeding this size |
graph_backend | string | No | Config default | auto, in-memory, or arrow |
Exampleβ
batho_patch(repo="myapp")
Outputβ
Returns patch stats: files changed, entities added/removed/modified, relationships added/removed, duration, and new run UUID.
batho_fixβ
Run integrity verification and repair on an artifact database. Destructive β may modify or delete corrupt artifacts.
Parametersβ
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
repo | string | No | Registry default | Repo name from registry |
deep | bool | No | false | Deep verification (slower, more thorough) |
dry_run | bool | No | false | Report issues without repairing |
target | string | No | "all" | Repair target: all, blobs, graph, state |
phase | int | No | β | Run only a specific repair phase (1-N) |
parallel | bool | No | false | Run repair phases in parallel |
Exampleβ
batho_fix(repo="myapp", dry_run=true)
Outputβ
Returns verification results, issues found, repairs applied (or proposed if dry_run), and a tamper-evident audit log entry.
batho_buildβ
Run a full index build for a repository. Destructive β deletes and rebuilds the artifact database. Disabled by default β enable via Tool Gating.
Parametersβ
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
repo | string | No | Registry default | Repo name from registry |
full | bool | No | false | Force full rebuild (deletes existing artifact) |
max_workers | int | No | CPU count | Max parallel workers for parsing |
max_file_size_kb | int | No | Config default | Skip files exceeding this size |
graph_backend | string | No | Config default | auto, in-memory, or arrow |
Exampleβ
batho_build(repo="myapp", full=true)
Outputβ
Returns build stats: entity count, relationship count, file count, duration, community count, and new run UUID.
batho_exportβ
Export a JSON view or Pack artifact from the code graph. Destructive β writes files to disk. Disabled by default β enable via Tool Gating.
Parametersβ
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
repo | string | No | Registry default | Repo name from registry |
view | string | No | "storage" | Export view: storage or agent |
output | string | No | Auto-generated | Output file path |
index_id | string | No | Latest | Specific index/run ID to export |
filter_pattern | string | No | β | Glob pattern to filter files |
category | string | No | "all" | Export category: all, entities, relationships, files |
token_budget | int | No | β | Token budget for LLM-optimized export |
json_mode | bool | No | true | Export as JSON (false = Pack binary) |
include_relationships | bool | No | false | Include relationship data in export |
Exampleβ
batho_export(repo="myapp", view="agent", json_mode=true)
Outputβ
Returns the export file path and summary stats (entities exported, file size).
batho_loadβ
Unpack a transport artifact ZIP into .batho/artifact/. Destructive β overwrites the artifact directory. Disabled by default β enable via Tool Gating.
Parametersβ
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
artifact_path | string | Yes | β | Path to the transport artifact ZIP file |
repo | string | No | Registry default | Repo name from registry |
force | bool | No | false | Overwrite existing artifact without confirmation |
Exampleβ
batho_load(artifact_path="/tmp/myapp_artifact.zip", repo="myapp")
Outputβ
Returns the unpacked artifact path and verification status.
batho_gcβ
Run garbage collection and maintenance on an artifact database. Destructive β may delete old run artifacts. Disabled by default β enable via Tool Gating.
Parametersβ
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
repo | string | No | Registry default | Repo name from registry |
subcommand | string | No | "status" | GC action: status, prune, compact, reclaim |
run_uuid | string | No | β | Target a specific run UUID for pruning |
older_than | int | No | β | Prune runs older than N days |
Exampleβ
batho_gc(repo="myapp", subcommand="prune", older_than=30)
Outputβ
Returns GC stats: runs pruned, disk space reclaimed, remaining run count, and fragmentation metrics.
Relationship Filteringβ
graph_query, trace_path, and search_entities support three relationship-level filters that compose with AND semantics. All filters default to None (no filtering) for backward compatibility.
symbol_rolesβ
Filters relationships by the SymbolRole bitmask stored on each edge. A relationship is included if any of the specified roles match (OR semantics within the parameter).
| Role | Bit | Description |
|---|---|---|
Definition | 1 | Relationship defines the target entity |
Import | 2 | Import statement |
WriteAccess | 4 | Write access to the target |
ReadAccess | 8 | Read access to the target |
Generated | 16 | Auto-generated code |
Declaration | 32 | Forward declaration |
Dynamic | 64 | Dynamic dispatch / runtime resolution |
Heuristic | 128 | Inferred by heuristic, not directly extracted |
Role names are case-insensitive ("writeaccess", "WriteAccess", "WRITEACCESS" are all valid). Invalid role names return an error listing the valid options.
Requires an artifact built with the
rolescolumn (Batho v1.4.2+). Older artifacts return a clear error directing you to runbatho build --full.
confidence_thresholdβ
Filters relationships by their resolution confidence score. Only edges with confidence >= threshold are returned or traversed.
Confidence Tiersβ
| Strategy | Confidence | Description |
|---|---|---|
| Direct extraction | 1.0 | Captured directly by tree-sitter (no resolution needed) |
exact_match | 0.95 | Direct dotpath lookup |
stdlib_method | 0.90 | Stdlib method / module prefix match |
import_map | 0.85 | Import-map cross-file resolution |
parent_chain | 0.75 | Parent stub chain building |
scope_qualified | 0.70 | Caller-scope qualified path |
receiver_type | 0.65 | Receiver-type inference |
ambiguous | 0.50 | Multiple equally-plausible candidates (kept for manual review) |
unresolved | 0.0 | No match found |
The threshold must be between 0.0 and 1.0 inclusive. Use 0.85 for high-confidence edges only, or 0.0 to include everything.
Note: Confidence values are stored as
float32in Arrow IPC. Values like0.85may be stored as0.84999996due to binary representation. Use a slightly lower threshold (e.g.,0.84) if you need to include edges at exact tier boundaries.
relation_directionβ
Filters relationships by edge direction relative to the entity:
| Value | Behavior |
|---|---|
"outgoing" | Entity is the source (source_id matches) |
"incoming" | Entity is the target (target_id matches) β enables "who calls X?" queries without inverse relationship types |
"both" (default for graph_query) | No direction filtering |
"outgoing" (default for trace_path) | BFS follows sourceβtarget edges |
"incoming" (trace_path) | Reverse BFS: follows targetβsource edges |
"both" (trace_path) | BFS follows edges in either direction |
Replaces inverse relationship types:
relation_direction="incoming"withrelation_types=["CALLS"]returns all callers of an entity β equivalent to the legacyCALLED_BYtype, but without requiring separate edge storage.
applied_filters in Outputβ
All active filters are echoed in structuredContent.applied_filters:
{
"applied_filters": {
"symbol_roles": ["WriteAccess"],
"confidence_threshold": 0.85,
"relation_direction": "incoming",
"entity_types": ["FUNCTION"],
"relation_types": ["CALLS"]
}
}
Response Formatsβ
| Format | Token Efficiency | Use Case |
|---|---|---|
summary | Most compact | Codebase orientation, architecture overview |
concise | Balanced | General queries, search results, file graphs |
detailed | Most verbose | Deep dives with source code, full metadata |
Token Budgetingβ
All tools accept max_tokens (default: 25,000). When output exceeds the budget:
- Markdown is truncated with a
[truncated]marker structuredContent.meta.truncatedis set totrue- Pagination hints are included for follow-up queries
Token estimation uses a len(text) / 4 heuristic (approximately 4 characters per token).
Error Handlingβ
Errors return a ToolResult with:
content:Error: <message>in plain text (plus an optionalHint: <hint>on a new line).structuredContent: A JSON object containing:{"error": true,"error_type": "CLIENT_ERROR","message": "Error details","retryable": false,"hint": "Actionable hint"}
Common errors:
No Batho artifact found at <path>. Run 'batho build' first.No repos registered. Use add_repo to register a repo.Repo '<name>' not found in registry. Available repos: [...]File not indexed: <path>Entity not found: <entity_id>No patch runs found. Run 'batho patch' first.