Skip to main content
Glama

oai-tts-mcp

一个 OpenAI 兼容 TTS MCP 服务。AI 可调用它来:

  1. 查询当前模型的可用音色;

  2. 将文本按指定音色和语气转换为音频。

功能

  • list_voices

    • 默认请求 GET /v1/tts/voices?model={OAI_TTS_MODEL}

    • 对 Base URL 自动规整:https://hosthttps://host/v1 均可,绝不会产生 /v1/v1

    • 上游请求失败、超时或响应不包含有效 voices[] 时,返回内置回退音色,并标记 source: "fallback" 和原因。

  • text_to_speech

    • 请求 POST /v1/audio/speech

    • 传入 instructions 即可要求语气/表达,例如“平静、温暖、适合睡前故事,语速自然,句末轻柔收束”。

    • 默认 speed1.25;可选范围 0.254

    • 将音频上传至 Urusai 文件托管并返回公开 HTTPS URL;不返回 Base64 音频,减少上下文和客户端兼容性问题。

Related MCP server: quick-tts-mcp

要求

  • Node.js >= 20

  • pnpm

  • 有效的 OpenAI 或 OpenAI 兼容 TTS 服务地址与 API Key

通过 npx 使用

发布到 npm 后,无需全局安装。MCP 客户端可直接调用:

{
  "mcpServers": {
    "oai-tts": {
      "command": "npx",
      "args": ["-y", "oai-tts-mcp"],
      "env": {
        "OAI_TTS_BASE_URL": "https://api.openai.com/v1",
        "OAI_TTS_API_KEY": "your_api_key_here",
        "OAI_TTS_MODEL": "gpt-4o-mini-tts",
        "OAI_TTS_VOICE": "marin",
        "URUSAI_API_TOKEN": "your_optional_urusai_token"
      }
    }
  }
}

npx -y 会下载并启动 npm 上的最新版本。请始终通过客户端的受保护环境变量注入 Key/Token,勿将真实凭据写入配置仓库。

安装

Set-Location "E:\Programming\oai-tts-mcp"
pnpm install

参照仓库内的 env.example,将以下变量填入 MCP 客户端的 env 配置或受保护的系统环境变量:

OAI_TTS_BASE_URL=https://api.openai.com/v1
OAI_TTS_API_KEY=your_api_key_here
OAI_TTS_MODEL=gpt-4o-mini-tts
OAI_TTS_VOICE=marin

# 可选:Urusai 图床访问令牌。音频将上传至第三方并返回公开 URL;请勿上传敏感内容。
URUSAI_API_TOKEN=your_optional_urusai_token

# 可选:默认 https://api.urusai.cc/v1/upload;仅用于自建兼容上传服务或本机测试。
URUSAI_UPLOAD_URL=https://api.urusai.cc/v1/upload

推荐模型为 gpt-4o-mini-tts,它支持使用 instructions 细调表达。兼容服务是否支持该字段及具体音色,以该服务的实现为准。

构建与启动

pnpm build
pnpm start

开发时:

pnpm dev

MCP 使用 stdio 通信;不要把服务日志写入 stdout。运行日志仅输出至 stderr。

MCP 客户端配置示例

以支持 stdio MCP 的客户端为例,配置命令为:

{
  "mcpServers": {
    "oai-tts": {
      "command": "node",
      "args": ["E:\\Programming\\oai-tts-mcp\\dist\\index.js"],
      "env": {
        "OAI_TTS_BASE_URL": "https://api.openai.com/v1",
        "OAI_TTS_API_KEY": "your_api_key_here",
        "OAI_TTS_MODEL": "gpt-4o-mini-tts",
        "OAI_TTS_VOICE": "marin",
        "URUSAI_API_TOKEN": "your_optional_urusai_token",
        "URUSAI_UPLOAD_URL": "https://api.urusai.cc/v1/upload"
      }
    }
  }
}

服务仅从进程环境变量读取配置;由 MCP 客户端 env 注入是推荐且安全的方式。

工具说明

list_voices

无参数。返回文本摘要和结构化结果:

{
  "voices": [
    { "voice_id": "eve", "name": "Eve", "language": "en" }
  ],
  "source": "remote"
}

若远程音色接口不可用,则返回 source: "fallback"。内置回退集为:

alloyashballadcoralechofablenovaonyxsageshimmerversemarincedar

tts-1tts-1-hd 的可用音色较少;请优先调用 list_voices,并以远程结果为准。

text_to_speech

参数:

参数

必填

说明

input

要朗读的文本,最多 4096 个字符。

voice

音色 ID;缺省时使用OAI_TTS_VOICE

instructions

语气、情绪、节奏、口音或表达方式;gpt-4o-mini-tts 支持效果最佳。

speed

语速倍率,默认1.25,范围 0.254

response_format

mp3(默认)、opusaacflacwavpcm

成功时工具仅返回文本 JSON 和结构化结果,其中 url 是图床返回的公开直链:

{
  "status": "success",
  "url": "https://example.com/oai-tts-...-Eve.mp3",
  "model": "grok-voice-think-fast-2.0",
  "voice": "Eve",
  "speed": 1.25,
  "format": "mp3",
  "mime_type": "audio/mpeg"
}

图床上传失败时,本次调用会返回错误,不会返回 Base64 音频或本地临时路径。

调用意图示例:

使用 text_to_speech,以 marin 音色、温暖平静的睡前故事语气朗读这段文本。

图床上传与安全说明

  • text_to_speech 将音频二进制上传到 Urusai 默认端点 https://api.urusai.cc/v1/upload,成功后使用响应内的 data.url_direct 作为公开直链。

  • 生成的音频会离开本机并可能被持有 URL 的人访问;不要对机密、隐私、个人信息或未获授权的内容使用此工具

  • URUSAI_API_TOKEN 是可选的上传服务令牌;URUSAI_UPLOAD_URL 仅用于覆盖默认端点(例如自建兼容服务)。不要把任一令牌提交到 Git。

  • TTS API Key 和上传 Token 均不会被写入日志、构建产物或仓库;请仅通过 MCP 客户端 env 或受保护的系统环境变量提供。

  • list_voices 上游请求失败会静默降级为公开内置列表;TTS 或上传失败会返回安全的错误摘要,不回显认证信息。

参考

Available Tools

2 tools
list_voices获取可用 TTS 音色A
Read-only

获取当前 OAI_TTS_MODEL 的可用音色。优先调用 GET /v1/tts/voices?model=...;上游失败、超时或响应无效时自动返回内置 OpenAI 音色,并在结构化结果中标记 source=fallback。

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

TDQS

A4.1/5.0
Behavior5/5

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

Beyond the readOnlyHint/openWorldHint annotations, the description discloses the concrete endpoint and query shape (GET /v1/tts/voices?model=...), plus a full fallback policy: on upstream failure, timeout, or invalid response it silently returns built-in OpenAI voices and flags source=fallback. That fallback semantics is exactly the kind of non-obvious behavior an agent cannot get from the annotations.

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

Conciseness5/5

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

Two tightly packed sentences: the purpose first, then the call strategy and fallback contract. Every clause carries information and nothing is repeated from the title or schema.

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

Completeness4/5

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

With no output schema, the description carries the return-value burden and does state that results are structured and include a source marker. It does not describe the shape of the voice entries themselves (identifiers, locale, gender), which the sibling text_to_speech would need, leaving a small gap.

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

Parameters4/5

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

The tool takes zero parameters, so the baseline is 4. The description still adds value by explaining that the model argument sent to the endpoint is derived from the current OAI_TTS_MODEL configuration rather than supplied by the caller, which clarifies why the schema is empty.

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 names a specific verb and resource ('获取当前 OAI_TTS_MODEL 的可用音色') and scopes it to the configured model, so an agent immediately knows this enumerates TTS voices. It never names the sibling text_to_speech, so the distinction is inferred from the resource rather than stated, keeping it just short of a 5.

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

Usage Guidelines3/5

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

Usage is only implied: an agent infers this is the tool to call before text_to_speech to discover a valid voice identifier. There is no explicit when-to-use statement, no when-not condition, and no named alternative, so it lands at the minimum-viable tier.

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

text_to_speech将文本转换为语音A

调用 OpenAI 兼容 POST /v1/audio/speech 生成语音,并上传到 Urusai 文件托管服务。传入 instructions 可指定语气、情绪、节奏或风格;未指定 voice 时使用 OAI_TTS_VOICE;未指定 speed 时默认 1.25。成功后仅返回公开音频 URL。

ParametersJSON Schema
NameRequiredDescriptionDefault
inputYes要转换为语音的文本
speedNo可选,播放速度倍率;默认 1.25
voiceNo可选,目标音色;默认使用 OAI_TTS_VOICE
instructionsNo可选,语气、情绪、节奏、口音或表达方式说明;gpt-4o-mini-tts 支持效果最佳
response_formatNo可选,音频格式;默认 mp3

TDQS

A3.9/5.0
Behavior4/5

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

Annotations already declare readOnlyHint=false, openWorldHint=true, and idempotentHint=false, so the safety profile is covered. The description adds genuinely new behavior: the audio is uploaded to an external file host and only a public URL is returned, plus the env-var default for voice. No return-format or failure behavior beyond that, hence a 4.

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?

Three front-loaded sentences covering the call flow, the instructions knob, and the defaults. Mostly earns its place, though the voice/speed defaults slightly duplicate the schema.

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

Completeness4/5

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

With no output schema, the description usefully specifies the return value (仅返回公开音频 URL) and the upload side effect, and annotations cover the mutation safety profile. Complete enough for correct invocation, missing only error/timeout behavior.

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

Parameters3/5

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

Schema description coverage is 100%, so all five parameters are already documented. The description restates the instructions semantics and the voice/speed defaults already present in the schema, adding little beyond it. Baseline 3 is appropriate.

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

Purpose5/5

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

States a specific verb+resource (调用 POST /v1/audio/speech 生成语音) plus the non-obvious side effect of uploading to Urusai hosting. An agent can distinguish this from the sibling list_voices, which merely enumerates voices, without opening either schema.

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

Usage Guidelines3/5

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

Explains how to use instructions (语气、情绪、节奏、风格) and the fallback behavior for voice and speed, which is useful context. However, it never states when to prefer this tool over list_voices or provides any when-not-to-use guidance, so routing is only implied.

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. 2 tool updatesv0.1.0
    • First observedlist_voices
    • First observedtext_to_speech

TDQS

A4/5.0

Scored across 2 tools

Disambiguation5/5

The two tools have entirely distinct purposes: list_voices enumerates available voices, while text_to_speech synthesizes audio and uploads it. There is no plausible way to confuse them, and the descriptions make the boundary explicit.

Naming Consistency4/5

Both names use consistent snake_case, which is predictable. minor deviation: list_voices follows a verb_noun pattern while text_to_speech is a noun phrase (verb implied), so it is not a perfectly uniform convention.

Tool Count3/5

With only two tools the surface is thin even for a narrowly scoped TTS server, which could reasonably expose model listing, voice preview, or audio retrieval operations. It is not a mismatch, but it sits at the borderline of minimal coverage.

Completeness4/5

The core lifecycle (discover voices, then synthesize speech) is covered, including fallback behavior and defaults for voice/speed. Missing secondary operations like previewing a voice or listing models are gaps agents can work around.

Maintenance

ActivityMaintained
ResponsivenessNo issues

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers