Skip to main content
Glama

Polyglot AST Symbol Extractor, Call Graph & Complexity Analyzer

analyze_ast_symbol_graph
Read-onlyIdempotent

Statically parses TypeScript, Python, Rust, Go, or Move code to extract symbols, call edges, and complexity metrics for mapping functions and hotspots before refactoring.

Instructions

Static lexer and AST parser only (zero execution or evaluation): extracts imports, exports, classes, interfaces, and functions with line numbers, intra-file call edges, McCabe cyclomatic complexity, and Halstead volume across TypeScript, Python, Rust, Go, and Move. Use when mapping internal functions, call graphs, and complexity hotspots of a source file before refactoring; for analyzing cross-file import DAGs and circular dependencies, use audit_module_dependency_cycles instead. Read-only call (32 KB, 60 RPM): accepts 'source_text' (with enum defaults), uses '?demo=true' or L402 (20 sats); HTTP 400 if invalid.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "code": "<code>"
    },
    "name": "analyze_ast_symbol_graph"
  }
}

Input Schema

NameRequiredDescriptionDefault
codeYesSource code file content to parse for symbols and complexity metrics.
languageNoProgramming language grammar used for symbol extraction; defaults to 'typescript' when omitted.
source_textNoAlias for code: source code file content to parse.

Output Schema

NameRequiredDescriptionDefault
functionsYesExtracted functions with line number, cyclomatic_complexity, and outgoing calls.
lines_of_codeYesTotal line count of the analyzed source code.
halstead_metricsYesHalstead vocabulary_size, program_length, volume, and estimated_bugs.
high_complexity_hotspotsYesFunctions with McCabe cyclomatic complexity >= 8 flagged for refactoring.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changedv2.6.0
    • addedInput schema / properties / source_text
      Added value: +{
      +  "description": "Alias for code: source code file content to parse.",
      +  "type": "string"
      +}
    • changedInput schema / required
      Previous value: -[
      -  "source_text"
      -]New value: +[
      +  "code"
      +]
  2. Addedv1.3.3

TDQS

A4.5/5.0
Behavior5/5

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

Annotations already cover read-only/idempotent/closed-world, and the description adds behavior beyond them: zero execution or evaluation guarantee, a 32 KB payload limit, 60 RPM rate limit, auth options (?demo=true or L402 20 sats), and HTTP 400 on invalid input. These are operationally actionable traits not present in the annotations.

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 the core purpose and extraction capabilities, then usage routing, then operational constraints. It is dense but each clause carries information; the pricing/auth details are compressed rather than verbose.

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?

With an output schema present and annotations covering the safety profile, the description needn't explain return values and doesn't. It covers languages, limits, auth, and error behavior; the only residual gap is the minor 'code' vs 'source_text' alias ambiguity.

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 coverage is 100%, so all three parameters and the enum defaults are already documented, making the baseline 3. The description adds the 32 KB size constraint but its mention of 'source_text' as the accepted input is slightly ambiguous since 'code' is the required parameter and the alias relationship is only clarified in 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?

States a specific verb+resource ('Static lexer and AST parser') and enumerates exactly what it extracts (imports, exports, classes, interfaces, functions, call edges, McCabe complexity, Halstead volume) plus the supported languages. It explicitly distinguishes itself from the sibling audit_module_dependency_cycles by scoping to intra-file analysis.

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?

Gives an explicit when-to-use ('mapping internal functions, call graphs, and complexity hotspots of a source file before refactoring') and an explicit alternative with its condition ('for analyzing cross-file import DAGs and circular dependencies, use audit_module_dependency_cycles instead'). Little is left to inference.

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

Deploy Server

Other Tools