Skip to main content
Glama
williamzujkowski

Strudel MCP Server

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: {} }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It states a read operation ('Get'), implying non-destructive behavior, but lacks details on permissions, rate limits, or what 'current' means in context. This is inadequate for a tool with zero annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with no wasted words. It is front-loaded and appropriately sized for a simple tool, making it easy for an agent to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations, no output schema, and a vague purpose, the description is incomplete. It fails to explain what 'pattern code' returns or how it relates to other pattern tools, leaving significant gaps for an agent to understand its function in context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool has 0 parameters with 100% schema description coverage, so no parameter documentation is needed. The description does not add param details, which is appropriate, earning a baseline score of 4 as it doesn't need to compensate for any gaps.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose2/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Get current pattern code' restates the tool name 'get_pattern' almost verbatim, making it tautological. While it indicates a retrieval action ('Get') and target ('pattern code'), it lacks specificity about what 'pattern code' entails or how it differs from sibling tools like 'generate_pattern' or 'compare_patterns'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives. With siblings like 'generate_pattern', 'compare_patterns', and 'validate_pattern_runtime', the description offers no context for selection, leaving the agent to infer usage based solely on the name.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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