Skip to main content
Glama

get_pattern

Retrieve the current music pattern code from Strudel for live coding, editing, or analysis in TidalCycles/Strudel environments.

Instructions

Get current pattern code

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Handler case in executeTool switch for the 'get_pattern' tool, delegating to getCurrentPatternSafe()
    case 'get_pattern': return await this.getCurrentPatternSafe();
  • Core handler logic in StrudelController.getCurrentPattern(): reads current pattern from Strudel.cc CodeMirror editor via Playwright, with caching
    async getCurrentPattern(): Promise<string> { if (!this._page) throw new Error('Browser not initialized. Run init tool first.'); // Return cached value if still valid const now = Date.now(); if (this.editorCache && (now - this.cacheTimestamp) < this.CACHE_TTL) { return this.editorCache; } const pattern = await this._page.evaluate(() => { const editor = document.querySelector('.cm-content') as HTMLElement; if (editor) { const view = (editor as any).__view; if (view && view.state && view.state.doc) { return view.state.doc.toString(); } } return ''; }); // Update cache this.editorCache = pattern; this.cacheTimestamp = now; return pattern; }
  • Registration of 'get_pattern' tool in getTools() array, including schema and description
    { name: 'get_pattern', description: 'Get current pattern code', inputSchema: { type: 'object', properties: {} } },
  • Helper method getCurrentPatternSafe() that provides fallback for uninitialized browser state
    private async getCurrentPatternSafe(): Promise<string> { if (!this.isInitialized) { // Return the last generated pattern if available const lastPattern = Array.from(this.generatedPatterns.values()).pop(); return lastPattern || ''; } try { return await this.controller.getCurrentPattern(); } catch (e) { return ''; } }
  • Input schema for get_pattern tool: empty object (no parameters required)
    inputSchema: { type: 'object', properties: {} }

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