Edge-TTS MCP Server

Local setup required. This server has to be cloned and prepared on your machine before you register it in Claude Code.
1

Set the server up locally

Run this once to clone and prepare the server before adding it to Claude Code.

Run in terminal
pip install -r requirements.txt
2

Register it in Claude Code

After the local setup is done, run this command to point Claude Code at the built server.

Run in terminal
claude mcp add -e "PYTHONPATH=${PYTHONPATH}" edge-tts -- python "<FULL_PATH_TO_EDGE_TTS_MCP>/dist/index.js"

Replace <FULL_PATH_TO_EDGE_TTS_MCP>/dist/index.js with the actual folder you prepared in step 1.

Required:PYTHONPATH
README.md

An MCP server that leverages the Microsoft Edge TTS service

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

  1. command: Path to Python interpreter
  2. args: Path to main program file
  3. env: Environment variables to ensure Python can find source code
  4. disabled: Whether to disable this server (default false)
  5. 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

Tools (5)

text_to_speechConvert text into speech audio.
list_voicesQuery available voices with filtering options.
save_audioSave audio data to a file.
get_voice_infoGet detailed information about a specific voice.
generate_subtitlesGenerate subtitle files for speech.

Environment Variables

PYTHONPATHrequiredPath to the source directory to ensure Python can find the modules.

Configuration

claude_desktop_config.json
{"mcpServers": {"edge-tts": {"command": "python", "args": ["/path/to/edge-tts/main.py"], "env": {"PYTHONPATH": "/path/to/edge-tts/src"}}}}

Try it

List all available Chinese voices for text-to-speech.
Convert the following text to an audio file using the zh-CN-XiaoxiaoNeural voice: 'Hello, welcome to the MCP server.'
Generate an SRT subtitle file for the text 'This is a test of the text to speech system.'
Get detailed information about the voice en-US-JennyNeural.

Frequently Asked Questions

What are the key features of Edge-TTS MCP Server?

Text-to-speech conversion supporting over 80 languages. Voice list querying with locale, gender, and pattern filtering. Audio file saving capabilities. Subtitle generation in SRT format. Detailed voice information retrieval.

What can I use Edge-TTS MCP Server for?

Creating audio versions of documents or articles for accessibility. Generating voiceovers for video content with synchronized subtitles. Building automated notification systems that speak alerts. Prototyping multilingual voice interfaces for applications.

How do I install Edge-TTS MCP Server?

Install Edge-TTS MCP Server by running: pip install -r requirements.txt

What MCP clients work with Edge-TTS MCP Server?

Edge-TTS MCP Server works with any MCP-compatible client including Claude Desktop, Claude Code, Cursor, and other editors with MCP support.

Turn this server into reusable context

Keep Edge-TTS MCP Server docs, env vars, and workflow notes in Conare so your agent carries them across sessions.

Need the old visual installer? Open Conare IDE.
Open Conare