Skip to main content
Glama

Play a music score

play

Plays multi-track MIDI music compositions with customizable instruments, tempo, and note arrangements for testing or listening to created scores.

Instructions

Plays a music score

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
bpmYesThe BPM of the song
midiOuputNameNoThe MIDI output name to use. Don't add unless requested.
tracksYesArray of tracks to play. - If you want to make it a drum track, set the instrumentName to 'drums'. and Use the 'drums' proprerty in notation. - Otherwise, use the 'note' property in 'notes'. - Unless asked otherwise, add 10 bars assuming 4/4 time signature. - Unless asked otherwise, make sure that each has the same number of bars. - Sometimes you make some tracks longer or shorter than others. Avoid that.

Implementation Reference

  • The main handler function for the MCP 'play' tool. It creates a Midi instance, initializes it, and calls playScore with the provided input parameters (bpm, midiOutputName, tracks). Returns a text response indicating playback.
    handler: async (
      input: PlayMusicMcpToolInput
    ): Promise<{ content: { type: "text"; text: string }[] }> => {
      const midi = new Midi();
    
      await midi.init();
    
      await midi.playScore({
        bpm: input.bpm,
        midiOuputName: input.midiOuputName,
        tracks: input.tracks as any,
      });
    
      return {
        content: [
          {
            type: "text",
            text: "Playing music score",
          },
        ],
      };
    },
  • Zod input schema for the 'play' tool defining bpm, optional midiOutputName, and tracks array with instrument, channel, and notes/drums with durations.
    const inputSchema = {
      bpm: z.number().describe("The BPM of the song"),
      midiOuputName: z
        .string()
        .optional()
        .describe("The MIDI output name to use. Don't add unless requested."),
      tracks: z
        .array(
          z.object({
            instrumentName: z
              .enum([
                "drums",
                ...(Object.keys(Instruments) as [string, ...string[]]),
              ])
              .describe(
                `The instrument of the track. Available instruments: ${Object.keys(
                  Instruments
                ).join(
                  ", "
                )}. If you want to make it a drum track, set the instrumentName to 'drums'.`
              ),
            channel: z
              .number()
              .optional()
              .describe(
                "The MIDI channel of the track. Don't add unless requested."
              ),
            notes: z
              .array(
                z.object({
                  note: z
                    .array(z.string())
                    .nullable()
                    .optional()
                    .describe(
                      "The notes to play. Use array for chords. Or put one element for single note. Use an empty array for rest/silence"
                    ),
                  drums: z
                    .array(z.string())
                    .nullable()
                    .optional()
                    .describe(
                      "The drums to play. Use array for multiple drums. Use an empty array for rest/silence. Available drums: " +
                        Object.keys(Drums).join(", ")
                    ),
                  noteDuration: z
                    .string()
                    .describe(
                      "The note duration, e.g.: 1/32, 1/16, 1/8, 1/4, 1/2, 1"
                    ),
                })
              )
              .describe(
                `"Array of notes or drums to play with timing. 
                
                - If you want to play a drum track, use the drums property. 
                - If you want to play a non-drum instrument, use the note property.
                
                Example:
                
                [{note: ['C2', 'E2'], noteDuration: '1/8'}, {note: [], noteDuration: '1/8'}, {note: ['G2'], noteDuration: '1/8'}, {note: null, noteDuration: '1/8'}]. 
                
                Or 
                
                [{drums: ['bass_drum_1', 'closed_hi_hat'], noteDuration: '1/8'}, {drums: ['closed_hi_hat'], noteDuration: '1/8'}, {drums: ['closed_hi_hat', 'acoustic_snare'], noteDuration: '1/8'}, {drums: ['closed_hi_hat'], noteDuration: '1/8'}]. 
                
                An array could be a bar or several bars.
                --------------------------------------------------------------------------------
                  
                IMPORTANT FOR FOR DRUM TRACKS:
               
                - notes are played one after another. 
                - we wait until the whole duration of a note before we play another one. 
                - So don't do this: "notes" :[{"drums: ["bass_drum_1", "closed_hi_hat"], noteDuration: '1/4'},{"drums: [ "closed_hi_hat"], noteDuration: '1/4'} {drums: ['closed_hi_hat', 'acoustic_snare'], noteDuration: '1/4'}...].`
              ),
          })
        )
        .describe(
          `Array of tracks to play.
          
          - If you want to make it a drum track, set the instrumentName to 'drums'. and Use the 'drums' proprerty in notation. 
          - Otherwise, use the 'note' property in 'notes'.
          - Unless asked otherwise, add 10 bars assuming 4/4 time signature.
          - Unless asked otherwise, make sure that each has the same number of bars.
          - Sometimes you make some tracks longer or shorter than others. Avoid that.
          `
        ),
    };
    
    const inputSchemaObject = z.object(inputSchema);
  • Registration of the 'play' tool (PlayMusicMcpTool) on the MCP server using server.registerTool with name, metadata, and handler.
    server.registerTool(
      PlayMusicMcpTool.name,
      {
        title: PlayMusicMcpTool.title,
        description: PlayMusicMcpTool.description,
        inputSchema: PlayMusicMcpTool.inputSchema,
      },
      PlayMusicMcpTool.handler
    );
  • Definition of the PlayMusicMcpTool object including name 'play', title, description, inputSchema, and handler for use in MCP registration.
    const PlayMusicMcpTool = {
      name: "play",
      title: "Play a music score",
      description: "Plays a music score",
      inputSchema,
      handler: async (
        input: PlayMusicMcpToolInput
      ): Promise<{ content: { type: "text"; text: string }[] }> => {
        const midi = new Midi();
    
        await midi.init();
    
        await midi.playScore({
          bpm: input.bpm,
          midiOuputName: input.midiOuputName,
          tracks: input.tracks as any,
        });
    
        return {
          content: [
            {
              type: "text",
              text: "Playing music score",
            },
          ],
        };
      },
    };
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 but only states the basic action ('Plays a music score'). It doesn't describe what 'playing' entails (e.g., audio output, MIDI device activation, duration, error conditions), whether it's blocking/non-blocking, or any side effects like resource consumption or permissions needed.

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

Conciseness5/5

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

The description is extremely concise with just three words, front-loading the core action without unnecessary elaboration. Every word earns its place, though this conciseness contributes to underspecification in other dimensions.

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?

For a complex tool with 3 parameters, nested objects, no annotations, and no output schema, the description is completely inadequate. It doesn't explain what 'playing' means operationally, what happens after invocation, or how to interpret results, leaving significant gaps despite the detailed schema.

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%, so the schema already documents all parameters thoroughly. The description adds no parameter information beyond what's in the schema, maintaining the baseline score of 3 where the schema does the heavy lifting without additional value from the description.

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

Purpose2/5

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

The description 'Plays a music score' is a tautology that restates the tool name 'play' and title 'Play a music score' without adding specificity. It lacks a clear verb+resource distinction and doesn't differentiate from the sibling tool 'list-midi-outputs' beyond the obvious action difference.

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 no guidance on when to use this tool versus alternatives. While the input schema includes some usage hints (e.g., 'Don't add unless requested' for parameters), the description itself offers no context about prerequisites, typical scenarios, or comparisons to the sibling tool 'list-midi-outputs'.

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/mikeborozdin/vibe-composer-midi-mcp'

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