TTS MCP Server

TTS MCP Server

Text-to-speech MCP server using Microsoft Edge TTS, supporting multiple voices and async processing.

Category
访问服务器

README

VoiceOver MCP Server

Text-to-speech server exposing one MCP tool (voice_over) over SSE, plus a matching REST API. Audio is generated to a temp directory (safe for ephemeral disks on Render/Railway/Fly/etc.) and served back over HTTP so any LLM client or frontend can render it.

Project layout

app/
├── main.py              # FastAPI app factory: middleware, lifespan, routers
├── config.py             # all env-var configuration in one place
│
├── models/
│   └── schemas.py         # TTSRequest / TTSResponse Pydantic models
│
├── core/                    # transport-agnostic business logic
│   ├── tts.py                 # edge-tts wrapper (generate_audio_core, list_available_voices)
│   ├── files.py                 # filename generation, temp-path resolution, cleanup
│   └── logging.py                 # in-memory request log
│
├── mcp/                              # MCP protocol layer
│   ├── server.py                       # Server("voiceover-mcp-server") instance
│   ├── tools.py                          # tool schema: single "voice_over" tool
│   └── handlers.py                         # call_tool dispatch -> core.tts
│
├── routes/                                    # REST layer (one file per resource)
│   ├── root.py                                  # GET / , GET /health
│   ├── mcp_sse.py                                 # GET /mcp/sse
│   ├── tts.py                                       # POST /api/v1/tts
│   ├── voices.py                                      # GET /api/v1/voices
│   ├── audio.py                                         # GET /api/v1/audio/{filename}
│   └── logs.py                                            # GET /api/v1/logs
│
└── utils/
    └── formatting.py                                        # file-size + timestamp helpers

tests/                                                            # pytest suite (27 tests)
run.py                                                              # entry point

Run it

pip install -r requirements.txt
cp .env.example .env   # edit as needed
python run.py

Server starts on http://0.0.0.0:8080 by default. Docs at /docs.

The voice_over MCP tool

Connect an MCP client to GET /mcp/sse. The single exposed tool:

  • Input: text (required), voice, rate, pitch, volume, output_filename
  • Output: { "success": true, "content": "<original text>", "filename": "<name>.mp3", "timestamp": "..." }

The tool does not return audio bytes or a filesystem path — only the filename. Fetch the actual file with:

GET /api/v1/audio/{filename}

This is what your deploy/render layer should call to play or download the generated clip.

REST API (mirrors the MCP tool 1:1)

Method Path Purpose
GET / Service info
GET /health Health + temp dir status
GET /mcp/sse MCP SSE connection
POST /api/v1/tts Generate speech, returns filename + download URL
GET /api/v1/voices List/filter available edge-tts voices
GET /api/v1/audio/{filename} Download/stream a generated clip
GET /api/v1/logs Recent request log (monitoring)

Storage model

  • All audio is written to a single ephemeral temp directory (TEMP_DIR, defaults to the OS temp dir + voiceover_mcp).
  • Filenames are sanitized and resolved with Path(...).name only — no path traversal via output_filename or the download route.
  • AUDIO_TTL_SECONDS (default 1 hour) controls a startup cleanup sweep that deletes stale files.
  • Because storage is ephemeral, files will not survive a server restart on most PaaS platforms — by design. The download endpoint returns a clear 404 if a file has expired or the instance was recycled.

Testing

python -m pytest tests/ -v

27 tests covering: filename/path safety, TTS core logic (edge-tts mocked, no real network calls), the MCP voice_over tool handler, and all REST routes.

Environment variables

See .env.example. Key ones:

  • PORT, HOST — server binding
  • TEMP_DIR — override the audio temp directory
  • AUDIO_TTL_SECONDS — cleanup age threshold
  • DEFAULT_VOICE, DEFAULT_RATE, DEFAULT_PITCH, DEFAULT_VOLUME — TTS defaults

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选