Skip to main content
Glama
0xYubo
by 0xYubo

analyze_python_ast

Read-only

Perform AST-level precise analysis of Python code to find symbols, fields, strings, calls, and imports with contextual function names and confidence scores, enabling accurate code searches beyond grep.

Instructions

对 Python 代码做 AST 级别精确分析,比 grep 更准确。支持多种搜索目标,可同时指定多类:

  • symbols: 任何标识符(变量名、类名、常量名)

  • field_names: 字段/属性名(捕获 obj.field / obj['field'] / obj.get('field'))

  • string_values: 字符串字面量值(捕获代码中的字符串常量)

  • call_names: 函数/方法调用名

  • import_names: 导入的模块或符号名 每个命中都标注所在函数名、访问方式和置信度,适合需要精确上下文的场景。返回按文件聚合的 JSON:{total_found, returned, truncated, files:[{file:相对路径, hits:[{line, kind, value, extra, function, confidence}]}]}。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
symbolsNo标识符名列表,如 ['AllEq', 'DEFAULT_TTL']
call_namesNo函数/方法调用名列表,如 ['get_eq_partition']
field_namesNo字段/属性名列表,如 ['x', 'y', 'status']
max_resultsNo最大返回结果数,默认 500;truncated=true 时可增大后重试
exclude_dirsNo排除目录,不传则使用默认排除列表,传 [] 则不排除任何目录
import_namesNo导入符号/模块名列表,如 ['plogen_tools']
project_pathYesPython 项目根目录绝对路径
string_valuesNo字符串字面量值列表,如 ['success', 'failed']
Behavior4/5

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

The readOnlyHint annotation already covers safety. The description adds behavioral detail by describing the return format, the per-hit fields (line, kind, value, extra, function, confidence), and the truncation flag. It doesn't contradict annotations.

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: a one-sentence core value proposition, a bulleted list of search targets, and a compact return schema. Each sentence contributes new information, making it concise despite its length.

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 moderately complex with 8 parameters and no output schema, but the description compensates by specifying the JSON return structure and per-hit metadata. It does not cover edge cases like duplicate hits or performance, but the essential information for correct invocation and result interpretation is present.

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?

With 100% schema coverage, the baseline is 3. The description adds semantic meaning for each parameter type, especially field_names ('捕获 obj.field / obj['field'] / obj.get('field')') and string_values, and notes that multiple search types can be combined—a behavior not detailed 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?

The description clearly identifies the tool as performing AST-level precise analysis of Python code ('对 Python 代码做 AST 级别精确分析') and differentiates it from grep ('比 grep 更准确'). It enumerates five distinct search targets (symbols, field_names, string_values, call_names, import_names), which distinguishes it from siblings like scan_patterns.

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

Usage Guidelines4/5

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

It explicitly states that the tool is suitable for scenarios needing precise context ('适合需要精确上下文的场景') and claims better accuracy than grep, giving an implicit comparison to alternatives. However, it does not name sibling tools or state when not to use it, so it stops short of full exclusion guidance.

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/0xYubo/Ripple-Mcp'

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