set_tempo
Adjust the playback speed of a MIDI file by setting its tempo in beats per minute (BPM).
Instructions
Set tempo for midi file
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filePath | Yes | Absoulate File Path to midi file | |
| bpm | Yes | BPM |
Implementation Reference
- src/main.ts:74-86 (handler)Handler function that loads the MIDI file using loadMidiFile, sets the tempo on the header with bpm, saves the modified file with saveMidiFile, 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}`, }, ] } })
- src/main.ts:70-73 (schema)Input schema defined with Zod for filePath (string) and bpm (number).{ 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 using McpServer's tool method, including name, description, input schema, and 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}`, }, ] } }) )