🎵 MIDI文件MCP
](https://smithery.ai/server/@xiaolaa2/midi-file-mcp)  
A powerful MCP tool for parsing and manipulating MIDI files based on Tone.js
______________________________________________________________________
📖 引言
这是一个基于Tone.js和@tonejs/MIDI库的MIDI文件解析和操作工具,通过MCP(模型上下文协议)服务提供功能。此工具允许您轻松读取、分析和修改MIDI文件,而无需深入研究MIDI文件格式的复杂性。
✨ 特性
- 读取MIDI文件信息
- 获取和修改轨迹、注释、控制更改和俯仰弯道信息
- 设置MIDI文件速度(BPM)
- 为特定曲目添加新注释、控制更改和俯仰弯曲
- 添加新曲目
- 全面的错误处理
📥 先决条件
- 安装 Node.js:确保npx命令可以正常运行。建议从安装最新的稳定版本
🔧 用法
与MCP客户端一起使用,支持的客户端包括但不限于:
通过Smithery安装
通过以下方式自动安装Claude Desktop的MIDI文件解析器 史密瑟里:
npx -y @smithery/cli install @xiaolaa2/midi-file-mcp --client claude光标配置示例
在Cursor中配置midi文件mcp:
"midi-file-mcp": {
"command": "npx",
"args": [
"-y",
"midi-file-mcp"
]
}🎹 使用具有绝对路径的MIDI解析器MCP
MIDI解析器MCP中的所有操作都需要MIDI文件的绝对路径。这确保了该工具可以正确地定位和操作您的MIDI文件,而不管当前的工作目录如何。
示例提示
以下是一些可以与AI助手一起使用的示例提示:
- 获取MIDI文件信息:
Can you show me information about the MIDI file at D:\path\to\your\file.mid?- 分析轨迹:
Please analyze all tracks in D:\path\to\your\file.mid and tell me how many notes are in each track.- 设置温度:
Change the tempo of D:\path\to\your\file.mid to 120 BPM.- 使用笔记:
Show me all notes in track 1 of D:\path\to\your\file.mid.- 添加注释:
Add a C4 note at position 0 with a duration of 1 beat to track 0 in D:\path\to\your\file.mid.可用操作
| 操作 | 说明 | 参数 |
|---|---|---|
| get_midi_info | 获取常规midi文件信息 | filePath |
| set_tempo | 设置MIDI文件的节奏(BPM) | filePath,BPM |
| get_tracks_info | 获取所有曲目的信息 | filePath |
| get_track_info_by_index | 获取特定曲目的信息 | filePath,trackIndex |
| get_notes_by_index | 从特定曲目中获取所有笔记 | filePath,trackIndex |
| get_pitchbends_by_index | 从特定轨迹获取所有俯仰弯曲 | filePath,trackIndex |
| get_controlchanges_by_index | 从特定轨道获取所有控制更改 | filePath,trackIndex |
| add_notes_by_index | 向特定曲目添加注释 | filePath、trackIndex、注释 |
| add_controlchanges_by_index | 将控件更改添加到特定轨道 | filePath、trackIndex、controlchanges |
| add_pitchbends_by_index | 向特定轨迹添加俯仰弯曲 | filePath、trackIndex、俯仰弯曲 |
| add_track | 向MIDI文件添加新曲目 | filePath |
备注:始终使用双反睫毛(\\)或正斜杠(/)在使用Windows路径时,请在文件路径中添加,以避免错误。
📄 许可证
该项目根据MIT许可证获得许可。有关详细信息,请参阅LICENSE文件。
🙏 致谢
得益于以下项目和库,没有它们,此工具就不可能实现:
- Tone.js -Web音频框架
- @tonejs/midi -MIDI文件解析和操作库
- MCP(模型上下文协议) -使工具集成到AI助手中成为可能
