Skip to main content
Glama

get_tracks_info

Get track information from a MIDI file. Provide the absolute file path to obtain details about each track.

Instructions

Get tracks info from midi file

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filePathYesAbsoulate File Path to midi file eg: D:programmingProjectmy-projectmidi-parser-mcp est.mid

Implementation Reference

  • The handler function that executes the 'get_tracks_info' tool logic. It loads a MIDI file via loadMidiFile, maps over tracks to extract info (name, instrument, channel, endOfTrackTicks, duration, durationTicks, noteCount), and returns JSON.
    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),
                },
            ]
        }
    })
  • Zod schema defining the input parameter for the tool: 'filePath' (string) describing the absolute path to a MIDI file.
    {
        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 with the MCP server using server.tool(), including name, description, schema, and handler.
    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),
                    },
                ]
            }
        })
    )
  • Helper function loadMidiFile that reads a file from disk synchronously and parses it using the @tonejs/midi library's Midi class.
    export function loadMidiFile(filePath: string) {
        const midiData = fs.readFileSync(filePath)
        const midi = new Midi(midiData)
        return midi
    }
  • The withErrorHandling wrapper that catches errors from the handler and returns an error response with isError flag.
    const withErrorHandling = <T extends Record<string, any>>(handler: (args: T) => any) => {
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description should explain behavioral aspects. It does not mention that the file must exist, whether it only reads (no side effects), or what 'tracks info' includes (e.g., track names, numbers). The behavior is underspecified.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is very concise (one sentence) but lacks structure or detail that could aid the agent. It is front-loaded but could be improved with more information without being verbose.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given that there is no output schema, the description should explain what the tool returns (e.g., an array of track objects). It does not, leaving the agent uninformed about the return format. This is a significant gap.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema covers 100% of parameters with a description for filePath. The tool description adds no further meaning beyond the schema's description, so baseline 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Get tracks info from midi file' clearly states the action and resource. It implicitly refers to all tracks, distinguishing it from sibling 'get_track_info_by_index' which gets info for a single track, but this differentiation is not explicit.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool versus siblings like 'get_track_info_by_index' or 'get_midi_info'. No context about prerequisites or alternatives is provided.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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