Skip to main content
Glama

analyze_code_ast

Deconstruct source code or commands into AST primitives to detect dynamic eval, shell piping, lateral egress, and destructive operations.

Instructions

Deconstruct source code or commands into abstract syntax tree (AST) primitives to detect dangerous patterns.
Identifies dynamic evaluations, shell piping, lateral network egress, and destructive operations.

Args:
    code: The source code snippet, query, or command string to statically analyze.
    environment: The syntactic context or execution environment ('python', 'bash', 'sql'). Default is 'python'.

Returns:
    Dictionary containing detected execution primitives, security classification, and containment recommendations.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYes
environmentNopython

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv0.1.2

TDQS

A4.1/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 it does disclose that the operation is static (no execution) and that it returns detected primitives, a security classification, and containment recommendations. It omits things like performance limits or how strictly classification thresholds are set, but the safety-relevant behavior 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.

Conciseness4/5

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

Front-loaded with purpose followed by clear Args/Returns sections; the two-line opener carries the real signal. The Args/Returns blocks are somewhat formulaic but each line adds information, with no filler sentences.

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?

An output schema exists so return values needn't be spelled out, and both parameters are documented despite zero schema coverage. For a two-parameter, annotation-free analysis tool this is essentially complete, with only explicit usage routing missing.

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 description coverage is 0%, so the description must compensate, and it does: it documents 'code' as the snippet/query/command to analyze and 'environment' as the syntactic context, adding concrete enum-like values ('python', 'bash', 'sql') and the 'python' default that the schema does not provide.

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+resource ('Deconstruct source code or commands into abstract syntax tree primitives') and a concrete goal ('to detect dangerous patterns') with enumerated categories of what it finds. The sibling tools (telemetry, interception) are clearly different, so an agent can identify this as the static-analysis entry point without checking schemas.

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

Usage Guidelines3/5

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

The intent ('statically analyze... to detect dangerous patterns') implies when the tool is useful, i.e., security screening of code or commands. However, it gives no explicit when-to-use/when-not guidance, no mention of prerequisites such as when to prefer it over intercept_tool_call, and no exclusions.

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