A text to speech MCP server: let your AI agent speak out loud
Coding agents and AI assistants work for minutes at a time, and you end up watching the window to see whether they are done. With a small MCP server, the agent can simply say it: “The build finished, two tests fail.”
The Model Context Protocol (MCP) is the open standard that Claude Code, Claude Desktop, Cursor and other clients use to call tools. This guide builds a speak tool in about 30 lines of Python. It voices text offline with the free SuperClonica engine and any of its voices, or through the SuperClonica speech API on a machine where you would rather not run a model.
Install
You need Python 3.10 or newer. Install the MCP Python SDK and the engine:
pip install mcp superclonica-cpu
On the first run the engine downloads the Supertonic 3 model, about 400 MB, and then works offline on an ordinary processor. On Linux the server plays sound with aplay from alsa-utils; Windows and macOS need nothing extra.
The server
Save this as tts_mcp.py. It registers one tool, speak, that voices the text, plays it on your speakers and tells the agent it is done:
import os, subprocess, sys, tempfile
from mcp.server.mcpserver import MCPServer
from superclonica import Superclonica
VOICE = os.environ.get("TTS_VOICE", "F1") # M1..M5, F1..F5 or a voice file from the catalog
server = MCPServer("speak")
tts = None
def play(path):
if sys.platform == "win32":
import winsound
winsound.PlaySound(path, winsound.SND_FILENAME)
elif sys.platform == "darwin":
subprocess.run(["afplay", path], check=True)
else:
subprocess.run(["aplay", "-q", path], check=True)
@server.tool()
def speak(text: str, language: str = "en") -> str:
"""Say a short message out loud to the user, for example when a long task is done."""
global tts
tts = tts or Superclonica()
audio, _ = tts.synthesize(text[:500], voice=VOICE, lang=language)
path = os.path.join(tempfile.gettempdir(), "mcp-speak.wav")
tts.save(path, audio)
play(path)
return "spoken"
if __name__ == "__main__":
server.run()The model loads on the first call, so the agent starts fast and only the first sentence takes a few seconds longer. The code is for version 2 of the mcp package, where FastMCP was renamed MCPServer; on version 1 import FastMCP from mcp.server.fastmcp instead. The tool’s docstring is what the agent reads to decide when to call it, so describe the use you want.
Connect it to Claude Code, Claude Desktop or Cursor
In Claude Code, add the server with one command:
claude mcp add speak -- python /full/path/to/tts_mcp.py
In Claude Desktop, add it to claude_desktop_config.json; Cursor reads the same mcpServers block from its mcp.json. Use the full path to the Python that has the packages installed:
{
"mcpServers": {
"speak": {
"command": "/full/path/to/python",
"args": ["/full/path/to/tts_mcp.py"],
"env": {"TTS_VOICE": "F1"}
}
}
}Then tell the agent when to speak, for example in your project instructions: “When you finish a task or need my input, call speak with one short sentence.”
The same tool through the API
On a laptop where you would rather not keep a 400 MB model, voice the text through the SuperClonica speech API instead: in speak, replace the two synthesis lines with a call to this function and set SUPERCLONICA_KEY and VOICE_ID.
import os, requests
API = "https://superclonica.com/api/v1/speech"
VOICE_ID = os.environ["VOICE_ID"] # the ID on the page of a catalog voice
def voice_to_file(text, language, path):
answer = requests.post(API, timeout=120,
headers={"Authorization": "Bearer " + os.environ["SUPERCLONICA_KEY"]},
json={"text": text, "voice": VOICE_ID, "language": language, "format": "wav"})
answer.raise_for_status()
with open(path, "wb") as file:
file.write(answer.content)Every catalog voice works by the ID on its page, on any plan. The free key gives a minute of audio a day, which is plenty for one-sentence status messages.
Choose the voice
TTS_VOICE takes one of the ten stock voices, M1 to M5 and F1 to F5, or the path of a voice file from the SuperClonica catalog: a calm narrator, a ship’s computer or a game character. Free catalog voices download without an account. Listen to a voice and voice a test sentence on its page first.