Skip to main content
Glama

batch_refactor

Apply a refactor instruction to every file matching a glob pattern. Review diffs with dry run before writing changes.

Instructions

Apply a refactor instruction to every file matching a glob pattern, sequentially.

glob_pattern matches relative paths under root_dir (default: the server's allowed base directory), e.g. "src/**/*.py". Files are processed one at a time against the local model. With dry_run=True (the default) nothing is written -- you get a unified diff per file to review first; set dry_run=False to write accepted changes to disk. Large match sets are capped (see OLLAMA_MCP_MAX_BATCH_FILES) to avoid runaway sequential runs.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
thinkNo
dry_runNo
root_dirNo
instructionYes
glob_patternYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes
Behavior5/5

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

The description details key behaviors: sequential processing per file, default dry_run to prevent writes, capping of large match sets via OLLAMA_MCP_MAX_BATCH_FILES, and the need to set dry_run=False to apply changes. No annotations are provided, but the description fully compensates.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

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

The description is a single paragraph that front-loads the main purpose and then explains parameters and behavior. It is reasonably concise, though a bullet list could improve scanability.

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?

Given the output schema exists and the description covers purpose, parameters, safety (dry run), limitations (capping), and procedural details, the description is complete enough for an agent to select and invoke the tool 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?

With 0% schema description coverage, the description is essential. It explains glob_pattern as matching relative paths under root_dir, root_dir's default behavior, dry_run's default value, and that instruction is the refactor directive. All parameters are effectively documented.

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 specific action ('Apply a refactor instruction') and the resource ('every file matching a glob pattern, sequentially'). It distinguishes from sibling tools like refactor_code, which likely targets single files.

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 explains that the tool is for sequential refactoring across multiple files matching a glob pattern, with dry_run defaulting to true for safety. It mentions the environment variable cap but does not explicitly list when not to use or alternative tools.

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/darthzen/ollama-code-mcp'

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