Skip to main content
Glama

get_track_info_by_index

Retrieve detailed information about a specific track in a MIDI file by providing its index number. Get the track's name, instrument, channel, duration, and note count.

Instructions

Get track info from midi file by track index. name, instrument, channel, endOfTrackTicks, duration, durationTicks, noteCount

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filePathYesAbsoulate File Path to midi file
trackIndexYesTrack index number

Implementation Reference

  • src/main.ts:120-149 (registration)
    Tool registered with name 'get_track_info_by_index'. Uses server.tool() with a description, input schema (filePath: string, trackIndex: number), and handler wrapped in withErrorHandling.
    server.tool(
        'get_track_info_by_index',
        `Get track info from midi file by track index. 
        name, instrument, channel, endOfTrackTicks, duration, durationTicks, noteCount`,
        {
            filePath: z.string().describe('Absoulate File Path to midi file'),
            trackIndex: z.number().describe('Track index number'),
        },
        withErrorHandling(({ filePath, trackIndex }) => {
            const midi = loadMidiFile(filePath)
            const track = getTrackByIndex(midi, trackIndex)
            const trackInfo = {
                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(trackInfo),
                    },
                ]
            }
        })
    )
  • Handler function that loads the MIDI file, gets the track by index, extracts name, instrument, channel, endOfTrackTicks, duration, durationTicks, and noteCount, then returns the info as JSON.
    withErrorHandling(({ filePath, trackIndex }) => {
        const midi = loadMidiFile(filePath)
        const track = getTrackByIndex(midi, trackIndex)
        const trackInfo = {
            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(trackInfo),
                },
            ]
        }
    })
  • Input schema using Zod: filePath is a string, trackIndex is a number.
    {
        filePath: z.string().describe('Absoulate File Path to midi file'),
        trackIndex: z.number().describe('Track index number'),
    },
  • Error handling wrapper used by the tool. Catches any errors and returns an error response.
    const withErrorHandling = <T extends Record<string, any>>(handler: (args: T) => any) => {
        return async (args: T) => {
            try {
                return await handler(args)
            } catch (e) {
                return {
                    isError: true,
                    content: [
                        {
                            type: 'text',
                            text: `Error: ${e}`,
                        },
                    ]
                }
            }
        }
    }
  • Loads a MIDI file from disk using @tonejs/midi library.
    export function loadMidiFile(filePath: string) {
        const midiData = fs.readFileSync(filePath)
        const midi = new Midi(midiData)
        return midi
    }
Behavior2/5

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

Since annotations are absent, the description bears full burden. It discloses only the returned fields, not side effects, error conditions, permissions, or state changes. For a read tool, more transparency is beneficial.

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

Conciseness5/5

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

Description is two sentences: first states purpose, second lists output fields. No fluff, front-loaded, every sentence earns its place.

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

Completeness3/5

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

Given no output schema, the description lists output fields, which is helpful. It lacks error handling or prerequisite context. For a simple getter, it is adequate but not fully comprehensive.

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?

Input schema has 100% description coverage with adequate parameter descriptions. The description adds no extra parameter semantics (e.g., format or constraints) but usefully lists output fields, compensating slightly for lack of output schema.

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

Purpose5/5

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

The description clearly states the verb 'get', the resource 'track info', and the method 'by track index'. It distinguishes from siblings like 'get_tracks_info' (all tracks) and specialized 'get_*_by_index' tools.

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?

The description provides no guidance on when to use this tool versus alternatives, such as 'get_tracks_info' for all tracks or 'get_notes_by_index' for specific details. No when-not-to-use or prerequisite information.

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