The Kokoro Text to Speech MCP server converts text to speech and generates MP3 files with an option to upload them to Amazon S3. It uses the Kokoro TTS model from Hugging Face to create natural-sounding audio in various voices and languages.
FFmpeg (required for MP3 conversion)
For macOS:
brew install ffmpeg
Create a .env
file based on the provided env.example
template with your own values:
AWS_ACCESS_KEY_ID=your_access_key
AWS_SECRET_ACCESS_KEY=your_secret_key
AWS_S3_BUCKET_NAME=your_bucket_name
AWS_S3_REGION=us-east-1
AWS_S3_FOLDER=mp3
S3_ENABLED=true
MP3_FOLDER=/path/to/mp3/storage
Add the following to your MCP configs (update with your own values):
"kokoro-tts-mcp": {
"command": "uv",
"args": [
"--directory",
"/path/toyourlocal/kokoro-tts-mcp",
"run",
"mcp-tts.py"
],
"env": {
"TTS_VOICE": "af_heart",
"TTS_SPEED": "1.0",
"TTS_LANGUAGE": "en-us",
"AWS_ACCESS_KEY_ID": "",
"AWS_SECRET_ACCESS_KEY": "",
"AWS_REGION": "us-east-1",
"AWS_S3_FOLDER": "mp3",
"S3_ENABLED": "true",
"MP3_FOLDER": "/path/to/mp3"
}
}
The preferred method is to use UV:
uv run mcp-tts.py
Convert text to speech with default settings:
python mcp_client.py --text "Hello, world!"
Process the contents of a text file:
python mcp_client.py --file my_text.txt
Change the voice and adjust the speech speed:
python mcp_client.py --text "Hello, world!" --voice "en_female" --speed 1.2
Generate MP3 locally only:
python mcp_client.py --text "Hello, world!" --no-s3
See all available command-line options:
python mcp_client.py --help
0.0.0.0
(all interfaces) or 127.0.0.1
(localhost only)localhost
or 127.0.0.1
when running on the same machineAWS Configuration:
AWS_ACCESS_KEY_ID
: Your AWS access keyAWS_SECRET_ACCESS_KEY
: Your AWS secret keyAWS_S3_BUCKET_NAME
: S3 bucket nameAWS_S3_REGION
: S3 region (e.g., us-east-1)AWS_S3_FOLDER
: Folder path within the S3 bucketAWS_S3_ENDPOINT_URL
: Optional custom endpoint URL for S3-compatible storageServer Settings:
MCP_HOST
: Host to bind the server to (default: 0.0.0.0)MCP_PORT
: Port to listen on (default: 9876)MCP_CLIENT_HOST
: Hostname for client connections (default: localhost)DEBUG
: Enable debug mode (set to "true" or "1")TTS Settings:
TTS_VOICE
: Default voice (default: af_heart)TTS_SPEED
: Default speech speed (default: 1.0)TTS_LANGUAGE
: Default language (default: en-us)File Management:
S3_ENABLED
: Enable S3 uploads (set to "true" or "1")MP3_FOLDER
: Path to store MP3 filesMP3_RETENTION_DAYS
: Days to keep MP3 files before automatic deletionDELETE_LOCAL_AFTER_S3_UPLOAD
: Delete local files after successful S3 uploadMP3_FOLDER
to specify where MP3 files are stored locallyMP3_RETENTION_DAYS=30
to automatically delete files older than 30 daysDELETE_LOCAL_AFTER_S3_UPLOAD=true
to remove local files after S3 uploadS3_ENABLED=true
or S3_ENABLED=false
.env
fileTo add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "kokoro-tts-mcp" '{"command":"uv","args":["--directory","/path/toyourlocal/kokoro-tts-mcp","run","mcp-tts.py"],"env":{"TTS_VOICE":"af_heart","TTS_SPEED":"1.0","TTS_LANGUAGE":"en-us","AWS_ACCESS_KEY_ID":"","AWS_SECRET_ACCESS_KEY":"","AWS_REGION":"us-east-1","AWS_S3_FOLDER":"mp3","S3_ENABLED":"true","MP3_FOLDER":"/path/to/mp3"}}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"kokoro-tts-mcp": {
"command": "uv",
"args": [
"--directory",
"/path/toyourlocal/kokoro-tts-mcp",
"run",
"mcp-tts.py"
],
"env": {
"TTS_VOICE": "af_heart",
"TTS_SPEED": "1.0",
"TTS_LANGUAGE": "en-us",
"AWS_ACCESS_KEY_ID": "",
"AWS_SECRET_ACCESS_KEY": "",
"AWS_REGION": "us-east-1",
"AWS_S3_FOLDER": "mp3",
"S3_ENABLED": "true",
"MP3_FOLDER": "/path/to/mp3"
}
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"mcpServers": {
"kokoro-tts-mcp": {
"command": "uv",
"args": [
"--directory",
"/path/toyourlocal/kokoro-tts-mcp",
"run",
"mcp-tts.py"
],
"env": {
"TTS_VOICE": "af_heart",
"TTS_SPEED": "1.0",
"TTS_LANGUAGE": "en-us",
"AWS_ACCESS_KEY_ID": "",
"AWS_SECRET_ACCESS_KEY": "",
"AWS_REGION": "us-east-1",
"AWS_S3_FOLDER": "mp3",
"S3_ENABLED": "true",
"MP3_FOLDER": "/path/to/mp3"
}
}
}
}
3. Restart Claude Desktop for the changes to take effect