apply_auto_corrections
Apply auto-correction patterns from matching contexts to text, ensuring consistent formatting and syntax across conversations.
Instructions
Apply auto-correction patterns from matching contexts to text
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| text | Yes | Text to apply corrections to | |
| tool_name | Yes | Tool context to use for corrections |
Implementation Reference
- src/server/index.ts:262-292 (handler)The handler for the apply_auto_corrections tool, which uses engine.getAutoCorrections to retrieve and apply corrections.
case 'apply_auto_corrections': { const text = String(args?.['text'] ?? ''); const toolName = String(args?.['tool_name'] ?? ''); if (!text || !toolName) { return { content: [{ type: 'text', text: 'Error: text and tool_name are required' }], }; } const corrections = engine.getAutoCorrections(toolName); let result = text; const applied: string[] = []; for (const c of corrections) { const re = new RegExp(c.pattern, 'gi'); if (re.test(result)) { result = result.replace(re, c.replacement); applied.push(c.name); } } return { content: [ { type: 'text', text: JSON.stringify( { corrected_text: result, corrections_applied: applied }, null, 2, ), }, ], }; } - src/server/index.ts:103-116 (registration)Registration of the apply_auto_corrections tool in the ListToolsRequestSchema.
name: 'apply_auto_corrections', description: 'Apply auto-correction patterns from matching contexts to text', inputSchema: { type: 'object' as const, properties: { text: { type: 'string', description: 'Text to apply corrections to' }, tool_name: { type: 'string', description: 'Tool context to use for corrections', }, }, required: ['text', 'tool_name'], }, },