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
| Name | Required | Description | Default |
|---|---|---|---|
| bpm | Yes | BPM | |
| filePath | Yes | Absoulate 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
- src/main.ts:74-86 (handler)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}`, }, ] } })
- src/main.ts:70-73 (schema)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}`, }, ] } }) )