MCP Connector

Generate Speech from Text and Upload to S3

A Kokoro text-to-speech MCP server that generates MP3 files locally with optional automatic upload to S3.

Works with s3ffmpeg

86
Spark score
out of 100
Updated 11 months ago
Version model-files-v1.0
Models
universal

Add to Favorites

Why it matters

Automate the creation of audio content by converting text into MP3 files using the Kokoro TTS model. Optionally, seamlessly upload generated audio to S3 storage for easy access and distribution.

Outcomes

What it gets done

01

Convert text input into speech using the Kokoro TTS model.

02

Generate MP3 audio files from synthesized speech.

03

Automatically upload generated MP3 files to an S3 bucket.

04

Configure voice, language, and speech speed for audio generation.

Install

Add it to your toolbox

Run in your project directory:

curl -fsSL https://spark.entire.vc/get/vb-kokoro-tts | bash

Capabilities

Tools your agent gets

generate_speech

Generates MP3 audio files from text using Kokoro TTS with configurable voice, speed, and language.

upload_to_s3

Uploads generated MP3 files to AWS S3 bucket with optional folder organization.

Overview

Kokoro TTS MCP Server

A Kokoro text-to-speech MCP server generating locally stored MP3 files with configurable voice/speed and optional S3 archiving. Use when an MCP client needs to turn text into playable speech audio, optionally archived to S3.

What it does

This is a Kokoro Text-to-Speech MCP server that generates .mp3 files from text, using the Kokoro TTS model (the same one hosted at Hugging Face's hexgrad/Kokoro-TTS Space), with an option to upload the resulting files to S3. It runs as a local server (uv run mcp-tts.py) configured via MCP client entries or a .env file, and ships a companion mcp_client.py script for sending TTS requests directly - basic text, reading from a file, customizing voice and speed, or disabling S3 upload per request with --no-s3. Output files are stored locally in a configurable MP3_FOLDER, with optional automatic cleanup after a set number of days (MP3_RETENTION_DAYS) or immediate deletion once successfully uploaded to S3 (DELETE_LOCAL_AFTER_S3_UPLOAD). Default voice, speed, and language are configurable (TTS_VOICE=af_heart, TTS_SPEED=1.0, TTS_LANGUAGE=en-us), and the server binds to a configurable host/port (MCP_HOST/MCP_PORT, default 0.0.0.0:9876) with a separate MCP_CLIENT_HOST for how clients reach it.

When to use - and when NOT to

Use it when an MCP client needs to convert text to speech and get back playable MP3 files, optionally archived to S3 with automatic retention/cleanup. It requires ffmpeg installed locally (brew install ffmpeg on macOS) to convert the model's .wav output to .mp3, and the Kokoro ONNX weights (kokoro-v1.0.onnx and voices-v1.0.bin) downloaded into the same repo before first run. When running server and client on the same machine, bind the server to 0.0.0.0 or 127.0.0.1 and have the client connect to localhost/127.0.0.1 accordingly - a mismatched bind/connect host is a likely source of connection failures.

Capabilities

Generates spoken-audio MP3s from text via the Kokoro TTS model, with configurable voice/speed/language defaults, local file storage with retention-based automatic cleanup, and optional S3 upload (with the option to delete the local copy immediately after a successful upload). The bundled mcp_client.py supports sending text directly, reading text from a file, overriding voice/speed per request, and disabling S3 upload per request.

How to install

Clone the repo locally, download the Kokoro ONNX weights (kokoro-v1.0.onnx, voices-v1.0.bin) into the same repo, install ffmpeg (needed to convert .wav to .mp3), copy env.example to .env and fill in your own values, then add an MCP config entry running uv run mcp-tts.py via the --directory flag pointing at the local repo path.

"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"
    } 
  }

Who it's for

Developers who want an MCP-connected text-to-speech pipeline that produces locally stored (and optionally S3-archived) MP3 files using the Kokoro TTS model.

Source README
Kokoro Text to Speech Server MCP server

Kokoro Text to Speech (TTS) MCP Server

Kokoro Text to Speech MCP server that generates .mp3 files with option to upload to S3.

Uses: https://huggingface.co/spaces/hexgrad/Kokoro-TTS

Configuration

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"
      } 
    }

Install ffmmeg

This is needed to convert .wav to .mp3 files

For mac:

brew install ffmpeg

To run locally add these to your .env file. See env.example and copy to .env and modify with your own values.

Supported Environment Variables

  • AWS_ACCESS_KEY_ID: Your AWS access key ID
  • AWS_SECRET_ACCESS_KEY: Your AWS secret access key
  • AWS_S3_BUCKET_NAME: S3 bucket name
  • AWS_S3_REGION: S3 region (e.g., us-east-1)
  • AWS_S3_FOLDER: Folder path within the S3 bucket
  • AWS_S3_ENDPOINT_URL: Optional custom endpoint URL for S3-compatible storage
  • 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 to the server (default: localhost)
  • DEBUG: Enable debug mode (set to "true" or "1")
  • S3_ENABLED: Enable S3 uploads (set to "true" or "1")
  • MP3_FOLDER: Path to store MP3 files (default is 'mp3' folder in script directory)
  • MP3_RETENTION_DAYS: Number of days to keep MP3 files before automatic deletion
  • DELETE_LOCAL_AFTER_S3_UPLOAD: Whether to delete local MP3 files after successful S3 upload (set to "true" or "1")
  • TTS_VOICE: Default voice for the TTS client (default: af_heart)
  • TTS_SPEED: Default speed for the TTS client (default: 1.0)
  • TTS_LANGUAGE: Default language for the TTS client (default: en-us)

Running the Server Locally

Preferred method use UV

uv run mcp-tts.py

Using the TTS Client

The mcp_client.py script allows you to send TTS requests to the server. It can be used as follows:

Connection Settings

When running the server and client on the same machine:

  • Server should bind to 0.0.0.0 (all interfaces) or 127.0.0.1 (localhost only)
  • Client should connect to localhost or 127.0.0.1

Basic Usage

python mcp_client.py --text "Hello, world!"

Reading Text from a File

python mcp_client.py --file my_text.txt

Customizing Voice and Speed

python mcp_client.py --text "Hello, world!" --voice "en_female" --speed 1.2

Disabling S3 Upload

python mcp_client.py --text "Hello, world!" --no-s3

Command-line Options

python mcp_client.py --help

MP3 File Management

The TTS server generates MP3 files that are stored locally and optionally uploaded to S3. You can configure how these files are managed:

Local Storage

  • Set MP3_FOLDER in your .env file to specify where MP3 files are stored
  • Files are kept in this folder unless automatically deleted

Automatic Cleanup

  • Set MP3_RETENTION_DAYS=30 (or any number) to automatically delete files older than that number of days
  • Set DELETE_LOCAL_AFTER_S3_UPLOAD=true to delete local files immediately after successful S3 upload

S3 Integration

  • Enable/disable S3 uploads with S3_ENABLED=true or DISABLE_S3=true
  • Configure AWS credentials and bucket settings in the .env file
  • S3 uploads can be disabled per-request using the client's --no-s3 option

FAQ

Common questions

Discussion

Questions & comments · 0

Sign In Sign in to leave a comment.