Skip to main content
Glama
nohosa001-pixel

security-gate-x402

inspect_code_ast_safety

Scan Python source code for dangerous AST operations such as eval, exec, subprocess, and sockets before sandbox execution. Validate raw code to block system manipulation and token exfiltration.

Instructions

Deterministic Python Abstract Syntax Tree (AST) parser scanning for hazardous operations (subprocess, os.system, eval, exec, socket, token exfiltration). Use this tool ONLY when validating raw Python source code or shell scripts for dangerous AST operations (e.g., eval, exec, subprocess, socket connections, system manipulation) prior to sandbox execution. Do NOT use this tool for natural language text or generic agent messages; use verify_agent_output or inspect_agent_output instead.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYesThe Python source code snippet to parse, validate, and audit via deterministic AST visitor.import math def calculate_roi(p, r, t): return p * (1 + r * t)

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed3 schema fields changedv1.0.5
    • addedInput schema / properties / code / default
      Added value: +"import math\ndef calculate_roi(p, r, t):\n    return p * (1 + r * t)"
    • changedInput schema / properties / code / description
      Previous value: -"The Python source code snippet to parse and audit via AST."New value: +"The Python source code snippet to parse, validate, and audit via deterministic AST visitor."
    • addedInput schema / properties / code / examples
      Added value: +[
      +  "import math\ndef calculate_roi(p, r, t):\n    return p * (1 + r * t)",
      +  "import os\nos.system('rm -rf /')"
      +]
  2. Addedv1.0.4

TDQS

A4.5/5.0
Behavior4/5

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

With no annotations available, the description must carry behavioral disclosure. It states the tool is deterministic, a static AST parser, and intended for use prior to sandbox execution, which strongly implies it does not execute code and has no side effects. It does not mention output format or failure modes, but the core safety-relevant trait of non-execution and determinism is communicated.

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

Conciseness5/5

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

Three sentences, front-loaded with the core purpose, followed by usage boundaries and alternatives. Every sentence earns its place, with no fluff or repetition of schema content. The structure is easy to parse.

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

Completeness3/5

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

The tool is a single-parameter, no-output-schema tool, and the description covers input, when-to-use, and exclusions. However, it never explains what the tool returns (e.g., a hazard report, verdict, or pass/fail), which is important because there is no output schema to fall back on.

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

Parameters4/5

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

Schema coverage is 100%, so the baseline is 3. The description adds meaning by broadening the accepted input to include 'shell scripts', which the schema's 'Python source code snippet' alone does not communicate. It also reinforces that the input is raw source code, not natural language, adding useful context beyond the schema.

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 opens with a specific verb-plus-resource construction: 'Deterministic Python Abstract Syntax Tree (AST) parser scanning for hazardous operations' and lists concrete hazards (subprocess, os.system, eval, exec, socket, token exfiltration). It also differentiates from siblings by explicitly stating the intended input domain and pointing to alternatives. This is unambiguous.

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 explicit when-to-use guidance ('ONLY when validating raw Python source code or shell scripts ... prior to sandbox execution') and a clear do-not-use case ('Do NOT use this tool for natural language text or generic agent messages'). It also names alternatives (`verify_agent_output` or `inspect_agent_output`), leaving no inference needed.

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