Skip to main content
Glama

get_pitchbends_by_index

Retrieves pitchbend events from a specified track in a MIDI file by providing the file path and track index.

Instructions

Get pitchbends 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:173-193 (registration)
    Tool registered with MCP server under name 'get_pitchbends_by_index'. Schema: filePath (string) and trackIndex (number). Handler loads MIDI file, gets track by index, extracts pitchBends from track.toJSON(), and returns them as JSON.
    server.tool(
        'get_pitchbends_by_index',
        'Get pitchbends 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 pitchbends = track.toJSON().pitchBends
            return {
                content: [
                    {
                        type: 'text',
                        text: JSON.stringify(pitchbends),
                    },
                ]
            }
        })
    )
  • Handler logic: loads midi file via loadMidiFile, gets track via getTrackByIndex, extracts pitchbends from track.toJSON().pitchBends, returns JSON stringified result.
        withErrorHandling(({ filePath, trackIndex }) => {
            const midi = loadMidiFile(filePath)
            const track = getTrackByIndex(midi, trackIndex)
            const pitchbends = track.toJSON().pitchBends
            return {
                content: [
                    {
                        type: 'text',
                        text: JSON.stringify(pitchbends),
                    },
                ]
            }
        })
    )
  • Helper function getTrackByIndex used by the handler to retrieve a track from the MIDI by 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.
    export function loadMidiFile(filePath: string) {
        const midiData = fs.readFileSync(filePath)
        const midi = new Midi(midiData)
        return midi
    }
  • PitchBendInterfaceSchema defines the Zod validation schema for pitchbend objects used in add_pitchbends_by_index tool (not directly used by get_pitchbends_by_index but related type).
    export const PitchBendInterfaceSchema = z.object({
        value: z.number(),
    }).and(z.union([
        z.object({
            time: z.number(),
        }),
        z.object({
            ticks: z.number(),
        })
    ]))
Behavior3/5

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

The description implies a read-only operation ('Get'), but with no annotations, it does not explicitly state safety or side effects. It lacks details on error handling or behavior for invalid inputs (e.g., non-existent file or out-of-range track index).

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

Conciseness4/5

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

The description is a single sentence with no fluff. It is concise, though slightly under-specified; could be improved without adding much length.

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?

No output schema is provided, and the description does not hint at the return format or structure. For a tool that retrieves data, this omission is significant and leaves the agent guessing about the output.

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?

Both parameters have descriptions in the schema (100% coverage). The description does not add additional meaning beyond what the schema provides, so baseline score of 3 applies.

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 action (get) and resource (pitchbends from midi file by track index). It distinguishes from sibling tools like get_notes_by_index by specifying pitchbends, but lacks detail on what exactly is returned (e.g., list of events).

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 alternatives (e.g., add_pitchbends_by_index or get_controlchanges_by_index). No prerequisites, exclusions, or context 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