Skip to main content
Glama

query_codebase_graph

Query an existing AST knowledge graph to inspect symbol definitions, trace dependencies, identify god classes, or examine clusters without loading large source files.

Instructions

Traverses and queries an existing AST knowledge graph to inspect symbol definitions, identify architectural god classes, trace dependencies, or examine functional clusters. Safe, read-only query: performs local file reads inside graphify-out/ without mutations, network calls, or authentication. Prerequisite: requires an active graph generated via build_codebase_graph; if no graph exists, returns an actionable notice directing the caller to build it.

When to use: Call during codebase onboarding, architectural review, or refactoring to retrieve targeted structural relationships without loading massive source files. When NOT to use: Do not use to check general graph health or existence (use inspect_codebase_graph), and do not use to construct the graph (use build_codebase_graph). Returns: Structured architectural intelligence matching the query mode: summary statistics, ranked god classes by centrality, top connected dependencies, or matched symbol occurrences.

Tool call template

This tool declares no required parameters. Add optional parameters from the input schema as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {},
    "name": "query_codebase_graph"
  }
}

Input Schema

NameRequiredDescriptionDefault
queryNoTarget symbol name (class, function, file) or operational keyword: 'summary' (overall metrics), 'god_nodes' (classes with highest centrality/complexity), 'dependencies' (top connected modules), or 'communities' (cluster breakdown). Case-insensitive. Defaults to 'summary'.summary
repo_pathNoAbsolute or relative path to the target repository root containing graphify-out/. If omitted, empty string, or '.', queries the current working directory.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changedv2.1.2
    • changedInput schema / properties / query / description
      Previous value: -"Query target or operation mode: enter a class/function/symbol name to look up, or one of the special commands: 'summary' (overall architecture & metrics), 'god_nodes' (classes with highest complexity/dependencies), 'dependencies' (top connected modules), or 'communities' (detected functional clusters)."New value: +"Target symbol name (class, function, file) or operational keyword: 'summary' (overall metrics), 'god_nodes' (classes with highest centrality/complexity), 'dependencies' (top connected modules), or 'communities' (cluster breakdown). Case-insensitive. Defaults to 'summary'."
    • changedInput schema / properties / repo_path / description
      Previous value: -"Absolute or relative path to the repository containing graphify-out/. If omitted or empty, queries the current working directory."New value: +"Absolute or relative path to the target repository root containing graphify-out/. If omitted, empty string, or '.', queries the current working directory."
  2. Addedv0.1.2

TDQS

A4.4/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations supplied, the description carries the full burden and does so well: it declares read-only semantics, that reads are confined to graphify-out/, and that there are no mutations, network calls, or authentication. It also discloses the failure mode when no graph exists (an actionable notice pointing to build_codebase_graph). It stops short of stating anything about result-size limits, truncation, or cost on very large graphs, which is the remaining behavioral gap.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Content is front-loaded: purpose, safety profile, prerequisite, then labeled 'When to use' / 'When NOT to use' / 'Returns' blocks. Each sentence carries information, though the opening sentence stacks four distinct use cases and the safety sentence partially restates the 'read-only' idea already implied by 'inspect'.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

There is no output schema, but the 'Returns' line describes the shape of results per mode (summary statistics, ranked god classes, top dependencies, matched symbols). Combined with the prerequisite and error-path disclosure, an agent has everything needed to call this correctly without further context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents the 'query' modes and the repo_path default behavior in detail. The description only echoes that output varies by 'query mode' and never adds format, casing, or fallback semantics beyond what the schema states. Baseline 3 applies since the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description names a specific verb and resource ('Traverses and queries an existing AST knowledge graph') and enumerates the concrete outputs: symbol definitions, god classes, dependencies, functional clusters. It explicitly distinguishes itself from both siblings by naming inspect_codebase_graph (health/existence) and build_codebase_graph (construction).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

It provides a dedicated 'When to use' (onboarding, architectural review, refactoring) and 'When NOT to use' section that routes the agent to the correct sibling tool for each excluded case. The prerequisite (an active graph built via build_codebase_graph) is stated up front rather than left implicit.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.