load
Retrieve saved music patterns from storage for use in live coding sessions with Strudel.cc, enabling AI-assisted music generation and audio manipulation.
Instructions
Load saved pattern
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Pattern name |
Implementation Reference
- Main handler logic for the 'load' MCP tool. Validates input, loads pattern from store, writes it to the Strudel editor, and returns success/error message.case 'load': InputValidator.validateStringLength(args.name, 'name', 255, false); const saved = await this.store.load(args.name); if (saved) { await this.writePatternSafe(saved.content); return `Loaded pattern "${args.name}"`; } return `Pattern "${args.name}" not found`;
- src/server/EnhancedMCPServerFixed.ts:377-386 (registration)Tool registration in getTools() method, including name, description, and input schema. Used by MCP server for tool listing.name: 'load', description: 'Load saved pattern', inputSchema: { type: 'object', properties: { name: { type: 'string', description: 'Pattern name' } }, required: ['name'] } },
- Input schema definition for the 'load' tool, specifying required 'name' parameter as string.inputSchema: { type: 'object', properties: { name: { type: 'string', description: 'Pattern name' } }, required: ['name'] }
- src/PatternStore.ts:57-77 (helper)Helper method in PatternStore that loads a saved pattern from JSON file, with caching and error handling.async load(name: string): Promise<PatternData | null> { // Check cache first if (this.patternCache.has(name)) { return this.patternCache.get(name)!; } const filename = this.sanitizeFilename(name) + '.json'; const filepath = path.join(this.basePath, filename); try { const data = await fs.readFile(filepath, 'utf-8'); const pattern = JSON.parse(data); // Update cache this.patternCache.set(name, pattern); return pattern; } catch (error) { this.logger.warn(`Failed to load pattern: ${name}`, error); return null; }