get_tracks_info
Extract detailed track information from MIDI files by providing the file path. Use this feature to analyze and understand the structure of MIDI tracks for processing or modification.
Instructions
Get tracks info from midi file
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filePath | Yes | Absoulate File Path to midi file eg: D:programmingProjectmy-projectmidi-parser-mcp est.mid |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"filePath": {
"description": "Absoulate File Path to midi file \n eg: D:programmingProjectmy-projectmidi-parser-mcp\test.mid",
"type": "string"
}
},
"required": [
"filePath"
],
"type": "object"
}
Implementation Reference
- src/main.ts:96-117 (handler)The core handler logic for the get_tracks_info tool. It loads the MIDI file using loadMidiFile, iterates over all tracks, extracts key information (name, instrument, channel, timings, note count), and returns a JSON-stringified array of track info objects wrapped in the MCP response format.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 definition using Zod for the get_tracks_info tool, specifying the required 'filePath' parameter with description and example.{ filePath: z.string().describe(`Absoulate File Path to midi file eg: D:\programming\Project\my-project\midi-parser-mcp\test.mid`), },
- src/main.ts:89-118 (registration)Registration of the get_tracks_info tool on the MCP server, including name, description, input schema, and wrapped handler function.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), }, ] } }) )