Skip to main content
Glama

synth-execute

Generate and execute SuperCollider SynthDef code to produce audio output with specified duration. Create custom synthesizers and play them directly from code blocks.

Instructions

SynthDefのコードを生成し、そのコードを実行して音を出します。 コードは{}でくくるようにしてください。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
synthYes再生するシンセの情報
durationNo再生時間(ミリ秒)。デフォルトは5000(5秒)

Implementation Reference

  • Handler function that initializes SuperCollider server, defines and plays the synth using provided code and name, waits for the specified duration, cleans up the server, and returns execution details or error.
    async ({ synth, duration = 5000 }) => {
      try {
        const scServer = await initServer();
    
        const def = await scServer.synthDef(synth.name, synth.code);
        await scServer.synth(def);
    
        console.error(`シンセを${duration / 1000}秒間演奏中...`);
        await new Promise(resolve => setTimeout(resolve, duration));
    
        await cleanupServer();
    
        console.error('シンセの演奏完了');
    
        return {
          content: [
            {
              type: "text",
              text: `シンセ名: ${synth.name}`,
            },
            {
              type: "text",
              text: `コード: ${synth.code}`,
            },
            {
              type: "text",
              text: `再生時間: ${duration / 1000}秒`,
            }
          ],
        };
      } catch (error) {
        console.error("SuperCollider実行エラー:", error);
        return {
          content: [
            {
              type: "text",
              text: `エラーが発生しました: ${error instanceof Error ? error.message : JSON.stringify(error, Object.getOwnPropertyNames(error), 2)}`,
            }
          ],
        };
      }
    }
  • Input schema using Zod for synth name, code, and optional duration in milliseconds.
    {
      synth: z.object({
        name: z.string().describe("シンセの名前"),
        code: z.string().describe("シンセのコード")
      }).describe("再生するシンセの情報"),
      duration: z.number().optional().describe("再生時間(ミリ秒)。デフォルトは5000(5秒)")
    },
  • src/index.ts:88-141 (registration)
    Registration of the 'synth-execute' tool using server.tool() with name, description, schema, and handler.
    server.tool(
      "synth-execute",
      `SynthDefのコードを生成し、そのコードを実行して音を出します。
      コードは{}でくくるようにしてください。`,
      {
        synth: z.object({
          name: z.string().describe("シンセの名前"),
          code: z.string().describe("シンセのコード")
        }).describe("再生するシンセの情報"),
        duration: z.number().optional().describe("再生時間(ミリ秒)。デフォルトは5000(5秒)")
      },
      async ({ synth, duration = 5000 }) => {
        try {
          const scServer = await initServer();
    
          const def = await scServer.synthDef(synth.name, synth.code);
          await scServer.synth(def);
    
          console.error(`シンセを${duration / 1000}秒間演奏中...`);
          await new Promise(resolve => setTimeout(resolve, duration));
    
          await cleanupServer();
    
          console.error('シンセの演奏完了');
    
          return {
            content: [
              {
                type: "text",
                text: `シンセ名: ${synth.name}`,
              },
              {
                type: "text",
                text: `コード: ${synth.code}`,
              },
              {
                type: "text",
                text: `再生時間: ${duration / 1000}秒`,
              }
            ],
          };
        } catch (error) {
          console.error("SuperCollider実行エラー:", error);
          return {
            content: [
              {
                type: "text",
                text: `エラーが発生しました: ${error instanceof Error ? error.message : JSON.stringify(error, Object.getOwnPropertyNames(error), 2)}`,
              }
            ],
          };
        }
      }
    );
  • Helper function to initialize and boot the SuperCollider server, ensuring singleton instance.
    async function initServer(): Promise<SCServer> {
      if (serverInitPromise) {
        return serverInitPromise;
      }
    
      serverInitPromise = (async () => {
        try {
          console.error("SuperColliderサーバーを起動中...");
          const server = await (sc as any).server.boot({
            debug: false,
            echo: false,
            stderr: './supercollider-error.log'
          }) as SCServer;
    
          console.error("SuperColliderサーバー起動完了");
          scServerInstance = server;
          return server;
        } catch (err) {
          console.error("SuperColliderサーバー起動エラー:", err);
          serverInitPromise = null;
          throw err;
        }
      })();
    
      return serverInitPromise!;
    }
  • Helper function to quit the SuperCollider server, reset state, and kill processes if necessary.
    async function cleanupServer() {
      if (scServerInstance) {
        try {
          await scServerInstance.quit();
    
          scServerInstance = null;
          serverInitPromise = null;
          activeSynths = [];
    
          try {
            if (process.platform === 'win32') {
              require('child_process').execSync('taskkill /F /IM sclang.exe', { stdio: 'ignore' });
            } else {
              require('child_process').execSync('pkill -f sclang', { stdio: 'ignore' });
            }
          } catch (killErr) {
            console.error('sclangプロセス終了試行:', killErr);
          }
    
          console.error('SuperColliderサーバーを終了しました');
        } catch (error) {
          console.error("サーバー終了エラー:", error);
        }
      }
    }
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions code generation and sound execution but lacks critical behavioral details: whether this is a read-only or mutating operation, what permissions might be needed, whether it has side effects, what happens on failure, or any rate limits. The description states what the tool does but not how it behaves operationally.

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 appropriately concise with two sentences that each serve a purpose: the first states the core functionality, the second provides a formatting requirement. It's front-loaded with the main purpose. While efficient, it could potentially benefit from slightly more context given the complexity of audio synthesis execution.

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 tool that executes code to produce sound (potentially complex with side effects), the description is insufficiently complete. It doesn't explain what happens after execution, error conditions, return values, or system implications. For a code execution tool in an audio context, more behavioral context is needed for safe and effective use.

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%, providing good documentation for both parameters (synth object with name/code, and duration with default). The description adds minimal parameter semantics beyond the schema - it mentions code wrapping in {} which relates to the 'code' parameter but doesn't elaborate on format or constraints. This meets the baseline for high schema coverage where the schema does most of the work.

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 tool's purpose: 'SynthDefのコードを生成し、そのコードを実行して音を出します' (Generate SynthDef code and execute that code to produce sound). It specifies both the generation and execution actions with the resource being sound/synth. However, it doesn't explicitly differentiate from its sibling 'multi-synth-execute' - while 'execute' vs 'multi-execute' suggests single vs multiple, this distinction isn't stated in the description itself.

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?

The description provides minimal usage guidance: 'コードは{}でくくるようにしてください' (Wrap code in {}). This gives a formatting requirement but no context about when to use this tool versus alternatives like 'multi-synth-execute'. There's no mention of prerequisites, appropriate scenarios, or explicit exclusions. The guidance is purely syntactic rather than contextual.

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/Synohara/supercollider-mcp'

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