Integrations
Supports playing notes using MIDI note numbers (0-127), enabling programmatic music composition through standard MIDI note representations.
Required as a prerequisite for running the MCP server, which enables communication between AI tools and Sonic Pi.
Allows execution of Ruby code in Sonic Pi, enabling music creation and control through Ruby's syntax and Sonic Pi's musical capabilities.
Sonic Pi MCP
模型上下文协议 (MCP) 服务器允许 AI 助手通过 OSC 消息与 Sonic Pi 进行交互。这使得 Claude 和 Cursor 等 AI 工具能够以编程方式创作音乐并控制 Sonic Pi。
特征
- 使用可自定义的合成器参数演奏单个音符
- 执行任意 Sonic Pi 代码
- 可与任何 MCP 兼容客户端(Claude Desktop、Cursor 等)配合使用
先决条件
Sonic Pi 配置
在使用 MCP 服务器之前,您需要将以下代码添加到 Sonic Pi 缓冲区。此代码用于处理服务器发送的 OSC 消息:
Copy
在使用 MCP 服务器之前,请确保此代码在 Sonic Pi 中运行。
与客户整合
光标
添加到~/.cursor/mcpServers.json
:
Copy
克劳德桌面
添加到 Claude 的 MCP 配置:
Copy
可用工具
播放笔记
播放具有可自定义参数的单个音符。
参数:
note
(必填):MIDI 音符编号(0-127)synth
(可选):要使用的合成器(例如“:saw”、“:beep”、“:prophet”)sustain
(可选):音符持续时间(以秒为单位)(默认值:1)cutoff
(可选):滤波器截止频率(默认值:100)
例子:
Copy
运行代码
执行任意 Sonic Pi 代码。
参数:
code
(必需):要执行的 Sonic Pi 代码
例子:
Copy
示例用法
以下是使用 MCP 工具的一些交互示例:
简单的旋律
Copy
复杂模式
Copy
故障排除
- 无声音
- 确保 Sonic Pi 正在运行
- 检查 OSC 处理程序代码是否在 Sonic Pi 中运行
- 验证 Sonic Pi 是否正在监听端口 4560(默认)
- 连接错误
- 检查服务器的另一个实例是否正在运行
- 重启Sonic Pi
- 确保没有其他应用程序正在使用端口 4560
- 代码执行错误
- 检查 Sonic Pi 日志窗口中的错误消息
- 验证 Sonic Pi 代码的语法
- 确保所有必需的合成器和样本都可用
发展
Copy
使用 MCP Inspector 进行测试
- 打开浏览器并导航至http://localhost:3000
- 在 MCP Inspector UI 中,配置连接:
- 命令:
node
- 参数:
dist/server.mjs
- 工作目录:
/path/to/your/sonic-pi-mcp
(使用您的实际项目路径) - 传输类型:stdio
- 命令:
- 测试
play_note
工具:
Copy
- 测试
run_code
工具:
Copy
- 检查 Sonic Pi 日志窗口是否有任何错误消息或输出
解决开发问题
- 构建错误
- 运行
npm run build
并检查 TypeScript 错误 - 确保所有依赖项都正确安装
- 检查
tsconfig.json
是否配置正确
- 运行
- MCP 检查器连接问题
- 验证服务器正在运行(
npm run dev
) - 检查工作目录路径是否正确
- 确保服务器没有其他实例正在运行
- 验证服务器正在运行(
- OSC 通信问题
- 确认 Sonic Pi 正在运行并且 OSC 处理程序代码处于活动状态
- 检查服务器日志是否存在连接错误
- 验证端口 4560 可用且未被阻止
贡献
- 分叉存储库
- 创建你的功能分支(
git checkout -b feature/amazing-feature
) - 提交您的更改(
git commit -m 'Add some amazing feature'
) - 推送到分支(
git push origin feature/amazing-feature
) - 打开拉取请求
执照
该项目根据 MIT 许可证获得许可 - 有关详细信息,请参阅LICENSE文件。
Related MCP Servers
- AsecurityFlicenseAqualityA lightweight Model Context Protocol server that enables AI assistants like Cursor & Claude to control Spotify playback and manage playlists.Last updated -1249TypeScript
- -securityFlicense-qualityA Model Context Protocol server that enables AI assistants like Claude to interact with Spotify, allowing them to search for tracks, control playback, and manage playlists.Last updated -TypeScript
- -securityAlicense-qualityA Model Context Protocol implementation that plays sound effects (completion, error, notification) for Cursor AI and other MCP-compatible environments, providing audio feedback for a more interactive coding experience.Last updated -PythonMIT License
- AsecurityAlicenseAqualityA Model Context Protocol server that enables real-time interaction with Ableton Live, allowing AI assistants to control song creation, track management, clip operations, and audio recording workflows.Last updated -23396TypeScriptMIT License