complex_find_replace
Perform context-aware advanced find and replace operations in files using regular expressions, enabling precise and efficient text modifications.
Instructions
Perform advanced find and replace operations with context awareness
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| options | No | Additional options for the find and replace operation | |
| path | Yes | Path to the file to perform find and replace on | |
| pattern | Yes | Regular expression pattern to search for | |
| replacement | Yes | Replacement text |
Implementation Reference
- src/router/operation-router.ts:455-463 (handler)Handler for complex_find_replace tool: routes to edit instance manager's replace commandcase 'complex_find_replace': return this.editInstanceManager.executeEditCommand(sessionId, { type: 'replace', params: { pattern: operation.params.pattern, replacement: operation.params.replacement, options: operation.params.options } });
- Executes the core replace command sent to the Edit process instancecase 'replace': result = await instance.executeCommand(`replace ${command.params.pattern} ${command.params.replacement}`); return { success: true, message: result };
- src/index.ts:272-303 (registration)Registers the complex_find_replace tool including its input schema and annotationsmcpServer.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 } });
- Defines EditCommand interface used internally, including 'replace' type for complex_find_replaceexport interface EditCommand { type: 'open' | 'close' | 'save' | 'edit' | 'find' | 'replace' | 'goto'; params: any; }
- Classifies complex_find_replace as a complex operation in analyzeComplexity methodconst complexOperations = [ 'interactive_edit_session', 'format_code', 'complex_find_replace', 'merge_conflicts_resolution', 'bulk_edit_operation', 'edit_with_context_awareness' ];