🎙️ supertone-mcp
面向 Supertone TTS API 的可組合 MCP 工具包。它不是單一的“朗讀這段文本”命令,而是將 Supertone SDK 暴露為一組構建塊工具——語音合成、聲音發現、試聽、時長/額度預測、用量追蹤,以及完整的聲音克隆 CRUD——由 LLM 組合調用來滿足請求。可在 Claude Desktop、Cursor 或任何兼容 MCP 的客戶端中使用。

覆蓋韓語、英語、日語,共 31 種語言。支持速度(0.5x–2.0x)、音高偏移(-24 到 +24 半音)、情感風格、每次調用的輸出模式、流式傳輸和模型選擇。
✨ 主要特性
🗣️ 語音合成
text_to_speech — 將文本轉換為音頻。可按調用控制 output_mode(files / resources / both)、autoplay、streaming、model,以及 include_phonemes / normalized_text。長文本由 SDK 自動分塊。
predict_duration — 在不合成的情況下估算音頻長度(以及額度消耗)。
🔍 聲音發現(預設)
search_voice — 按語言、性別、年齡、用例、風格、模型、名稱或描述篩選目錄。
get_voice — 獲取某個聲音的完整詳情。
preview_voice — 獲取某個聲音的示例音頻 URL(可按語言/風格/模型篩選)。
🧬 自定義聲音克隆
clone_voice — 從本地 WAV/MP3(≤3MB)創建克隆聲音。
search_custom_voice — 列出/篩選克隆聲音。
get_custom_voice — 獲取某個克隆聲音的完整詳情。
edit_custom_voice — 更新名稱和/或描述。
delete_custom_voice — 永久刪除(不可逆)。
🎧 音頻拼接
merge_audio_files — 通過內置 ffmpeg 將兩個或多個本地音頻文件(mp3/wav)拼接為一個。支持普通拼接、片段間靜音間隔(gap_ms)或交叉淡化混合(crossfade_ms)。輸出格式自動檢測(混合 → mp3),也可通過 output_format 強制指定。無需系統安裝 ffmpeg。
📊 用量與額度
get_credit_balance — 剩餘額度。
get_usage_history — 指定時間窗口內的用量。
get_voice_usage — 某個特定聲音的用量。
🚀 快速開始
📦 安裝
uvx supertone-mcp
pip install supertone-mcp
⚙️ 配置
Claude Desktop
添加到 claude_desktop_config.json:
{
"mcpServers": {
"supertone-tts": {
"command": "uvx",
"args": ["supertone-mcp"],
"env": {
"SUPERTONE_API_KEY": "your-api-key-here"
}
}
}
}
Cursor
添加到你的 Cursor MCP 設置中(JSON 結構與上方相同)。
🔐 環境變量
只有認證和穩定默認值通過環境配置——所有行為均按調用控制。
| 變量 |
必需 |
默認值 |
說明 |
SUPERTONE_API_KEY |
是 |
— |
你的 Supertone API 密鑰 |
SUPERTONE_MCP_VOICE_ID |
否 |
預設聲音(Aiden,多語言) |
text_to_speech / predict_duration 的默認 voice_id(可在每次調用中覆蓋) |
SUPERTONE_OUTPUT_DIR |
否 |
~/supertone-tts-output/ |
音頻文件保存目錄(用於 output_mode=files/both) |
0.2.0 已移除:SUPERTONE_MCP_OUTPUT_MODE 和 SUPERTONE_MCP_AUTOPLAY — 參見 0.2.0 破壞性變更與遷移。
📤 輸出模式(text_to_speech 的 output_mode)
| 模式 |
返回 |
適用場景 |
files (默認) |
純文本,包含保存的文件路徑 + 元數據 |
希望文件保存在磁盤上 |
resources |
MCP AudioContent + TextContent(不寫入文件) |
客戶端內聯渲染音頻(例如 Claude.ai 聊天) |
both |
磁盤文件 以及 AudioContent/TextContent |
二者都要——內聯試聽並保留文件 |
💻 使用示例
MCP 客戶端會在這些工具之間路由自然語言請求——工具包的價值在於組合:LLM 會串聯多個工具來滿足一個請求。
示例 1 — 發現 → 試聽 → 估算成本 → 合成
“找一位平靜的韓語女聲,讓我聽一個樣本,檢查成本,然後把這段通知做成 mp3。”
LLM 組合:
search_voice(language="ko", gender="female", style="neutral") # find candidates
→ preview_voice(voice_id) # sample URLs to confirm the voice
→ predict_duration(text, voice_id) + get_credit_balance() # gauge cost before spending
→ text_to_speech(text, voice_id, output_format="mp3",
output_mode="files") # synthesize
示例 2 — 克隆我的聲音 → 立即使用
“從 ~/recordings/sample.wav 創建一個名為 MyVoice 的克隆聲音,然後用它朗讀這段問候並播放給我聽。”
LLM 組合:
clone_voice(name="MyVoice", audio_path="~/recordings/sample.wav") # create the cloned voice
→ get_custom_voice(voice_id) # confirm it was created
→ text_to_speech(text, voice_id=<cloned>, autoplay=true) # synthesize, then play immediately
autoplay 是每次調用參數(默認 false),因此只有明確請求時才會播放。
🔄 0.2.0 破壞性變更與遷移
0.2.0 將行為控制從環境變量遷移到每次調用的工具參數——因此由 LLM 按請求決定,而不是服務器配置。
| 之前(環境變量) |
之後(每次調用參數) |
說明 |
SUPERTONE_MCP_OUTPUT_MODE=files|resources|both |
text_to_speech(output_mode=...) |
默認仍為 files |
SUPERTONE_MCP_AUTOPLAY=true |
text_to_speech(autoplay=...) |
默認值已從 true 改為 false(播放現在為顯式操作) |
| (始終流式) |
text_to_speech(streaming=...) |
新增,默認 false(一次性)。streaming=true 需要 model="sona_speech_1" |
其他變更:
- 默認模型已從
sona_speech_1 改為 sona_speech_2_flash。
list_voices 已移除(自發現版本起),並由 search_voice 替代——無參數調用它以復現舊的“列出全部”行為。
- 不再有 300 字符硬限制——更長文本由 SDK 自動分塊(額度/延遲隨長度擴展)。
如果你之前設置過 SUPERTONE_MCP_OUTPUT_MODE 或 SUPERTONE_MCP_AUTOPLAY,請從客戶端配置中移除它們,並改為在每次調用時傳入 output_mode / autoplay。(如果服務器檢測到已移除的變量,會向 stderr 打印一次性通知。)
🔧 工具參數
text_to_speech
| 參數 |
類型 |
必需 |
默認值 |
說明 |
text |
string |
是 |
— |
要轉換的文本(長文本由 SDK 自動分塊) |
voice_id |
string |
否 |
環境變量或預設 |
聲音標識符(可通過 search_voice 瀏覽) |
language |
string |
否 |
ko |
語言代碼——31 種之一(ko、en、ja、…) |
output_format |
string |
否 |
mp3 |
mp3 或 wav |
model |
string |
否 |
sona_speech_2_flash |
sona_speech_1, sona_speech_2, sona_speech_2_flash, sona_speech_2t, sona_speech_3t, supertonic_api_1, supertonic_api_3 |
speed |
float |
否 |
1.0 |
0.5–2.0 |
pitch_shift |
int |
否 |
0 |
-24 到 +24 半音 |
style |
string |
否 |
— |
情感風格(因聲音而異) |
output_mode |
string |
否 |
files |
files、resources 或 both(參見 輸出模式) |
autoplay |
bool |
否 |
false |
合成後在本地播放音頻(macOS afplay) |
streaming |
bool |
否 |
false |
流式合成。僅 model="sona_speech_1" 支持 |
include_phonemes |
bool |
否 |
false |
隨音頻一起返回音素時間數據 |
normalized_text |
string |
否 |
— |
預歸一化文本(僅由 sona_speech_2 / sona_speech_2_flash 使用) |
predict_duration
與 text_to_speech 具有相同的核心參數結構(長文本自動分塊)。返回 "Predicted duration: 2.34s (credit usage is proportional to duration)."。
search_voice
所有參數可選。無篩選 → 完整目錄。有任意篩選 → 第一行響應為 Filters applied: ...。
| 參數 |
類型 |
說明 |
language |
string |
例如 ko、en、ja |
gender |
string |
例如 male、female |
age |
string |
例如 young_adult、child |
use_case |
string |
例如 narration、advertisement |
style |
string |
例如 neutral、happy |
model |
string |
例如 sona_speech_2_flash |
name |
string |
部分匹配 |
description |
string |
部分匹配 |
get_voice / preview_voice
| 工具 |
必需 |
可選 |
get_voice |
voice_id |
— |
preview_voice |
voice_id |
language、style、model(篩選樣本) |
clone_voice
| 參數 |
類型 |
必需 |
說明 |
name |
string |
是 |
顯示名稱(非空) |
audio_path |
string |
是 |
本地 WAV 或 MP3 路徑(≤3MB)。支持 ~ 展開 |
description |
string |
否 |
可選備註 |
自定義聲音 CRUD
| 工具 |
必需 |
可選 |
search_custom_voice |
— |
name、description(部分匹配) |
get_custom_voice |
voice_id |
— |
edit_custom_voice |
voice_id |
name、description(至少需要一個) |
delete_custom_voice |
voice_id |
— (不可逆) |
用量與額度
| 工具 |
必需 |
可選 |
get_credit_balance |
— |
— |
get_usage_history |
— |
—(報告近期默認窗口) |
get_voice_usage |
voice_id |
— |
merge_audio_files
| 參數 |
類型 |
必需 |
說明 |
input_paths |
string[] |
是 |
兩個或多個本地 mp3/wav 路徑(支持 ~ 展開)。單個文件將原樣返回 |
gap_ms |
int |
否 |
在每個連接處插入靜音(毫秒)。默認 0。與 crossfade_ms 互斥 |
crossfade_ms |
int |
否 |
在每個連接處交叉淡化混合(毫秒)。默認 0。與 gap_ms 互斥 |
output_format |
string |
否 |
強制 mp3 或 wav。若省略:擴展名全部相同 → 使用該擴展名;混合 → mp3 |
🛠️ 開發
git clone https://github.com/supertone-inc/supertone-mcp.git
cd supertone-mcp
uv sync
uv run pytest -q
uv run pytest --cov=src --cov-report=term-missing
📄 許可證
MIT