Skip to main content
Glama

scan_and_extract_patterns

Read-onlyIdempotent

Analyze code snippets, files, or directories to extract reusable patterns and decide whether to save them to the memory system. Supports scanning directories with configurable file and pattern limits.

Instructions

当需要从单段代码、单文件或整个目录中抽取可复用模式,再决定是否沉淀到记忆系统时使用。目录扫描时,优先传 project_root 为项目根目录绝对路径,并让 directory_path 传相对项目根的路径,例如 app/utils;只有无法确定项目根时,才把 directory_path 直接设为绝对路径。不要传带项目名的半相对路径,例如 font-miniapp-api/app/utils

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentNo待分析的代码或文本内容。传入该字段时走单段分析模式
file_pathNo来源文件路径。单段分析时作为来源路径使用
max_filesNo最多扫描多少个文件,默认 30,最大 200
max_patternsNo最多返回多少个候选模式,默认 20,最大 100
project_nameNo已废弃,扫描结果不再写入 source_project
project_rootNo项目根目录绝对路径。目录扫描时建议始终传入;传入后,`directory_path` 应写成相对项目根的路径。
directory_pathNo要扫描的目录路径。最佳实践是传相对 `project_root` 的路径,例如 `app/utils`;如果拿不到 `project_root`,才传目录绝对路径。不要传带项目名的半相对路径,例如 `font-miniapp-api/app/utils`。
include_extensionsNo允许扫描的文件扩展名列表,例如 [".ts", ".tsx", ".py"]
Behavior5/5

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

Annotations already declare readOnlyHint=true, destructiveHint=false, and idempotentHint=true, making the safety profile clear. The description adds value by detailing how the tool behaves in different modes (single-segment vs. directory scanning) and how parameters affect scanning behavior, without contradicting 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.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single dense paragraph that front-loads the purpose and then delivers precise usage guidelines. Every sentence adds value with no redundancy, efficiently packing information without being 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?

Given the tool's complexity (8 parameters, multiple modes, integration with memory system), the description covers essential usage contexts well. However, it does not describe the output format or what constitutes a 'pattern', which would be helpful since there is no output schema. Still, it is largely complete for an experienced agent.

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?

All 8 parameters have descriptions in the schema (100% coverage), so the baseline is 3. The description enriches this by explaining the relationship between 'project_root' and 'directory_path', best practices, and which parameters to use in which scenario, adding significant meaning beyond 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 states the tool's purpose: extracting reusable patterns from code snippets, single files, or entire directories, with the intent to potentially persist them into the memory system. It uses a specific verb ('scan and extract') and resource ('patterns from code'), and distinguishes itself from sibling tools like 'memorize_asset' and 'read_memory_asset' which handle direct memory operations.

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?

The description provides explicit guidance on when to use the tool (when needing to extract patterns for possible memorization) and how to parameterize it for directory scanning: recommending to pass 'project_root' as absolute and 'directory_path' as relative, with a warning against semi-relative paths. It also implies when not to use certain parameter combinations.

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/mybolide/mcp-probe-kit'

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