Skip to main content
Glama
Infinite Code Next

Infinite Code Next

by Kawai-Senpai

graph

Analyze code structure to assess what breaks when a symbol changes, trace call paths, detect cycles, find entry points, hotspots, coupling, and dead code before editing.

Instructions

Structural questions about the code graph: blast radius, paths, cycles.

WHEN TO USE: after investigate() has told you what a symbol is for, and you need to know what changing it costs. investigate() answers "what is this and why"; graph() answers "what else moves if I touch it". AFTER THIS: investigate(action='why', symbol=...) on anything surprising in the blast radius, then record() what you decided.

Actions: impact blast radius of one symbol. direction='upstream' is who depends on it (who breaks if the contract changes); 'downstream' is what it depends on. trace shortest directed call path from target to to. Use it to prove two symbols are actually connected rather than assuming it. cycles directed cycles in the file import graph. Act on component_count, not on the number of cycles: one removed import can dissolve a whole component, so the cycle count swings wildly and the component count is what a fix actually reduces. A deferred import (inside a function, or a TypeScript import type) is excluded: it cannot force an initialisation order, and it is the usual fix for a cycle rather than a cause of one. entrypoints where control enters the program - routes, MCP tool handlers, CLI commands, tests. Pass a kind in target to filter. Start here on an unfamiliar codebase. areas functional areas from the call graph, not the directory layout, so an area can span directories. Each carries test_share and the entry points that reach it; an area nothing reaches is a library or is dead. triggers which entry points can reach target - what a user can actually do that runs this code. The complement of impact: not "what else changes" but "what can set this off". coupling file pairs that keep changing together, from git history. The rows worth reading are the ones with also_imports=false: those are coupled by something no static analysis can see. hotspots where change and structural weight meet. Neither alone is interesting; a file both heavily depended on and constantly rewritten is where a change is most likely to break something far away. deadcode symbols nothing in the graph reaches. CANDIDATES, never a verdict - read confidence on every row and the boundaries before acting on one. memscore measure this repository's own retrieval: accuracy, latency and context cost, reported side by side and deliberately not combined into one number. Ground truth is the store's anchored memories, so it is free and specific to this repository - and only comparable to another run on the SAME repository. Use it before and after touching search weights. window sets the sample size. run the runtime counterpart of all of the above: execute target (any shell command: 'python app.py', 'pytest -x tests/test_a.py', 'npm test') and record what actually happened. Python gets the full call flow, arguments, return values, how local variables changed line by line, time and CPU per function, exceptions and library calls; Node.js gets a sampled CPU profile; anything else gets time, memory, exit code and output. Calls the static graph does not know (dynamic dispatch, callbacks) are listed. Returns the path of report.md: READ THAT FILE, it is written for you. run_diff compare two recorded runs, e.g. before and after a change, or a passing and a failing input: the first point where the call sequence diverges, the first variables whose values differ, calls and exceptions present in only one run, and time that moved. target and to name the two runs (folder or name fragment); omit both to compare the two most recent runs in root.

READ THE ENVELOPE BEFORE THE RESULT. Every answer carries: epistemic 'exact' or 'lower-bound'. 'lower-bound' means callers exist that this result provably does not list. An empty affected with epistemic='lower-bound' is NOT proof that nothing calls the symbol. boundaries one plain sentence per reason, for humans. causes the machine-readable why. Every field counts MISSING or UNPROVEN things, never sentences: ambiguous_call_sites - call sites naming this symbol that could not be attributed to a single definition. These are the callers you are not being shown. inferred_edges_traversed - edges resolved by import scope or by uniqueness of the name, not proven from the syntax. Counts edges walked, so it can exceed counts.inferred, which counts distinct symbols reached. external_call_sites - calls that left the indexed program. Not a defect: no in-graph node could have been reached.

Edges are tiered, and the tier is on every result. receiver_self (1.0) and same_file (0.9) are read off the syntax; imported (0.8) and unique_global (0.6) are judgements. Pass min_confidence=0.9 to walk only what was proven.

The three history actions carry their own envelope. It is always 'lower-bound': history only knows the commits it read, only knows committed work, and knows nothing that a squash or a shallow clone removed. history in the result says how much was actually read.

Args: action: impact (default), trace, cycles, entrypoints, areas, triggers, coupling, hotspots, deadcode, memscore. target: symbol to analyse, the path source for trace, or - for action='entrypoints' - a kind to filter by (route, tool, cli, test). A bare name is fine; if it is ambiguous the candidates come back for you to choose. to: destination symbol, for trace. direction: upstream or downstream, for impact. depth: hops to walk. Clamped to 12. file_hint: path fragment disambiguating target, e.g. 'search.py'. to_file_hint: the same, for to. include_tests: include test files in the blast radius. For action='areas', rank mostly-test areas alongside the rest instead of sorting them last. For action='deadcode', report unreferenced test symbols too. min_confidence: drop edges below this confidence before walking. window: commits to read, for the history actions. Default 500, max 5000. since: a git date ('3 months ago', '2026-01-01') bounding that window. root: repository path. Defaults to the server's working directory. For action='run', the directory the command runs in. timeout_seconds: for action='run', stop the command after this long. run_options: for action='run', any of 'libraries' (also trace the standard library and installed packages; slower), 'memory' (allocation sites; slower), 'no-values' (flow and timing only; fastest).

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": "graph"
  }
}

Input Schema

NameRequiredDescriptionDefault
toNo
rootNo
depthNo
sinceNo
actionNoimpact
targetNo
windowNo
directionNoupstream
file_hintNo
run_optionsNo
to_file_hintNo
include_testsNo
min_confidenceNo
timeout_secondsNo

Output Schema

NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.8/5.0
Behavior5/5

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

With no annotations the description carries the full burden and does so: it explains the epistemic/boundaries/causes envelope, warns that an empty affected with epistemic='lower-bound' is not proof of no callers, discloses edge tiers with concrete confidences, states that history actions are always lower-bound and blind to squashes and shallow clones, and flags deadcode as "CANDIDATES, never a verdict". It also tells the agent that action='run' returns a report.md path that must be read, which is behavioral information no schema could convey.

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?

Front-loaded with purpose and WHEN TO USE, then a scannable per-action block, then envelope semantics, then Args — good ordering for an 11-action tool. There is some duplication between the Actions prose and the Args list (run/run_diff, depth clamping, window bounds), and the length is at the upper limit of what an agent will read in one pass, so it is efficient but not waste-free.

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

Completeness4/5

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

For a 14-parameter, multi-action tool with no annotations, the description is unusually complete, and an output schema exists so return shapes needn't be restated. One residual gap: the Args line for action enumerates only ten actions, omitting run and run_diff, which the agent must infer from the Actions section — a small inconsistency in an otherwise thorough definition.

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

Parameters5/5

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

Schema description coverage is 0%, so the description must define all 14 parameters, and it does: action, target (including its overloaded meaning for entrypoints and run), to, direction, depth ("clamped to 12"), file_hint, to_file_hint, include_tests (with per-action meaning for areas and deadcode), min_confidence ("pass 0.9 to walk only what was proven"), window (default 500, max 5000), since, root, timeout_seconds, and run_options values. It adds real semantic content — upstream means "who breaks if the contract changes" — rather than restating field names.

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?

Opens with a specific verb-and-resource framing ("Structural questions about the code graph: blast radius, paths, cycles") and immediately contrasts itself with the sibling: investigate() answers "what is this and why" while graph() answers "what else moves if I touch it". An agent can route between the two without opening either schema.

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?

Explicit WHEN TO USE and AFTER THIS sequencing, plus per-action selection guidance such as "Start here on an unfamiliar codebase" for entrypoints and "Use it to prove two symbols are actually connected rather than assuming it" for trace. It also names the downstream handoff to investigate(action='why') and record(), so exclusions and follow-ups are covered, not just context.

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