text-to-speech
Enables text-to-speech conversion using Google Translate's TTS, supporting many languages and accents, and saving MP3 files.
README
Text-to-Speech MCP Server
An MCP server that exposes a text-to-speech
tool, powered by the free, no-API-key gTTS
library (which wraps Google Translate's internal TTS endpoint).
- Free — no API key, no billing, no GCP account.
- Many languages — English, Bengali, Spanish, and ~60 more.
- File output — saves an MP3 and returns its path.
- Resilient — retries transient/rate-limit failures with exponential backoff.
Note: gTTS uses an undocumented Google endpoint. It requires internet access and can rate-limit or change without notice — great for personal/internal use, less suited to high-volume production. The engine is isolated in
engine.pyso it can be swapped for Google Cloud TTS or an offline engine later.
Requirements
- uv
- Python 3.12 (uv will provision it)
Setup
uv sync
This creates .venv/ and installs the project (and its deps: gtts, mcp).
Optional configuration — copy .env.example to .env and edit:
| Variable | Default | Meaning |
|---|---|---|
TTS_OUTPUT_DIR |
./output |
Where MP3s are written when no output_path is given |
TTS_MAX_RETRIES |
3 |
Max synthesis attempts before failing |
TTS_RETRY_BACKOFF |
1.0 |
Base backoff seconds (1s, 2s, 4s, …) |
TTS_DEFAULT_LANG |
en |
Default language code |
TTS_DEFAULT_ACCENT |
com |
Default accent TLD |
Run
uv run tts-server
# or
uv run python -m tts_server.server
The server speaks MCP over stdio.
Tools
text_to_speech
| Arg | Type | Default | Description |
|---|---|---|---|
text |
string | — (required) | Text to speak |
language |
string | en |
Language code (en, bn, es, …) |
slow |
boolean | false |
Speak more slowly |
accent |
string | com |
Accent TLD: com (US), co.uk (UK), com.au (AU), co.in (India) |
output_path |
string | auto | Output MP3 path; auto-generated under TTS_OUTPUT_DIR if omitted |
Returns: Saved <N> KB MP3 to <path>, or Error: <reason>.
list_languages
No arguments. Returns supported code: name pairs.
Install in an MCP client
This is a standard stdio MCP server, so it works with any MCP-compatible client (Claude Code, Claude Desktop, Cursor, Windsurf, Continue, etc.). Every client needs the same three things:
| Field | Value |
|---|---|
| command | uv |
| args | ["--directory", "<ABS_PROJECT_PATH>", "run", "tts-server"] |
| env (optional) | e.g. { "TTS_OUTPUT_DIR": "<ABS_OUTPUT_PATH>" } |
Replace <ABS_PROJECT_PATH> with the absolute path to this project. Using
uv --directory <path> run means the client can launch the server from anywhere
and still resolve the right virtual env and .env. Make sure uv
is on the client's PATH (or use the absolute path to the uv binary — find it
with which uv).
Claude Code (CLI)
# user scope = available in every project; use --scope project for just this repo
claude mcp add text-to-speech --scope user -- \
uv --directory /abs/path/to/text-to-speech-agent run tts-server
Verify, inspect, or remove:
claude mcp list # health check
claude mcp get text-to-speech # show config
claude mcp remove text-to-speech
Tools load when a session starts, so open a new session after adding.
Claude Desktop
Edit the config file (Settings → Developer → Edit Config, or directly):
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
Add (see claude_desktop_config.example.json):
{
"mcpServers": {
"text-to-speech": {
"command": "uv",
"args": ["--directory", "/abs/path/to/text-to-speech-agent", "run", "tts-server"],
"env": { "TTS_OUTPUT_DIR": "/abs/path/to/text-to-speech-agent/output" }
}
}
}
Then fully restart Claude Desktop.
Cursor / Windsurf / other JSON-config clients
These use the same mcpServers JSON shape as Claude Desktop. Add the block above
to the client's MCP config (e.g. Cursor: Settings → MCP, or ~/.cursor/mcp.json),
then reload the client.
Generic stdio client
Any client that can launch a stdio server: configure it to run
uv --directory /abs/path/to/text-to-speech-agent run tts-server
and (optionally) pass environment variables from the table in Setup.
Troubleshooting
- Server fails to start / "uv not found" — use the absolute path to
uv(which uv) as thecommand, since GUI clients often don't inherit your shellPATH. - Tools don't appear — restart the client (Claude Code: start a new session).
- MP3s land in the wrong place — set
TTS_OUTPUT_DIRin the client'senvblock (it overrides.env). - Synthesis errors — gTTS needs internet and may rate-limit; the server retries automatically, but check connectivity if it persists.
Project layout
src/tts_server/
server.py # MCP tools, validation, response shaping
engine.py # gTTS wrapper + retry/backoff (only file importing gTTS)
config.py # env-driven settings
utils.py # filename gen, language validation, file sizing
tests/ # unit tests (retry paths, mocked gTTS)
output/ # generated MP3s
Tests
uv run python -m pytest -q
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。