complex_find_replace
Perform advanced find and replace operations in files using context-aware regular expressions to modify text patterns efficiently.
Instructions
Perform advanced find and replace operations with context awareness
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | Path to the file to perform find and replace on | |
| pattern | Yes | Regular expression pattern to search for | |
| replacement | Yes | Replacement text | |
| options | No | Additional options for the find and replace operation |
Implementation Reference
- src/index.ts:272-303 (registration)Registers the 'complex_find_replace' tool including its input schema, description, and annotations.mcpServer.registerTool({ name: 'complex_find_replace', description: 'Perform advanced find and replace operations with context awareness', inputSchema: { type: 'object', properties: { path: { type: 'string', description: 'Path to the file to perform find and replace on' }, pattern: { type: 'string', description: 'Regular expression pattern to search for' }, replacement: { type: 'string', description: 'Replacement text' }, options: { type: 'object', description: 'Additional options for the find and replace operation' } }, required: ['path', 'pattern', 'replacement'] }, annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: false } });
- src/router/operation-router.ts:455-463 (handler)Main handler for 'complex_find_replace' tool: creates an edit session and delegates to EditInstanceManager.executeEditCommand with a 'replace' command.case 'complex_find_replace': return this.editInstanceManager.executeEditCommand(sessionId, { type: 'replace', params: { pattern: operation.params.pattern, replacement: operation.params.replacement, options: operation.params.options } });
- Implements the replace operation (used by complex_find_replace) by executing a 'replace' command on the editor instance.case 'replace': result = await instance.executeCommand(`replace ${command.params.pattern} ${command.params.replacement}`); return { success: true, message: result };