npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

mcp-ai-music

v1.0.23

Published

AI作曲MCP服务 - 基于Suno4.5 API的音乐生成、翻唱、扩展和进度查询工具

Readme

AI作曲 MCP 服务

版本 (Version): 1.0.0

描述 (Description)

mcp-ai-music 是一个基于 Suno4.5 API 的 AI 作曲 MCP 服务,提供音乐生成、翻唱、扩展和进度查询功能。该服务支持多种音乐风格,可以生成原创音乐、对现有音乐进行翻唱转换,以及扩展音乐长度。

功能特点

  • 原创音乐生成:根据提示词和风格生成全新的音乐作品
  • 音乐翻唱:将现有音乐转换为不同风格,保留核心旋律
  • 音乐扩展:在保持原始风格的基础上延长音乐时长
  • 实时进度查询:支持轮询查询任务进度,实时了解生成状态
  • 多模型支持:支持 V3_5、V4、V4_5 多个AI模型版本
  • 纯音乐模式:支持生成无歌词的纯音乐版本

环境配置

重要:请配置以下必填环境变量:

  • SUNO_API_KEY:Suno API 密钥
  • SUNO_SERVICE_BASE:服务网关地址,默认 https://www.mcpcn.cc

费用说明

  • 生成音乐:¥0.438/次
  • 翻唱音乐:¥0.438/次
  • 扩展音乐:¥0.438/次
  • 查询进度:免费

使用方法

{
  "mcpServers": {
    "mcp-ai-music": {
      "command": "node",
      "args": [
        "dist/index.js"
      ],
      "env": {
        "SUNO_API_KEY": "您的Suno API密钥",
        "SUNO_SERVICE_BASE": "https://www.mcpcn.cc/api"
      },
      "autoApprove": [
        "generate_music",
        "cover_music", 
        "extend_music",
        "query_progress"
      ]
    }
  }
}

可用工具 (Available Tools)

该服务提供以下4个工具:

1. generate_music - 生成音乐

生成原创音乐作品。

输入参数:

  • prompt (必需): 音乐描述提示词,详细描述想要的音乐风格、情感、乐器等
    • V3_5/V4 模型:最多 3000 字符
    • V4_5 模型:最多 5000 字符
  • style (可选): 音乐风格,如"古典"、"流行"、"摇滚"等
    • V3_5/V4 模型:最多 200 字符
    • V4_5 模型:最多 1000 字符
  • title (可选): 音乐标题,最多 80 字符
  • instrumental (可选): 是否生成纯音乐(无歌词),默认 false
  • model (可选): AI模型版本,可选 "V3_5"、"V4"、"V4_5",默认 "V4_5"
  • negativeTags (可选): 负面标签,描述不想要的音乐元素

调用示例:

{
  "name": "generate_music",
  "arguments": {
    "prompt": "一段平静舒缓的钢琴曲,带有柔和的旋律,适合冥想和放松",
    "style": "古典",
    "title": "宁静钢琴冥想",
    "instrumental": true,
    "model": "V4_5",
    "negativeTags": "重金属, 强节奏鼓点"
  }
}

2. cover_music - 翻唱音乐

将现有音乐转换为新的风格,保留核心旋律。

输入参数:

  • uploadUrl (必需): 要翻唱的音频文件URL,音频长度不超过2分钟
  • prompt (必需): 翻唱风格描述
  • style (可选): 目标音乐风格
  • title (可选): 翻唱版本标题
  • instrumental (可选): 是否生成纯音乐版本,默认 false
  • model (可选): AI模型版本,默认 "V4_5"
  • negativeTags (可选): 负面标签

调用示例:

{
  "name": "cover_music",
  "arguments": {
    "uploadUrl": "https://example.com/audio.mp3",
    "prompt": "将这首歌转换为爵士风格",
    "style": "爵士",
    "title": "爵士翻唱版",
    "instrumental": false
  }
}

3. extend_music - 扩展音乐

在保留原始音频风格的同时扩展音轨长度。

输入参数:

  • uploadUrl (必需): 要扩展的音频文件URL,音频长度不超过2分钟
  • prompt (必需): 扩展描述,如"用更多舒缓的音符延长音乐"
  • continueAt (必需): 从音频的第几秒开始扩展,必须大于0且小于音频总时长
  • style (可选): 保持的音乐风格
  • title (可选): 扩展版本标题
  • instrumental (可选): 是否生成纯音乐版本,默认 false
  • model (可选): AI模型版本,必须与源音乐保持一致,默认 "V4_5"
  • negativeTags (可选): 负面标签

调用示例:

{
  "name": "extend_music",
  "arguments": {
    "uploadUrl": "https://example.com/audio.mp3",
    "prompt": "用更多舒缓的音符延长音乐,保持原有的宁静氛围",
    "continueAt": 60,
    "style": "古典",
    "title": "宁静钢琴延长版",
    "instrumental": true
  }
}

4. query_progress - 查询进度

查询音乐生成任务的进度状态。

重要提示:由于AI生成音乐需要时间,大模型需要轮询此接口来获取任务状态和结果。建议每10-30秒查询一次,直到状态为'complete'或'failed'。

输入参数:

  • taskId (必需): 音乐生成任务的ID(从其他工具的返回结果中获取)

调用示例:

{
  "name": "query_progress",
  "arguments": {
    "taskId": "task_12345"
  }
}

状态说明:

  • processing: 正在处理中
  • text: 文本生成完成,正在生成音频
  • first: 第一首音乐生成完成
  • complete: 任务完成
  • failed: 任务失败

工作流程示例

生成原创音乐的完整流程:

  1. 发起生成请求
{
  "name": "generate_music",
  "arguments": {
    "prompt": "一首欢快的流行歌曲,适合夏天",
    "style": "流行",
    "title": "夏日阳光"
  }
}
  1. 获取任务ID
{
  "taskId": "task_abc123",
  "status": "pending",
  "message": "音乐生成任务已提交,请使用query_progress工具查询进度。",
  "cost": "¥0.438"
}
  1. 轮询查询进度
{
  "name": "query_progress",
  "arguments": {
    "taskId": "task_abc123"
  }
}
  1. 获取最终结果 当状态变为'complete'时,会返回包含音乐文件信息的完整结果。

注意事项

也需要设置 SUNO_SERVICE_BASE(默认 https://www.mcpcn.cc),否则将无法正常访问服务。

  1. API密钥安全:请确保 SUNO_API_KEY 环境变量已正确设置,不要在代码中硬编码API密钥。

  2. 文件大小限制:上传的音频文件长度不得超过2分钟。

  3. 文件保存期限:生成的音乐文件在服务器上保留15天后会被删除。

  4. 费用控制:每次调用生成、翻唱、扩展功能都会产生¥0.438的费用,请合理使用。

  5. 轮询间隔:建议查询进度的间隔为10-30秒,避免过于频繁的请求。

  6. 模型兼容性:在扩展音乐时,使用的模型版本必须与源音乐的生成模型保持一致。

  7. 字符限制:请注意各个参数的字符长度限制,超出限制会导致请求失败。

错误处理

服务会返回详细的错误信息,包括:

  • 参数验证错误
  • API请求失败
  • 字符长度超限
  • 任务状态异常

所有错误都会在响应中通过 isError 字段标识,并在 errorMessage 字段中提供具体的错误描述。

技术实现

  • 基于 Model Context Protocol (MCP) SDK 构建
  • 使用 Suno4.5 API 进行音乐生成
  • 支持 TypeScript 开发
  • 提供完整的类型定义和输入验证

开发和构建

# 安装依赖
npm install

# 开发模式运行
npm run dev

# 构建项目
npm run build

# 启动服务
npm start