Skip to main content
Glama

set_tempo

Adjust the tempo of a MIDI file by specifying the file path and desired BPM, enabling precise control over playback speed for editing or performance purposes.

Instructions

Set tempo for midi file

Input Schema

NameRequiredDescriptionDefault
bpmYesBPM
filePathYesAbsoulate File Path to midi file

Input Schema (JSON Schema)

{ "$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "properties": { "bpm": { "description": "BPM", "type": "number" }, "filePath": { "description": "Absoulate File Path to midi file", "type": "string" } }, "required": [ "filePath", "bpm" ], "type": "object" }

Implementation Reference

  • Handler function that loads the MIDI file, sets the tempo using midi.header.setTempo(bpm), saves the modified file, and returns a confirmation message.
    withErrorHandling(({ filePath, bpm }) => { const midi = loadMidiFile(filePath) midi.header.setTempo(bpm) saveMidiFile(midi, filePath) return { content: [ { type: 'text', text: `Set tempo to ${bpm}`, }, ] } })
  • Input schema using Zod validators for filePath (absolute path to MIDI file) and bpm (beats per minute).
    { filePath: z.string().describe('Absoulate File Path to midi file'), bpm: z.number().describe('BPM'), },
  • src/main.ts:67-87 (registration)
    Registration of the set_tempo tool with the MCP server using server.tool, including description, schema, and error-wrapped handler.
    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}`, }, ] } }) )

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