tts-mcp

tts-mcp

Profile-driven MCP server for Google Cloud Text-to-Speech that exposes tools to synthesize text to speech, run diagnostics, and stop playback, with voice and settings locked per profile.

Category
访问服务器

README

tts-mcp

Profile-driven MCP server for Google Cloud Text-to-Speech: define one profile per app/client so each tool always speaks with the right voice and settings.

Exposes three tools to any MCP client:

  • tts_speak — synthesize text to audio and auto-play it
  • tts_doctor — run diagnostics on auth, profile, and playback
  • tts_stop — stop any currently playing audio

Voice, language, model, and format are locked per profile — the LLM can only control text content, speaking rate, and pitch.

Install

pip install tts-mcp

Or with uvx (no install needed):

uvx tts-mcp --help

Prerequisites

  • Python 3.11+
  • A Google Cloud project with the Cloud Text-to-Speech API enabled
  • Google offers a generous free tier — up to 4 million characters/month (roughly 84 hours of English speech at a normal pace) for Standard and WaveNet voices, and 1 million characters/month (roughly 21 hours) for Neural2, Polyglot, Chirp 3: HD, and Studio voices, more than enough for most individual use. See TTS pricing for details.
  • Google Cloud CLI (gcloud) for authentication
  • macOS uses afplay for playback by default (configurable via profile)

Setup

1. Authenticate with Google Cloud

gcloud auth application-default login
gcloud auth application-default set-quota-project YOUR_PROJECT_ID

This stores credentials at ~/.config/gcloud/application_default_credentials.json, which the TTS client discovers automatically. No environment variables needed.

2. Create a profiles file

tts-mcp --init
${EDITOR:-vi} ~/.config/tts-mcp/profiles.json

This creates a starter config at ~/.config/tts-mcp/profiles.json with example profiles for every Google TTS voice tier. Edit it to pick your voice, format, and playback settings.

The server finds the profiles file automatically — no --profiles flag needed for the common case. The search order is:

  1. --profiles flag or TTS_MCP_PROFILES_PATH env var (explicit override)
  2. ~/.config/tts-mcp/profiles.json (XDG standard — created by tts-mcp --init)

MCP client setup

After running tts-mcp --init, no --profiles flag is needed — the server finds ~/.config/tts-mcp/profiles.json automatically. Just pass --profile to select which profile each client uses.

Claude Code

claude mcp add --transport stdio --scope user \
  speech -- tts-mcp --profile claude

OpenCode

Edit ~/.config/opencode/opencode.jsonc:

{
  "mcp": {
    "speech": {
      "type": "local",
      "command": ["tts-mcp", "--profile", "opencode"],
      "enabled": true,
      "timeout": 120000
    }
  }
}

Codex CLI

Edit ~/.codex/config.toml:

[mcp_servers.speech]
command = "tts-mcp"
args = ["--profile", "codex"]

Using uvx (no global install)

Any client config can use uvx instead of installing globally:

{
  "command": "uvx",
  "args": ["--update", "tts-mcp", "--profile", "opencode"]
}

Usage

In any MCP-enabled client, prompt naturally:

  • Summarize this and read it aloud.
  • Stop talking.

Tool names may appear prefixed by the client (e.g. speech_tts_speak, speech_tts_stop).

CLI reference

The package installs four commands. Each supports --help for full details. For normal usage, you only need tts-mcp --init plus your MCP client setup above; the commands below are mostly for diagnostics or manual testing.

tts-mcp — MCP server and management

tts-mcp --init              # create starter config at ~/.config/tts-mcp/profiles.json
tts-mcp --init --force      # overwrite existing config
tts-mcp --doctor            # diagnostics: auth, profile, voice, player
tts-mcp --profile casual    # start MCP server with a specific profile

Defaults:

  • --profiles: TTS_MCP_PROFILES_PATH env var or "" (then auto-discovery runs)
  • --profile: TTS_MCP_PROFILE_NAME env var or "" (then default_profile is used)
  • --doctor, --init, --force: false

tts-speak — synthesize text to audio

tts-speak --text "Hello world" --voice en-US-Chirp3-HD-Fenrir --format wav --out hello.wav
tts-speak --text-file notes.txt --voice en-US-Neural2-D --format mp3 --out notes.mp3
tts-speak --ssml --text "<speak>Hello <break time='500ms'/> world</speak>" --out ssml.wav
echo "Piped text" | tts-speak --voice en-US-Casual-K --out piped.ogg

Options: --text, --text-file, --voice, --language, --model, --format (mp3/ogg/wav), --speaking-rate, --pitch, --out, --usage-log.

Defaults:

  • --voice: ""
  • --language: en-US
  • --model: ""
  • --format: mp3
  • --speaking-rate: 1.0
  • --pitch: 0.0
  • --out: "" (auto-generates YYYYMMDD-HHMMSS-ms.ext in the current directory, local timezone)
  • --usage-log: usage_log.csv
  • input: if neither --text nor --text-file is provided, the CLI reads piped stdin or prompts for text

tts-voices — list available voices

tts-voices                              # list en-US voices (default language)
tts-voices --language en-US             # filter by language
tts-voices --language en-US --family Chirp3   # filter by family
tts-voices --limit 5                    # limit results

Defaults:

  • --language: en-US
  • --family: "" (no family filter)
  • --limit: 0 (no limit)

tts-batch — generate samples for multiple voices

tts-batch --text-file test.txt --out-dir ./samples
tts-batch --text-file test.txt --families Chirp3,Neural2 --language en-US --format wav
tts-batch --text-file test.txt --limit 3   # first 3 matching voices only

Defaults:

  • --families: "" (no family filter)
  • --language: en-US
  • --format: mp3
  • --out-dir: ./out
  • --speaking-rate: 1.0
  • --pitch: 0.0
  • --limit: 0 (all matching voices)
  • --text-file: required

Profile system

Profiles are defined in a JSON file (see profiles.example.json):

{
  "default_profile": "opencode",
  "profiles": {
    "opencode": {
      "voice": "en-US-Chirp3-HD-Fenrir",
      "language": "en-US",
      "model": "models/chirp3-hd",
      "format": "wav",
      "speaking_rate": 1.0,
      "pitch": 0.0,
      "output_dir": "~/.local/share/tts-mcp/out",
      "usage_log": "~/.local/share/tts-mcp/usage_log.csv",
      "autoplay": true,
      "player_command": ["afplay", "{file}"]
    }
  }
}

Each profile locks: voice, language, model, format, output_dir, usage_log, autoplay, and player_command. Only speaking_rate and pitch can be overridden per tool call.

Troubleshooting

  • Auth errors — run gcloud auth application-default login, or confirm GOOGLE_APPLICATION_CREDENTIALS is set.
  • No audio — verify the player binary (e.g. afplay) exists, or change player_command in your profile.
  • Tool timeout — playback is non-blocking, but if timeouts persist, increase the client's tool_timeout.
  • Run diagnostics — tts-mcp --doctor checks auth, profile, voice, and player.

Development

git clone git@github.com:that-lucas/tts-mcp.git
cd tts-mcp
make setup    # creates venv, installs package + dev deps, sets git hooks
make test     # run pytest
make lint     # run ruff check + format check

See CONTRIBUTING.md for details.

License

MIT

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选