Skip to main content
Glama

validate_pattern_runtime

Validate Strudel music patterns by checking for runtime errors during execution, ensuring code runs correctly before live performance.

Instructions

Validate pattern with runtime error checking (monitors Strudel console for errors)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
patternYesPattern code to validate
waitMsNoHow long to wait for errors (default 500ms)

Implementation Reference

  • Main handler function that executes the runtime pattern validation by writing the pattern to the editor, briefly playing it to trigger evaluation, capturing console errors and warnings from Strudel.
    async validatePatternRuntime(pattern: string, waitMs: number = 500): Promise<{ valid: boolean; errors: string[]; warnings: string[]; }> { if (!this._page) { throw new Error('Browser not initialized. Run init tool first.'); } // Clear previous errors this.clearConsoleMessages(); // Write pattern await this.writePattern(pattern); // Brief play to trigger evaluation - Strudel uses lazy evaluation // so errors only appear when the pattern is actually executed try { await this._page.keyboard.press('ControlOrMeta+Enter'); await this._page.waitForTimeout(Math.min(waitMs, 300)); await this._page.keyboard.press('ControlOrMeta+Period'); } catch (e) { this.logger.warn('Failed to trigger pattern evaluation', e); } // Wait for potential errors to appear await this._page.waitForTimeout(waitMs); const errors = this.getConsoleErrors(); const warnings = this.getConsoleWarnings(); return { valid: errors.length === 0, errors, warnings }; }
  • Tool registration in the getTools() array, including name, description, and input schema definition.
    name: 'validate_pattern_runtime', description: 'Validate pattern with runtime error checking (monitors Strudel console for errors)', inputSchema: { type: 'object', properties: { pattern: { type: 'string', description: 'Pattern code to validate' }, waitMs: { type: 'number', description: 'How long to wait for errors (default 500ms)' } }, required: ['pattern'] } },
  • Tool dispatch handler in the executeTool switch statement that calls the controller's validatePatternRuntime method and formats the response.
    case 'validate_pattern_runtime': if (!this.isInitialized) { return 'Browser not initialized. Run init first.'; } InputValidator.validateStringLength(args.pattern, 'pattern', 10000, false); const validation = await this.controller.validatePatternRuntime( args.pattern, args.waitMs || 500 ); if (validation.valid) { return `✅ Pattern valid - no runtime errors detected`; } else { return `❌ Pattern has runtime errors:\n${validation.errors.join('\n')}\n` + (validation.warnings.length > 0 ? `\nWarnings:\n${validation.warnings.join('\n')}` : ''); }

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