Skip to main content
Glama
pwno-io

treesitter-mcp

by pwno-io

treesitter_analyze_file

Analyze source files to extract symbols like functions and classes. Supports Python, C, C++, and header files; optionally write results to a file to avoid context overload.

Instructions

Analyze a source code file and extract symbols (functions, classes, etc.).

Args: file_path: Path to the source code file to analyze (supports .py, .c, .cpp, .h, .hpp) output_file: If provided, writes result to this file instead of returning. Useful for large outputs to prevent context overload.

Returns: Dictionary containing: - file_path: The analyzed file path - language: Detected programming language - symbols: List of extracted symbols (functions, classes, etc.) - errors: Any parsing errors encountered OR if output_file is set: {"status": "written", "output_file": "...", "bytes_written": N}

Note: This function does not return the full AST to avoid serialization issues. Use treesitter_get_ast() if you need the complete AST.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYes
output_fileNo
Behavior5/5

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

With no annotations provided, the description carries full behavioral burden. It discloses that the function does not return the full AST due to serialization issues, can write results to a file, and returns a structured dictionary with specific fields. It also lists supported file extensions, providing valuable context beyond the bare schema.

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 well-structured and concise: a one-sentence purpose, followed by clear Args/Returns sections and a note. Every sentence contributes useful information without redundancy or fluff.

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?

Despite no output schema, the description details the return dictionary structure. It also covers limitations, error handling ('errors' field), and alternative tool usage. Given the tool's simplicity (2 params, 1 required), the description is fully sufficient for an agent to select and invoke it correctly.

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

Parameters5/5

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

Schema description coverage is 0%, so the description fully compensates: file_path is described as 'Path to the source code file to analyze (supports .py, .c, .cpp, .h, .hpp)' and output_file is explained as 'If provided, writes result to this file instead of returning. Useful for large outputs to prevent context overload.' This adds significant meaning beyond the property names.

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: 'Analyze a source code file and extract symbols (functions, classes, etc.)'. It specifies the verb 'extract' and the resource 'source code file', and distinguishes itself from siblings by noting it returns symbols rather than the full AST.

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?

Explicitly provides guidance on when to use an alternative: 'Use treesitter_get_ast() if you need the complete AST.' Also explains when to use the output_file parameter ('Useful for large outputs to prevent context overload'), giving clear context for choosing options.

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/pwno-io/treesitter-mcp'

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