Skip to main content
Glama
williamzujkowski

Strudel MCP Server

init

Initialize Strudel in the browser to enable AI-powered music generation and live coding for creating TidalCycles patterns.

Instructions

Initialize Strudel in browser

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Registration of the 'init' tool in the getTools() method, including name, description, and empty input schema (no parameters required).
    {
      name: 'init',
      description: 'Initialize Strudel in browser',
      inputSchema: { type: 'object', properties: {} }
    },
  • Input schema for 'init' tool: empty object, no input parameters required.
    inputSchema: { type: 'object', properties: {} }
  • Handler implementation in executeTool switch statement: calls StrudelController.initialize(), sets isInitialized=true, and writes any pending generated patterns.
    case 'init':
      const initResult = await this.controller.initialize();
      this.isInitialized = true;
      
      // Write any pending patterns
      if (this.generatedPatterns.size > 0) {
        const lastPattern = Array.from(this.generatedPatterns.values()).pop();
        if (lastPattern) {
          await this.controller.writePattern(lastPattern);
          return `${initResult}. Loaded generated pattern.`;
        }
      }
      return initResult;
  • Core initialization logic delegated by MCP handler: launches headless Chromium browser, navigates to strudel.cc, optimizes loading, sets up console monitoring and audio analyzer.
    async initialize(): Promise<string> {
      if (this.browser) {
        return 'Already initialized';
      }
    
      this.browser = await chromium.launch({
        headless: this.isHeadless,
        args: [
          '--use-fake-ui-for-media-stream',
          '--disable-dev-shm-usage',
          '--no-sandbox',
          '--disable-setuid-sandbox',
          '--disable-gpu',
          '--disable-software-rasterizer'
        ],
      });
    
      const context = await this.browser.newContext({
        permissions: ['microphone'],
        viewport: { width: 1280, height: 720 },
        reducedMotion: 'reduce',
      });
    
      this._page = await context.newPage();
    
      // Optimize page loading
      await this._page.route('**/*', (route) => {
        const resourceType = route.request().resourceType();
        // Block unnecessary resources
        if (['image', 'font', 'media'].includes(resourceType)) {
          route.abort();
        } else {
          route.continue();
        }
      });
    
      await this._page.goto('https://strudel.cc/', {
        waitUntil: 'domcontentloaded', // Changed from networkidle for faster load
        timeout: 15000,
      });
    
      // Wait for editor with optimized timeout
      await this._page.waitForSelector('.cm-content', { timeout: 8000 });
    
      // Set up console monitoring for runtime errors
      this.setupConsoleMonitoring();
    
      await this.analyzer.inject(this._page);
    
      return 'Strudel initialized successfully';
    }
  • State flag tracking whether the browser has been initialized by the 'init' tool.
    private isInitialized: boolean = false;

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