Skip to main content
Glama

get_pitchbends_by_index

Extract pitch bend data from a MIDI file for a specific track 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

  • Handler function that loads the MIDI file using loadMidiFile, retrieves the specific track using getTrackByIndex, extracts the pitchBends array from the track's JSON representation, and returns it as a JSON string in the MCP response format.
    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),
                },
            ]
        }
    })
  • src/main.ts:173-193 (registration)
    Registers the 'get_pitchbends_by_index' tool with the MCP server, including name, description, input schema, and the handler function wrapped in error handling.
    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),
                    },
                ]
            }
        })
    )
  • Input schema defined using Zod for the tool parameters: filePath (absolute path to MIDI file) and trackIndex (numeric index of the track).
    {
        filePath: z.string().describe('Absoulate File Path to midi file'),
        trackIndex: z.number().describe('Track index number'),
    },
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure but offers minimal insight. It states the tool reads pitchbends, implying a read-only operation, but doesn't specify if it requires file access permissions, how it handles invalid inputs, or what the output format looks like (e.g., list of pitchbend values). This leaves gaps in understanding the tool's behavior beyond its basic function.

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 extremely concise—a single sentence that directly states the tool's function without any fluff. It's front-loaded and wastes no words, making it easy to parse quickly. Every part of the sentence earns its place by specifying the action, resource, and key parameter.

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 the tool's moderate complexity (reading specific data from a file), no annotations, and no output schema, the description is minimally adequate but incomplete. It covers the basic purpose but lacks details on behavior, error handling, and output structure, which are important for a tool interacting with file systems and MIDI data. It meets the minimum viable threshold but has clear gaps.

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 schema description coverage is 100%, with clear documentation for both parameters ('filePath' and 'trackIndex'), so the description doesn't need to add parameter details. It mentions 'by track index' which aligns with the schema but doesn't provide additional context like valid index ranges or file format requirements, resulting in a baseline score as the schema handles the heavy lifting.

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 pitchbends') and resource ('from midi file by track index'), making the purpose immediately understandable. It distinguishes itself from siblings like 'get_notes_by_index' or 'get_controlchanges_by_index' by specifying pitchbends, but doesn't explicitly contrast with 'get_midi_info' or 'get_track_info_by_index' which might provide overlapping information.

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. It doesn't mention prerequisites like needing a valid MIDI file path or track index, nor does it compare to siblings such as 'get_midi_info' for general file details or 'get_track_info_by_index' for broader track metadata. The description assumes context without explicit direction.

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