sc_boot
Start the SuperCollider audio server to enable real-time sound synthesis and audio processing capabilities for music creation and audio experiments.
Instructions
Boot the SuperCollider audio server. Must be called before any sound synthesis.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:244-264 (handler)MCP tool handler for sc_boot: checks if server is booted, calls scServer.boot(), sets synthDefsLoaded flag, returns success message.case 'sc_boot': { if (scServer.getBooted()) { return { content: [{ type: 'text', text: 'SuperCollider server is already running' }], }; } await scServer.boot(); // Mark as loaded - we'll use inline synths instead of pre-loaded SynthDefs synthDefsLoaded = true; return { content: [ { type: 'text', text: 'SuperCollider server booted successfully. All synth definitions loaded.', }, ], }; }
- src/index.ts:44-51 (schema)Tool schema definition including name, description, and empty input schema for sc_boot.{ name: 'sc_boot', description: 'Boot the SuperCollider audio server. Must be called before any sound synthesis.', inputSchema: { type: 'object', properties: {}, }, },
- src/supercollider.ts:54-135 (helper)Core boot logic in SuperColliderServer class: validates installation, spawns sclang process, monitors stdout for readiness, sends server boot code, handles timeout and errors.async boot(): Promise<void> { log('=== BOOT CALLED ==='); if (this.isBooted) { throw new Error('SuperCollider server is already running'); } // Validate installation before attempting to boot if (!this.options.sclangPath) { const instructions = getInstallInstructions(); throw new Error(`SuperCollider not found.\n\n${instructions}`); } const validation = validateInstallation(this.options.sclangPath); if (!validation.valid) { const instructions = getInstallInstructions(); throw new Error(`${validation.error}\n\n${instructions}`); } return new Promise((resolve, reject) => { log(`Spawning sclang at: ${this.options.sclangPath}`); // Start sclang process in interactive mode // Using no flags for stdin mode this.sclangProcess = spawn(this.options.sclangPath, [], { stdio: ['pipe', 'pipe', 'pipe'], }); let bootTimeout: NodeJS.Timeout; const sclangReadyPattern = /Welcome to SuperCollider/; const scsynthBootedPattern = /SuperCollider 3 server ready|Server 'localhost' running/; let sclangReady = false; let scsynthBooted = false; this.sclangProcess.stdout?.on('data', (data) => { const output = data.toString(); this.emit('stdout', output); log(`[STDOUT] ${output}`); if (!sclangReady && sclangReadyPattern.test(output)) { sclangReady = true; log('sclang is ready, booting scsynth...'); // Boot the default server with audio configuration setTimeout(() => { if (this.sclangProcess?.stdin) { const bootCode = 's = Server.default; s.options.numOutputBusChannels = 2; s.options.numInputBusChannels = 2; s.boot;\n'; log(`Sending boot code: ${bootCode}`); this.sclangProcess.stdin.write(bootCode); } }, 500); } if (sclangReady && !scsynthBooted && (output.includes('server ready') || output.includes('Server \'localhost\' running'))) { scsynthBooted = true; this.isBooted = true; clearTimeout(bootTimeout); log('scsynth booted successfully!'); setTimeout(() => resolve(), 1000); } }); this.sclangProcess.stderr?.on('data', (data) => { const err = data.toString(); this.emit('stderr', err); log(`[STDERR] ${err}`); }); this.sclangProcess.on('error', (error) => { clearTimeout(bootTimeout); reject(new Error(`Failed to start sclang: ${error.message}`)); }); this.sclangProcess.on('exit', (code) => { this.isBooted = false; this.emit('exit', code); }); // Timeout after 30 seconds bootTimeout = setTimeout(() => { reject(new Error('SuperCollider boot timeout - check terminal for debug output')); }, 30000); }); }
- src/index.ts:200-202 (registration)Registration of the tools list handler which includes sc_boot in the returned tools array.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools, }));
- src/index.ts:16-17 (helper)Global instantiation of SuperColliderServer used by sc_boot handler.const scServer = new SuperColliderServer();