save
Store music patterns with names and tags for reuse in TidalCycles/Strudel live coding sessions.
Instructions
Save pattern with metadata
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Pattern name | |
| tags | No |
Implementation Reference
- src/server/EnhancedMCPServerFixed.ts:365-375 (registration)Registration of the 'save' tool in getTools() array, including name, description, and input schema definition.name: 'save', description: 'Save pattern with metadata', inputSchema: { type: 'object', properties: { name: { type: 'string', description: 'Pattern name' }, tags: { type: 'array', items: { type: 'string' } } }, required: ['name'] } },
- Handler implementation in executeTool switch statement: validates args, retrieves current pattern, calls store.save, returns success message.case 'save': InputValidator.validateStringLength(args.name, 'name', 255, false); const toSave = await this.getCurrentPatternSafe(); if (!toSave) { return 'No pattern to save'; } await this.store.save(args.name, toSave, args.tags || []); return `Pattern saved as "${args.name}"`;
- src/PatternStore.ts:36-55 (helper)PatternStore.save method: persists pattern data as JSON file with metadata, updates cache, sanitizes filename.async save(name: string, content: string, tags: string[] = []): Promise<void> { await this.ensureDirectory(); const filename = this.sanitizeFilename(name) + '.json'; const filepath = path.join(this.basePath, filename); const data: PatternData = { name, content, tags, timestamp: new Date().toISOString(), }; // Update cache this.patternCache.set(name, data); this.listCache = null; // Invalidate list cache // Write file asynchronously await fs.writeFile(filepath, JSON.stringify(data, null, 2)); }