get_tracks_info
Extract track information from MIDI files to analyze musical structure and content for editing or processing purposes.
Instructions
Get tracks info from midi file
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filePath | Yes | Absoulate File Path to midi file eg: D:programmingProjectmy-projectmidi-parser-mcp est.mid |
Implementation Reference
- src/main.ts:89-118 (registration)Registration of the 'get_tracks_info' MCP tool, including inline Zod input schema for filePath and the handler function that loads the MIDI file with loadMidiFile, extracts track information (name, instrument, channel, timings, note count), and returns it as JSON text content.server.tool( 'get_tracks_info', 'Get tracks info from midi file', { filePath: z.string().describe(`Absoulate File Path to midi file eg: D:\programming\Project\my-project\midi-parser-mcp\test.mid`), }, withErrorHandling(({ filePath }) => { const midi = loadMidiFile(filePath) const tracksInfo = midi.tracks.map(track => { return { name: track.name, instrument: track.instrument.toJSON(), channel: track.channel, endOfTrackTicks: track.endOfTrackTicks, duration: track.duration, durationTicks: track.durationTicks, noteCount: track.notes.length, } }) return { content: [ { type: 'text', text: JSON.stringify(tracksInfo), }, ] } }) )
- src/main.ts:96-117 (handler)The core handler function (wrapped by withErrorHandling utility) that implements the tool logic: loads the MIDI file, maps over all tracks to collect key info, and formats as JSON response.withErrorHandling(({ filePath }) => { const midi = loadMidiFile(filePath) const tracksInfo = midi.tracks.map(track => { return { name: track.name, instrument: track.instrument.toJSON(), channel: track.channel, endOfTrackTicks: track.endOfTrackTicks, duration: track.duration, durationTicks: track.durationTicks, noteCount: track.notes.length, } }) return { content: [ { type: 'text', text: JSON.stringify(tracksInfo), }, ] } })
- src/main.ts:92-95 (schema)Input schema defined using Zod: requires 'filePath' as a string with description including example path.{ filePath: z.string().describe(`Absoulate File Path to midi file eg: D:\programming\Project\my-project\midi-parser-mcp\test.mid`), },