Skip to main content
Glama

Build Persistent AST Context Snapshot Cache

build_ast_snapshot
Idempotent

Creates or reuses a persistent .tzero/snapshot.json AST index to cache codebase symbols and token metrics for multi-turn loading, returning cache status.

Instructions

Creates or reuses a persistent '.tzero/snapshot.json' AST index and returns cache status, distinguishing from 'build_project_context' which returns context without writing a snapshot and 'generate_architectural_passport' which inspects one file.

Parameters:

  • workspace_dir (str, optional, default='.'): Target repository root directory containing source code to index.

  • force_refresh (bool, optional, default=False): When True, invalidates existing snapshot and rebuilds fresh AST cache from disk.

Behavior:

  • Mutability: Writes cached index to '.tzero/snapshot.json'; does not modify repository source code files.

  • Idempotency: Deterministic index generation for identical repository state.

  • Performance & Latency: Sub-8ms cache retrieval on hit; <600ms initial scan across 100+ files.

  • Resources: Consumes <45MB RAM; thread-safe local file operations.

  • Privacy: 100% offline local processing; zero external network transmission.

  • Auth & Limits: Zero external credentials or API keys required; zero rate limits.

  • Error Handling: Skips unparseable or binary files gracefully and continues indexing.

Usage Guidelines:

  • When to use: Use when caching or fast-loading complete codebase AST symbols and token metrics in <8ms across multi-turn sessions or large workspaces (10,000+ files).

  • When NOT to use: Do not use for real-time live symbol editing or single file pruning (use 'prune_code_snippet' instead); do not use for ad-hoc semantic keyword searching (use 'search_codebase' instead).

Returns: Formatted Markdown report detailing snapshot status, file count, load time, and token economics (-95%).

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

Input Schema

NameRequiredDescriptionDefault
force_refreshNoWhether to force rebuild the cache even if valid (default: False).
workspace_dirNoTarget repository root directory (default: current directory)..

Output Schema

NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv10.6.0

TDQS

A4.3/5.0
Behavior4/5

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

Annotations already declare readOnlyHint=false, idempotentHint=true, destructiveHint=false and openWorldHint=false, but the description adds real substance beyond that: the exact file written (.tzero/snapshot.json), the guarantee that source files are untouched, graceful skipping of binary/unparseable files, and local-only processing with no credentials. The latency and memory figures (sub-8ms, <600ms, <45MB) are useful but read as marketing claims and are unverifiable from the description alone, which keeps this just short of a 5.

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

Conciseness3/5

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

The definition is front-loaded and well organized with clear sections, but it is over-long for a two-parameter tool. The Parameters block duplicates the schema, the 'Returns' sentence duplicates the output schema, and the Privacy/Auth bullets ('Zero external credentials', 'zero rate limits') are boilerplate that inflate length without changing how the agent calls it.

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?

For a cache-building tool with a write side effect, the description covers the decision inputs (when/when-not), the side effect (which file is written, source untouched), idempotency, and failure tolerance. An output schema exists, so the additional Returns sentence is a bonus rather than a necessity, and nothing an agent needs before calling is missing.

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 both parameters are already fully documented. The Parameters block essentially restates the schema ('Target repository root directory', 'invalidates existing snapshot and rebuilds fresh AST cache'), adding only mild nuance on force_refresh semantics. 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 opening sentence gives a specific verb and resource ('Creates or reuses a persistent .tzero/snapshot.json AST index'), states the return ('returns cache status'), and explicitly contrasts with two named siblings: build_project_context (no snapshot written) and generate_architectural_passport (single-file inspection). An agent can choose correctly without opening any 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?

It provides an explicit 'When to use' condition (multi-turn sessions, large workspaces, fast cache retrieval) and a 'When NOT to use' section that routes two distinct cases to prune_code_snippet and search_codebase. Alternatives are named with the reason each is preferred.

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