Skip to main content
Glama

set_tempo

Set the tempo of a MIDI file by specifying the file path and BPM value.

Instructions

Set tempo for midi file

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filePathYesAbsoulate File Path to midi file
bpmYesBPM

Implementation Reference

  • src/main.ts:67-87 (registration)
    Registration and handler for the 'set_tempo' tool. Uses server.tool() to register the tool name, description, schema (filePath, bpm), and handler logic.
    server.tool(
        'set_tempo',
        'Set tempo for midi file',
        {
            filePath: z.string().describe('Absoulate File Path to midi file'),
            bpm: z.number().describe('BPM'),
        },
        withErrorHandling(({ filePath, bpm }) => {
            const midi = loadMidiFile(filePath)
            midi.header.setTempo(bpm)
            saveMidiFile(midi, filePath)
            return {
                content: [
                    {
                        type: 'text',
                        text: `Set tempo to ${bpm}`,
                    },
                ]
            }
        })
    )
  • Handler function for set_tempo: loads a MIDI file, sets the tempo via midi.header.setTempo(bpm), saves the file, and returns a success message.
    withErrorHandling(({ filePath, bpm }) => {
        const midi = loadMidiFile(filePath)
        midi.header.setTempo(bpm)
        saveMidiFile(midi, filePath)
        return {
            content: [
                {
                    type: 'text',
                    text: `Set tempo to ${bpm}`,
                },
            ]
        }
    })
  • Zod schema for set_tempo parameters: filePath (string) and bpm (number).
    {
        filePath: z.string().describe('Absoulate File Path to midi file'),
        bpm: z.number().describe('BPM'),
    },
  • Helper function 'loadMidiFile' used by the handler to read a MIDI file from disk.
    export function loadMidiFile(filePath: string) {
        const midiData = fs.readFileSync(filePath)
        const midi = new Midi(midiData)
        return midi
    }
  • Helper function 'saveMidiFile' used by the handler to write the modified MIDI file back to disk.
    export function saveMidiFile(midi: any, filePath: string): void {
        const arrayBuffer = midi.toArray()
        // 将ArrayBuffer转换为Buffer并写入文件
        fs.writeFileSync(filePath, Buffer.from(arrayBuffer))
    }
Behavior2/5

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

With no annotations, the description should disclose behavioral traits. It does not state whether the file is modified in place, whether the tempo is added or overwritten, or any side effects. This is a significant gap.

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 extremely concise at one sentence with no wasted words. However, it lacks structure and additional context, so it is efficient but not fully shaped.

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 the tool has two required parameters and no output schema, the description is insufficient. It does not explain what happens to the MIDI file, whether it returns a result, or any constraints on bpm values.

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 baseline is 3. The description adds no additional meaning beyond the schema's parameter descriptions, which are minimal (e.g., 'BPM').

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 sets the tempo for a MIDI file, with a specific verb and resource. It is distinguishable from sibling tools that deal with notes, tracks, or control changes, but doesn't elaborate on the exact scope.

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?

No guidance is provided on when to use this tool versus alternatives, nor any prerequisites or context. The description only states the basic action.

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/xiaolaa2/midi-file-mcp'

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