Skip to main content
Glama

get_controlchanges_by_index

Retrieve control change events from a specific track in a MIDI file by providing the file path and track index.

Instructions

Get controlchanges from midi file by track index

Input Schema

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

Implementation Reference

  • src/main.ts:195-215 (registration)
    Registration of the 'get_controlchanges_by_index' tool on the MCP server, including its schema definition and handler invocation.
    server.tool(
        'get_controlchanges_by_index',
        'Get controlchanges from midi file by track index',
        {
            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 controlchanges = track.toJSON().controlChanges
            return {
                content: [
                    {
                        type: 'text',
                        text: JSON.stringify(controlchanges),
                    },
                ]
            }
        })
    )
  • Handler function for 'get_controlchanges_by_index' - loads the MIDI file, retrieves the track by index, extracts control changes via track.toJSON().controlChanges, and returns them as JSON.
    withErrorHandling(({ filePath, trackIndex }) => {
        const midi = loadMidiFile(filePath)
        const track = getTrackByIndex(midi, trackIndex)
        const controlchanges = track.toJSON().controlChanges
        return {
            content: [
                {
                    type: 'text',
                    text: JSON.stringify(controlchanges),
                },
            ]
        }
    })
  • Input schema for the tool: 'filePath' (string) and 'trackIndex' (number), both defined using Zod.
    {
        filePath: z.string().describe('Absoulate File Path to midi file'),
        trackIndex: z.number().describe('Track index number'),
    },
  • Helper function 'getTrackByIndex' used by the handler to retrieve a track from the MIDI file by its index.
    export function getTrackByIndex(midi: any, trackIndex: number) {
        if (trackIndex < 0 || trackIndex >= midi.tracks.length) {
            throw new Error('Track index out of range')
        }
        return midi.tracks[trackIndex]
    }
  • Helper function 'loadMidiFile' used by the handler to read and parse the MIDI file from disk.
    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?

No annotations are provided, so the description must fully disclose behavioral traits. However, it only says 'Get controlchanges' without explaining side effects (likely none), whether it's read-only, or what happens on errors. Important details like file existence requirements or return format are omitted.

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?

The description is a single, well-structured sentence that is immediately clear. There is no extraneous information. It front-loads the key action and resource.

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 no output schema, the description should provide more context about return values, but it does not. It also lacks error handling information, file format expectations, or behavior when the track or file is invalid. For a simple tool, some completeness is missing.

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?

Schema coverage is 100% with descriptions for both filePath and trackIndex. The description adds no additional meaning beyond what the schema already provides. Thus, it meets the baseline of 3.

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 clearly states the tool retrieves controlchanges from a MIDI file by track index. It uses a specific verb (Get) and resource (controlchanges). While it doesn't explicitly differentiate from siblings like get_notes_by_index, the resource name is distinct enough for an agent to infer the purpose.

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 is provided on when to use this tool versus alternatives (e.g., get_notes_by_index). There is no mention of prerequisites, context, or exclusions. The description only states what it does, not when to use it.

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