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
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.