compose
Generate and play complete music patterns in one step for genres like techno, house, or ambient. Auto-initializes browser for Strudel.cc live coding with customizable tempo, key, and playback.
Instructions
Generate, write, and play a complete pattern in one step. Auto-initializes browser if needed.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| style | Yes | Genre: techno, house, dnb, ambient, trap, jungle, jazz, experimental | |
| tempo | No | BPM (default: genre-appropriate) | |
| key | No | Musical key (default: C) | |
| auto_play | No | Start playback immediately (default: true) |
Implementation Reference
- Handler for the 'compose' tool: validates inputs, auto-initializes browser if needed, generates complete pattern via PatternGenerator, writes to editor, plays if requested, returns success with preview and metadata.case 'compose': InputValidator.validateStringLength(args.style, 'style', 100, false); if (args.key) { InputValidator.validateRootNote(args.key); } if (args.tempo !== undefined) { InputValidator.validateBPM(args.tempo); } // Auto-initialize if needed if (!this.isInitialized) { await this.controller.initialize(); this.isInitialized = true; } // Generate pattern const composedPattern = this.generator.generateCompletePattern( args.style, args.key || 'C', args.tempo || this.getDefaultTempo(args.style) ); // Write pattern await this.controller.writePattern(composedPattern); // Auto-play by default (unless explicitly set to false) const shouldPlay = args.auto_play !== false; if (shouldPlay) { await this.controller.play(); } return { success: true, pattern: composedPattern.substring(0, 200) + (composedPattern.length > 200 ? '...' : ''), metadata: { style: args.style, bpm: args.tempo || this.getDefaultTempo(args.style), key: args.key || 'C' }, status: shouldPlay ? 'playing' : 'ready', message: `Created ${args.style} pattern in ${args.key || 'C'}${shouldPlay ? ' - now playing' : ''}` };
- Schema definition for 'compose' tool including input parameters: style (required), tempo, key, auto_play.{ name: 'compose', description: 'Generate, write, and play a complete pattern in one step. Auto-initializes browser if needed.', inputSchema: { type: 'object', properties: { style: { type: 'string', description: 'Genre: techno, house, dnb, ambient, trap, jungle, jazz, experimental' }, tempo: { type: 'number', description: 'BPM (default: genre-appropriate)' }, key: { type: 'string', description: 'Musical key (default: C)' }, auto_play: { type: 'boolean', description: 'Start playback immediately (default: true)' } }, required: ['style'] } }
- src/server/EnhancedMCPServerFixed.ts:571-573 (registration)Registration of tool list handler which includes the 'compose' tool via getTools().this.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: this.getTools() }));