Skip to main content
Glama
0xYubo
by 0xYubo

scan_patterns

Read-only

Search any codebase with regex patterns to locate code affected by field, function, or string changes. Returns per-file hits with line numbers for impact analysis.

Instructions

在代码库中搜索任意正则表达式 pattern,支持 Python/TypeScript/JavaScript/任意文本文件。这是最通用的搜索工具,适用于所有变更场景:字段访问、函数调用、字符串值、常量、配置项、API 路径、SQL 字段名、注释、枚举值等任何内容。当用户描述任何类型的代码变更并想知道影响范围时,调用此工具。由 Claude 根据变更描述决定要搜什么 pattern,此工具只负责机械执行搜索。返回按文件聚合的 JSON:{engine, total_found, returned, truncated, files:[{file:相对路径, hits:[{line, code, patterns, confidence}]}]}。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
patternsYes正则表达式列表,支持任意内容。例如:字段访问: ["machine\.x", "machine\['x'\]"] | 函数调用: ["calculate_distance\("] | 字符串值: ["'success'", "\"failed\""] | 常量: ["STATUS_OK", "MAX_RETRY"] | API路径: ["/api/external/"] | SQL字段: ["survey_status_today"] | 导入: ["from plogen_tools import"]
extensionsNo文件扩展名,默认 ['.py','.ts','.tsx','.js','.jsx']
max_resultsNo最大返回结果数,默认 500;truncated=true 时可增大后重试
exclude_dirsNo排除目录,不传则使用默认排除列表(node_modules/.venv/dist 等),传 [] 则不排除任何目录
project_pathYes项目根目录绝对路径
Behavior4/5

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

Beyond the minimal readOnlyHint: true annotation, the description adds valuable behavioral context: it states the tool '只负责机械执行搜索' (only mechanically executes search) and describes the exact JSON return structure aggregated by file. This gives the agent insight into the tool's role and output. It does not contradict the annotation. Slightly more could be said about edge cases or performance, but the disclosure is solid.

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 front-loaded with the core purpose in the first sentence, followed by concise sentences that each add distinct value: generality, usage guidance, tool role, and return format. There is no fluff or repetition, making it appropriately sized for a general-purpose search tool.

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?

Since there is no output schema, the description includes the return JSON structure, which is helpful. It covers the tool's scope, when to use it, its mechanical nature, and return format. While some defaults (e.g., extensions, max_results) are only in the schema, this is acceptable. The description is contextually complete for a complex search tool, though it could briefly mention potential limitations like truncation behavior (which is already in the schema).

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 schema descriptions for all 5 parameters are detailed, providing examples for patterns and defaults for extensions and max_results, so schema coverage is 100%. The description itself does not add additional parameter-level semantics; it only mentions the return format. Since the schema does the heavy lifting, the 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 opens with a specific verb+resource: '在代码库中搜索任意正则表达式 pattern' (search arbitrary regex patterns in the codebase). It then distinguishes itself as '最通用的搜索工具' (the most general-purpose search tool) and provides concrete examples of what it can search (field access, function calls, string values, etc.), clearly differentiating it from specialized sibling tools like trace_callers or find_definition.

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?

The description explicitly states when to use the tool: '当用户描述任何类型的代码变更并想知道影响范围时,调用此工具' (call this tool when the user describes any type of code change and wants to know the impact scope). It also clarifies that Claude decides the patterns to search, relieving the tool of interpretation. However, it does not mention alternatives or when not to use this tool, so it falls short of a 5.

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