Skip to main content
Glama
mberg

Kokoro Text to Speech MCP Server

by mberg

Kokoro 文本转语音 (TTS) MCP 服务器

Kokoro 文本到语音 MCP 服务器可生成 .mp3 文件,并可选择上传到 S3。

用途: https://huggingface.co/spaces/hexgrad/Kokoro-TTS

Related MCP server: MCP Voice Soundboard

配置

将以下内容添加到您的 MCP 配置中。请使用您自己的值进行更新。

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

安装 ffmmeg

这是将 .wav 文件转换为 .mp3 文件所必需的

对于Mac:

brew install ffmpeg

要在本地运行,请将这些添加到你的 .env 文件中。请参阅 env.example 并复制到 .env 文件,然后使用你自己的值进行修改。

支持的环境变量

  • AWS_ACCESS_KEY_ID :您的 AWS 访问密钥 ID

  • AWS_SECRET_ACCESS_KEY :您的 AWS 秘密访问密钥

  • AWS_S3_BUCKET_NAME :S3 存储桶名称

  • AWS_S3_REGION :S3 区域(例如,us-east-1)

  • AWS_S3_FOLDER :S3 bucket 内的文件夹路径

  • AWS_S3_ENDPOINT_URL :S3 兼容存储的可选自定义端点 URL

  • MCP_HOST :绑定服务器的主机(默认值:0.0.0.0)

  • MCP_PORT :监听端口(默认值:9876)

  • MCP_CLIENT_HOST :客户端连接到服务器的主机名(默认值:localhost)

  • DEBUG :启用调试模式(设置为“true”或“1”)

  • S3_ENABLED :启用 S3 上传(设置为“true”或“1”)

  • MP3_FOLDER :存储 MP3 文件的路径(默认为脚本目录中的“mp3”文件夹)

  • MP3_RETENTION_DAYS :自动删除前保留 MP3 文件的天数

  • DELETE_LOCAL_AFTER_S3_UPLOAD :S3 上传成功后是否删除本地 MP3 文件(设置为“true”或“1”)

  • TTS_VOICE :TTS 客户端的默认语音(默认值:af_heart)

  • TTS_SPEED :TTS 客户端的默认速度(默认值:1.0)

  • TTS_LANGUAGE :TTS 客户端的默认语言(默认值:en-us)

本地运行服务器

首选方法是使用紫外线

uv run mcp-tts.py

使用 TTS 客户端

mcp_client.py脚本允许你向服务器发送 TTS 请求。它的使用方法如下:

连接设置

在同一台机器上运行服务器和客户端时:

  • 服务器应绑定到0.0.0.0 (所有接口)或127.0.0.1 (仅限本地主机)

  • 客户端应连接到localhost或127.0.0.1

基本用法

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

从文件读取文本

python mcp_client.py --file my_text.txt

自定义语音和速度

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

禁用 S3 上传

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

命令行选项

python mcp_client.py --help

MP3文件管理

TTS 服务器会生成 MP3 文件,这些文件存储在本地,也可以选择上传到 S3。您可以配置这些文件的管理方式:

本地存储

  • 在.env文件中设置MP3_FOLDER来指定 MP3 文件的存储位置

  • 文件保存在此文件夹中,除非自动删除

自动清理

  • 设置MP3_RETENTION_DAYS=30 (或任意数字)以自动删除超过该天数的文件

  • 设置DELETE_LOCAL_AFTER_S3_UPLOAD=true以在 S3 上传成功后立即删除本地文件

S3 集成

  • 使用S3_ENABLED=true或DISABLE_S3=true启用/禁用 S3 上传

  • 在.env文件中配置 AWS 凭证和存储桶设置

  • 可以使用客户端的--no-s3选项按请求禁用 S3 上传

Available Tools

1 tool
text_to_speechB
    Convert text to speech using the Kokoro TTS service.
    
    Args:
        text: The text to convert to speech
        voice: Voice ID to use (default: af_heart)
        speed: Speech speed (default: 1.0)
        lang: Language code (default: en-us)
        filename: Optional filename for the MP3 (default: auto-generated UUID)
        upload_to_s3: Whether to upload to S3 if enabled (default: True)
        
    Returns:
        A dictionary with information about the generated audio file
    
ParametersJSON Schema
NameRequiredDescriptionDefault
textYes
voiceNoen_sarah
speedNo
langNoen-us
filenameNo
upload_to_s3No

TDQS

B3.3/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions that the output is an MP3 file and that upload to S3 is optional, which adds some context. However, it doesn't cover important aspects like rate limits, authentication requirements, error conditions, or what the returned dictionary contains. For a tool with 6 parameters and no annotation coverage, this is insufficient.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured and appropriately sized. It starts with the core purpose, then lists parameters with clear explanations, and ends with return information. Every sentence earns its place, though the formatting with 'Args:' and 'Returns:' sections is slightly verbose but still efficient.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (6 parameters, no annotations, no output schema), the description is moderately complete. It excels at parameter documentation but lacks behavioral context and usage guidelines. The absence of an output schema means the description should ideally explain the return dictionary structure, which it doesn't. It's adequate but has clear gaps.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description provides excellent parameter semantics beyond the input schema. With 0% schema description coverage, the description fully compensates by explaining each parameter's purpose, default values, and optionality. It clarifies that 'filename' is auto-generated if not provided and that 'upload_to_s3' depends on whether S3 is enabled. This adds significant value over the bare schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Convert text to speech using the Kokoro TTS service.' It specifies the verb ('convert') and resource ('text to speech'), and mentions the specific service. However, without sibling tools, it cannot demonstrate differentiation from alternatives, so it doesn't reach the highest score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention any prerequisites, constraints, or typical use cases. The only contextual information is the service name (Kokoro TTS), but this doesn't help an agent decide when this tool is appropriate.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 1 tool updatev1.0.0
    • Changedtext_to_speech2 fields changed
      • changedInput schema / properties / speed / default
        Previous value: -1New value: +1.2
      • changedInput schema / properties / voice / default
        Previous value: -"af_heart"New value: +"en_sarah"
  2. 1 tool update
    • First observedtext_to_speech

TDQS

B3.4/5.0

Scored across 1 tool

Disambiguation5/5

With only one tool, there is no possibility of ambiguity or overlap between tools. The single tool has a clearly defined purpose of converting text to speech, which cannot be confused with any other functionality.

Naming Consistency5/5

The single tool name 'text_to_speech' follows a clear verb_noun pattern and uses snake_case consistently. With only one tool, naming consistency is inherently perfect as there are no other tools to compare against.

Tool Count2/5

A single tool is too few for a server's apparent scope of text-to-speech functionality. While the tool itself is well-defined, a complete TTS service would typically include additional tools such as listing available voices, managing audio files, or configuring settings, making this server feel thin and incomplete.

Completeness2/5

The server is severely incomplete for a text-to-speech domain. It lacks essential operations such as listing available voices, checking service status, managing generated audio files (beyond the single generation tool), or handling configuration. This creates significant gaps that will limit agent workflows and cause failures in more complex tasks.

Maintenance

ActivityInactive
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers