Skip to main content
Glama

append

Add code snippets to existing patterns in Strudel MCP Server for AI-driven music generation and live coding. Simplify pattern modification and extend functionality.

Instructions

Append code to current pattern

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYesCode to append

Implementation Reference

  • Handler for the 'append' tool: retrieves the current pattern, appends the provided code with a newline, and writes the updated pattern using safe methods.
    case 'append': const current = await this.getCurrentPatternSafe(); return await this.writePatternSafe(current + '\n' + args.code);
  • Tool schema definition for 'append', including name, description, and input schema requiring a 'code' string parameter.
    { name: 'append', description: 'Append code to current pattern', inputSchema: { type: 'object', properties: { code: { type: 'string', description: 'Code to append' } }, required: ['code'] } },
  • Helper method used by append handler to safely retrieve the current pattern, handling uninitialized state.
    private async getCurrentPatternSafe(): Promise<string> { if (!this.isInitialized) { // Return the last generated pattern if available const lastPattern = Array.from(this.generatedPatterns.values()).pop(); return lastPattern || ''; } try { return await this.controller.getCurrentPattern(); } catch (e) { return ''; } }
  • Helper method used by append handler to safely write the updated pattern, storing if not initialized.
    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); }
  • Registration of tool list handler, which includes the 'append' tool via getTools().
    this.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: this.getTools() }));

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/williamzujkowski/strudel-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server