clear
Remove existing content from the Strudel.cc editor to start fresh with AI-powered music generation, pattern creation, and live coding tasks in TidalCycles/Strudel environments.
Instructions
Clear the editor
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- Handler for the 'clear' tool. Clears the editor by writing an empty string to the pattern using writePatternSafe method.case 'clear': return await this.writePatternSafe('');
- Schema definition for the 'clear' tool, including name, description, and empty input schema. Part of the tools list returned by getTools().name: 'clear', description: 'Clear the editor', inputSchema: { type: 'object', properties: {} } },
- src/server/EnhancedMCPServerFixed.ts:442-444 (registration)Registration of the tool list handler, which provides the 'clear' tool via getTools() when listing tools.this.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: this.getTools() }));
- The general tool call handler that dispatches to executeTool based on tool name, used for invoking 'clear'.this.server.setRequestHandler(CallToolRequestSchema, async (request) => { const { name, arguments: args } = request.params; try { this.logger.info(`Executing tool: ${name}`, args); let result = await this.executeTool(name, args); return { content: [{ type: 'text', text: typeof result === 'string' ? result : JSON.stringify(result, null, 2) }], }; } catch (error: any) { this.logger.error(`Tool execution failed: ${name}`, error); return { content: [{ type: 'text', text: `Error: ${error.message}` }], }; } });
- Helper method called by 'clear' (and write ops) to safely write patterns, handling uninitialized state.private async writePatternSafe(pattern: string): Promise<string> { if (!this.isInitialized) { // Store the pattern for later use const id = `pattern_${Date.now()}`; this.generatedPatterns.set(id, pattern); return `Pattern generated (initialize Strudel to use it): ${pattern.substring(0, 50)}...`; } return await this.controller.writePattern(pattern); }