Skip to main content
Glama

add_track

Create a new track in a MIDI file and retrieve track details. Specify the absolute file path to integrate additional tracks into your MIDI composition.

Instructions

Add a new track to midi file and return the new track info

Input Schema

NameRequiredDescriptionDefault
filePathYesAbsoulate File Path to midi file

Input Schema (JSON Schema)

{ "$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "properties": { "filePath": { "description": "Absoulate File Path to midi file", "type": "string" } }, "required": [ "filePath" ], "type": "object" }

Implementation Reference

  • src/main.ts:310-333 (registration)
    Registration of the 'add_track' tool, including input schema (filePath: string), description, and the handler function that loads the MIDI file, adds a new track, saves the file, and returns the new track as JSON.
    server.tool( 'add_track', 'Add a new track to midi file and return the new track info', { filePath: z.string().describe('Absoulate File Path to midi file'), }, withErrorHandling(({ filePath }) => { // 读取文件 const midi = loadMidiFile(filePath) // 添加新轨道 const newTrack = midi.addTrack() // 保存文件 saveMidiFile(midi, filePath) return { content: [ { type: 'text', text: JSON.stringify(newTrack), }, ] } }) )
  • The handler function for 'add_track' tool: loads MIDI file using loadMidiFile, adds a new track with midi.addTrack(), saves with saveMidiFile, and returns the new track JSON.
    withErrorHandling(({ filePath }) => { // 读取文件 const midi = loadMidiFile(filePath) // 添加新轨道 const newTrack = midi.addTrack() // 保存文件 saveMidiFile(midi, filePath) return { content: [ { type: 'text', text: JSON.stringify(newTrack), }, ] } })
  • Input schema for 'add_track' tool: requires absolute filePath to the MIDI file.
    { filePath: z.string().describe('Absoulate File Path to midi file'), },

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