Skip to main content
Glama
BradA1878
by BradA1878

sc_execute

Execute raw SuperCollider code to control advanced audio synthesis or create custom SynthDefs for real-time sound generation.

Instructions

Execute raw SuperCollider code. Use this for advanced synthesis control or custom SynthDefs.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYesThe SuperCollider code to execute

Implementation Reference

  • src/index.ts:68-81 (registration)
    Registration of the 'sc_execute' tool including name, description, and input schema.
    {
      name: 'sc_execute',
      description: 'Execute raw SuperCollider code. Use this for advanced synthesis control or custom SynthDefs.',
      inputSchema: {
        type: 'object',
        properties: {
          code: {
            type: 'string',
            description: 'The SuperCollider code to execute',
          },
        },
        required: ['code'],
      },
    },
  • Handler for 'sc_execute' tool: validates input, checks server status, executes code via scServer.executeCode, returns result.
    case 'sc_execute': {
      const schema = z.object({ code: z.string() });
      const { code } = schema.parse(args);
    
      if (!scServer.getBooted()) {
        return {
          content: [{ type: 'text', text: 'Error: SuperCollider server is not running. Call sc_boot first.' }],
          isError: true,
        };
      }
    
      const result = await scServer.executeCode(code);
      return {
        content: [{ type: 'text', text: result || 'Code executed successfully' }],
      };
    }
  • Core implementation: SuperColliderServer.executeCode method sends code to sclang stdin, captures stdout/stderr after 500ms timeout.
    async executeCode(code: string): Promise<string> {
      if (!this.sclangProcess?.stdin) {
        throw new Error('SuperCollider sclang process is not running');
      }
    
      return new Promise((resolve, reject) => {
        let output = '';
        let errorOutput = '';
    
        const stdoutHandler = (data: Buffer) => {
          output += data.toString();
        };
    
        const stderrHandler = (data: Buffer) => {
          errorOutput += data.toString();
        };
    
        this.sclangProcess!.stdout?.on('data', stdoutHandler);
        this.sclangProcess!.stderr?.on('data', stderrHandler);
    
        // Send the code
        this.sclangProcess!.stdin!.write(code + '\n');
    
        // Wait for output (this is a simple approach; a more robust solution would parse responses)
        setTimeout(() => {
          this.sclangProcess!.stdout?.removeListener('data', stdoutHandler);
          this.sclangProcess!.stderr?.removeListener('data', stderrHandler);
    
          if (errorOutput) {
            reject(new Error(errorOutput));
          } else {
            resolve(output);
          }
        }, 500);
      });
    }
  • Input schema definition for sc_execute tool (MCP JSON schema).
    inputSchema: {
      type: 'object',
      properties: {
        code: {
          type: 'string',
          description: 'The SuperCollider code to execute',
        },
      },
      required: ['code'],
    },
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It mentions the action ('Execute') but lacks details on behavioral traits such as permissions needed, whether it's destructive (e.g., could stop other processes), rate limits, or error handling. This is a significant gap for a tool that executes code.

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

Conciseness4/5

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

The description is concise with two sentences, front-loading the main purpose. However, the second sentence could be more specific (e.g., explaining what 'advanced' means) to earn a higher score, but it's efficient with minimal waste.

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 the complexity of executing raw code, no annotations, and no output schema, the description is incomplete. It doesn't cover safety aspects, return values, or error conditions, which are crucial for such a tool. More context is needed to adequately guide an AI agent.

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

Parameters3/5

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

Schema description coverage is 100%, with the parameter 'code' fully described in the schema. The description adds no additional meaning beyond implying the code is for SuperCollider, which is already clear from the tool name and schema. Baseline 3 is appropriate as the schema does the heavy lifting.

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

Purpose4/5

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

The description clearly states the verb ('Execute') and resource ('raw SuperCollider code'), specifying it's for 'advanced synthesis control or custom SynthDefs.' However, it doesn't explicitly differentiate from siblings like sc_play_synth or sc_play_synth_advanced, which might also involve code execution but are more specific.

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

Usage Guidelines3/5

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

The description implies usage for 'advanced synthesis control or custom SynthDefs,' suggesting when to use it (for raw/advanced tasks) but doesn't explicitly state when not to use it or name alternatives. For example, it doesn't clarify if sc_play_synth is for simpler tasks, leaving some ambiguity.

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/BradA1878/mcp-wave'

If you have feedback or need assistance with the MCP directory API, please join our Discord server