Edge-TTS MCP Server
An MCP server that leverages the Microsoft Edge TTS service to provide high-quality text-to-speech capabilities across over 80 languages. It enables users to generate audio files, query available voices, and create subtitle files using natural language commands.
README
Edge-TTS MCP Server
中文文档 | English Documentation
基于 Microsoft Edge TTS 服务的 MCP (Model Context Protocol) 服务器,提供文本转语音功能。
Claude Code MCP Configuration
Add the following MCP server configuration to your Claude Code settings:
{
"mcpServers": {
"edge-tts": {
"command": "python",
"args": [
"/absolute/path/to/edge-tts/main.py"
],
"env": {
"PYTHONPATH": "/absolute/path/to/edge-tts/src"
}
}
}
}
Configuration Example (modify with your actual path):
{
"mcpServers": {
"edge-tts": {
"command": "python",
"args": [
"/Users/ymr/github/edge-tts/main.py"
],
"env": {
"PYTHONPATH": "/Users/ymr/github/edge-tts/src"
}
}
}
}
Windows Configuration:
{
"mcpServers": {
"edge-tts": {
"command": "python",
"args": [
"C:\\path\\to\\edge-tts\\main.py"
],
"env": {
"PYTHONPATH": "C:\\path\\to\\edge-tts\\src"
}
}
}
}
Using Virtual Environment (recommended):
{
"mcpServers": {
"edge-tts": {
"command": "/path/to/venv/bin/python",
"args": [
"/path/to/edge-tts/main.py"
]
}
}
}
Configuration File Example: The project root provides claude-mcp-config.json with a complete configuration example.
Configuration Details
- command: Path to Python interpreter
- args: Path to main program file
- env: Environment variables to ensure Python can find source code
- disabled: Whether to disable this server (default false)
- autoStart: Whether to auto-start (default true)
Configuration Location
Claude Code MCP configuration file is typically located at:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json - Linux:
~/.config/Claude/claude_desktop_config.json
Add the configuration to the mcpServers section of the file.
功能特性
- ✅ 文本转语音(支持多种语言和语音)
- ✅ 语音列表查询(支持按语言、性别过滤)
- ✅ 音频文件保存
- ✅ 语音详细信息查询
- ✅ 字幕生成(SRT格式)
- ✅ 完整的 MCP 协议支持
- ✅ 严格的参数验证
- ✅ 详细的错误处理
安装依赖
pip install -r requirements.txt
启动服务器
# 方式1: 使用主脚本
python main.py
# 方式2: 直接运行服务器
python -m src.server
工具列表
1. text_to_speech
将文本转换为语音音频
参数:
text: 要转换的文本内容(必填)voice: 语音名称(默认: en-US-EmmaMultilingualNeural)rate: 语速调整(默认: +0%)volume: 音量调整(默认: +0%)pitch: 音调调整(默认: +0Hz)boundary: 边界类型(默认: SentenceBoundary)format: 输出格式(默认: mp3)
2. list_voices
查询可用的语音列表
参数:
locale: 语言区域过滤gender: 性别过滤(Male/Female)name_pattern: 名称模式匹配
3. save_audio
将音频数据保存到文件
参数:
audio_data: base64编码的音频数据(必填)filename: 保存的文件名(必填)format: 文件格式(默认: mp3)
4. get_voice_info
获取特定语音的详细信息
参数:
voice_name: 语音名称(必填)
5. generate_subtitles
生成语音的字幕文件
参数:
text: 文本内容(必填)voice: 语音名称(默认: en-US-EmmaMultilingualNeural)subtitle_format: 字幕格式(默认: srt)boundary_type: 边界类型(默认: SentenceBoundary)
使用示例
命令行测试
# 查询中文语音列表
curl -X POST http://localhost:8000/tools/call \
-H "Content-Type: application/json" \
-d '{
"name": "list_voices",
"arguments": {
"locale": "zh-CN"
}
}'
# 文本转语音
curl -X POST http://localhost:8000/tools/call \
-H "Content-Type: application/json" \
-d '{
"name": "text_to_speech",
"arguments": {
"text": "你好,世界!",
"voice": "zh-CN-XiaoxiaoNeural"
}
}'
Python 客户端示例
import asyncio
import aiohttp
import json
async def test_tts():
async with aiohttp.ClientSession() as session:
# 文本转语音
payload = {
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "text_to_speech",
"arguments": {
"text": "Hello, world!",
"voice": "en-US-JennyNeural"
}
}
}
async with session.post("http://localhost:8000", json=payload) as response:
result = await response.json()
print(json.dumps(result, indent=2))
asyncio.run(test_tts())
错误代码
1001: 验证错误1002: 语音不存在1003: 参数错误1004: 网络错误1005: 音频生成错误
配置说明
编辑 config/server_config.yaml 文件进行配置:
server:
host: localhost
port: 8000
log_level: INFO
defaults:
voice: en-US-EmmaMultilingualNeural
rate: +0%
volume: +0%
pitch: +0Hz
支持的语音
支持 85 种语言的 585 个不同语音,包括:
- 中文:
zh-CN-XiaoxiaoNeural,zh-CN-YunyangNeural - 英文:
en-US-JennyNeural,en-US-EmmaMultilingualNeural - 日文:
ja-JP-NanamiNeural - 韩文:
ko-KR-SunHiNeural
使用 list_voices 工具查看完整列表。
开发说明
项目结构:
edge-tts-mcp-server/
├── src/
│ ├── __init__.py
│ ├── server.py # MCP Server 主文件
│ ├── tools.py # 工具实现
│ ├── models.py # 数据模型
│ └── utils.py # 工具函数
├── config/
│ └── server_config.yaml # 服务器配置
├── requirements.txt # 依赖文件
├── README.md
└── main.py # 启动脚本
许可证
MIT License
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。