Skip to main content
Glama

verify_hallucination_guard

Verify proposed Python code against local AST signatures to catch hallucinated imports and wrong function/method call contracts before applying AI-generated changes.

Instructions

Eliminates AI coding hallucinations before code is written or applied. Parses proposed code and verifies all internal imports and function/method call contracts (argument counts and keyword parameter names) against known workspace AST signatures.

Behavior:

  • Read-only: Compares AST call signatures against local symbol catalog; does not modify source files.

  • Idempotent: Deterministic contract verification.

  • 100% Offline: Uses local AST indices without remote queries.

Usage Guidelines:

  • When to use: Run BEFORE applying AI-generated code to prevent hallucinated module imports, missing functions, or wrong argument counts.

  • Sibling Routing: To enforce layer boundary separation rules, use 'enforce_architecture_boundaries'.

Returns: Verification status report with specific contract mismatches and 'did you mean' fuzzy suggestions.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
target_fileNoOptional path of the target file being modified to resolve relative imports.
project_rootNoWorkspace root directory providing the ground-truth AST symbol catalog (default: current directory)..
proposed_codeYesPython code proposed to be written or edited.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed3 schema fields changedv0.1.1
    • addedInput schema / properties / project_root / description
      Added value: +"Workspace root directory providing the ground-truth AST symbol catalog (default: current directory)."
    • addedInput schema / properties / proposed_code / description
      Added value: +"Python code proposed to be written or edited."
    • addedInput schema / properties / target_file / description
      Added value: +"Optional path of the target file being modified to resolve relative imports."
  2. First observedv0.1.0

TDQS

A4.4/5.0
Behavior4/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 well: it declares read-only ('does not modify source files'), idempotent/deterministic, and 100% offline, and it explains the return content. It stops short of only minor items like how mismatches are ordered or performance bounds.

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-loads the core purpose, then uses labeled Behavior/Usage/Returns sections that are easy to scan. Slightly verbose in places (e.g., restating read-only and offline separately), but every line is relevant.

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 verification tool, the description covers what it checks, how (AST against local symbol catalog), the safety profile, when to run it, sibling routing, and even the return shape. An agent has everything needed to call it correctly.

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 proposed_code, target_file, and project_root. The description adds only marginal framing ('against known workspace AST signatures') and doesn't add syntax or format detail beyond the schema, so the baseline 3 applies.

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?

States a specific verb and resource ('Parses proposed code and verifies all internal imports and function/method call contracts') with concrete scope (argument counts, keyword parameter names, AST signatures). Clearly distinguishable from siblings like enforce_architecture_boundaries and audit_codebase_quality.

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: Run BEFORE applying AI-generated code' with the failure modes it prevents, plus an explicit sibling route ('To enforce layer boundary separation rules, use enforce_architecture_boundaries'). Both when-to-use and alternatives are named.

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