fast_apply
Apply code changes to files using intelligent merging. For new files, writes content directly; for existing files, merges a snippet with anchor lines from the current content.
Instructions
Edit or create a file using intelligent merging.
For new files: writes content directly. For existing files: merges edit_snippet with current content using anchor lines. Anchor lines are verbatim lines copied from the existing file that help locate the exact edit target. Include 1-2 unique lines adjacent to the change. Truncation markers are recommended for larger scoped edits but not required. Markdown files keep fenced code blocks verbatim; outer fence stripping is skipped for .md/.mdx targets.
On error, the response includes a code field:
NEEDS_MORE_CONTEXT: merge model could not locate the target - add 1-2 unique anchor lines from immediately around the edit location.
APPLY_NOOP: merge returned an identical file even though the snippet contained explicit remove directives or concrete new lines not present in the original.
BLAST_RADIUS_EXCEEDED: edit scope too large - split into smaller edits.
MARKER_LEAKAGE: placeholder marker text leaked into merged output (treated as literal text).
TRUNCATION_DETECTED: merged output shrank drastically and no explicit remove directive was provided.
On success: {status: "ok", diff: str | None (unified diff, None for new files or no-op)}.
Do NOT use this tool to delete files or clear file contents. Use a dedicated file management tool for those operations.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | File path (absolute or relative to MCP_BASE_DIR; if MCP_BASE_DIR is unset, relative paths resolve against MCP Roots). | |
| edit_snippet | Yes | Code snippet representing the changes. Include only the lines being added or modified, plus placeholder comments for unchanged parts when useful for larger scoped edits: `// ... existing code ...` (JS/TS), `# ... existing code ...` (Python/shell). Anchor the edit with 1-2 verbatim lines from the existing file. | |
| instruction | No | Optional natural language hint to disambiguate the target location (e.g., 'add after imports', 'inside the if block'). |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||