Skip to main content
Glama

sc_execute

Execute raw SuperCollider code for advanced audio synthesis control, custom SynthDef creation, and specialized sound generation tasks.

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

  • Handler for the sc_execute tool: validates arguments using Zod, checks if SC server is booted, executes the code via scServer.executeCode, and returns the result or success message.
    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' }], }; }
  • Input schema definition for sc_execute tool, specifying a required 'code' string parameter.
    inputSchema: { type: 'object', properties: { code: { type: 'string', description: 'The SuperCollider code to execute', }, }, required: ['code'], },
  • src/index.ts:68-81 (registration)
    Registration of the sc_execute tool in the MCP tools array.
    { 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'], }, },
  • Supporting method in SuperColliderServer class that sends the provided SC code to the sclang process stdin, captures stdout/stderr, and returns the output after a short 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); }); }

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