Skip to main content
Glama

analyze_file_ast

Parses a Python file's abstract syntax tree to yield an outline of docstrings, imports, top-level classes, functions, variables, and line counts. Enables codebase analysis without loading full source.

Instructions

Parse a Python file using Python's AST parser and return a detailed outline of its docstrings, imports, top-level classes, functions, variables, and line counts.

:param file_path: Path to the Python (.py) file to analyze.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes
Behavior2/5

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

No annotations (readOnlyHint, destructiveHint) are provided, so the description must carry the full burden of disclosing side effects. It states 'parse' which implies a read-only operation, but it does not explicitly state that the file is not modified, nor does it mention authentication, rate limits, or other behavioral aspects. The description is vague about non-obvious behaviors.

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?

The description is a single, front-loaded sentence that immediately states the action ('Parse a Python file') and then lists the elements of the returned outline. There is no unnecessary verbosity or repetition; every part contributes to the understanding.

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?

The tool is relatively simple (single parameter, clear output), and an output schema exists (though not detailed here). The description sufficiently conveys what the tool does and what the outline contains, so the user can predict the result. It does not cover error conditions or edge cases, but these are not critical given the tool's simplicity.

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?

The input schema has one parameter, 'file_path', with full coverage in the schema (name and type are provided). The description does not add extra meaning about the parameter, such as path format or constraints. Since schema coverage is high, a baseline score of 3 is appropriate.

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 clearly states the tool's purpose: parsing a Python file with AST and returning a detailed outline of its components (docstrings, imports, classes, functions, variables, line counts). It uses a specific verb ('parse') and resource ('Python file'), and distinguishes itself from sibling tools by offering a broad outline rather than focused analyses.

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

Usage Guidelines2/5

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

The description does not mention when to use this tool versus the sibling tools (e.g., find_class_methods, get_imports_graph). No explicit use cases, conditions, or alternatives are provided. Users must infer from the description that it is appropriate for a general overview.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/m-sameerkhan/code-ast-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server