Skip to main content
Glama

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'], },

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