complex_find_replace
Perform context-aware find and replace operations in files using regular expressions and custom options, enabling precise text modifications and edits on the Edit-MCP server.
Instructions
Perform advanced find and replace operations with context awareness
Input 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 |
Input Schema (JSON Schema)
{
"properties": {
"options": {
"description": "Additional options for the find and replace operation",
"type": "object"
},
"path": {
"description": "Path to the file to perform find and replace on",
"type": "string"
},
"pattern": {
"description": "Regular expression pattern to search for",
"type": "string"
},
"replacement": {
"description": "Replacement text",
"type": "string"
}
},
"required": [
"path",
"pattern",
"replacement"
],
"type": "object"
}
Implementation Reference
- src/router/operation-router.ts:455-463 (handler)Handler for 'complex_find_replace' operation: creates an edit session and executes a 'replace' command on the EditInstanceManager.case '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 'replace' EditCommand by sending a formatted command to the spawned Edit process instance.case '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 with the MCP server, including its input schema 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/index.ts:275-296 (schema)Defines the input schema for the 'complex_find_replace' tool.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'] },
- Classifies 'complex_find_replace' as a complex operation in the router's complexity analysis.const complexOperations = [ 'interactive_edit_session', 'format_code', 'complex_find_replace', 'merge_conflicts_resolution', 'bulk_edit_operation', 'edit_with_context_awareness' ];