insert
Add code at a precise line number to modify Strudel music patterns during live coding sessions.
Instructions
Insert code at specific line
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| position | Yes | Line number | |
| code | Yes | Code to insert |
Implementation Reference
- The main handler logic for the 'insert' MCP tool. Validates inputs, splits the current pattern into lines, inserts the new code at the specified position using Array.splice, and writes the updated pattern back using writePatternSafe.case 'insert': InputValidator.validatePositiveInteger(args.position, 'position'); InputValidator.validateStringLength(args.code, 'code', 10000, true); const lines = (await this.getCurrentPatternSafe()).split('\n'); lines.splice(args.position, 0, args.code); return await this.writePatternSafe(lines.join('\n'));
- src/server/EnhancedMCPServerFixed.ts:104-114 (registration)Registration of the 'insert' tool in the getTools() method, including name, description, and input schema definition for MCP protocol compliance.{ name: 'insert', description: 'Insert code at specific line', inputSchema: { type: 'object', properties: { position: { type: 'number', description: 'Line number' }, code: { type: 'string', description: 'Code to insert' } }, required: ['position', 'code'] }
- Input schema definition for the 'insert' tool specifying position (number) and code (string) parameters.inputSchema: { type: 'object', properties: { position: { type: 'number', description: 'Line number' }, code: { type: 'string', description: 'Code to insert' } }, required: ['position', 'code']