Skip to main content
Glama
NiuTrans

MCP Translation Text

by NiuTrans

MCP 翻译服务

基于小牛翻译(NiuTrans)API 的 MCP Provider,提供文字翻译工具和语种目录资源,方便在 Cursor/mcp-cli 等客户端中引用。

快速开始

使用 uv 安装并启动发布版

uv tool install mcp-translation-text

Related MCP server: DeepL MCP Server

环境变量

计费说明

本服务使用小牛翻译的文本翻译 API,计费规则如下:

项目

说明

计费单位

2000 字符 = 1 积分

免费额度

每天免费赠送 100 积分

每日可翻译

20 万字符(免费额度)

💡 提示:每日免费赠送的 100 积分足够日常使用,超出部分可在小牛翻译开放平台充值购买。

MCP 客户端配置示例

若通过 uv tool install 安装,可在 mcp.json 中写:

{
  "mcpServers": {
    "translation": {
      "type": "stdio",
      "command": "uv",
      "args": [
        "tool",
        "run",
        "mcp-translation-text"
      ],
      "env": {
        "NIUTRANS_API_KEY": "${env.NIUTRANS_API_KEY}"
      }
    }
  }
}

启动 Cursor 后执行 ListTools 即可看到 translate_text,同时支持 ListResources 读取 language://catalog

可用功能

工具:translate_text

  • 参数

    • text:待翻译内容。

    • source:源语言代码或别名(会通过本地映射表规范化)。

    • target:目标语言代码或别名。

  • 返回

    {
      "source": "zh",
      "target": "en",
      "original_text": "你好",
      "translated_text": "Hello",
      "raw": { ... 小牛原始响应 ... }
    }

资源:language://catalog

提供所有可用语种及别名,示例如下:

{
  "total": 455,
  "languages": [
    {"code": "zh", "zh": "中文(简体)", "en": "Chinese (Simplified)"},
    {"code": "en", "zh": "英语", "en": "English"}
    // ... 其余省略 ...
  ],
  "aliases": {
    "zhongwenjianti": "zh",
    "english": "en"
    // ... 其余省略 ...
  }
}

推荐在客户端的 LLM 中先读取该资源,完成语种描述到代码的映射后,再调用 translate_text

调试与常见问题

  • 缺少 API Key:启动时报 缺少环境变量 NIUTRANS_API_KEY,请确认已在 .env 或系统环境中设置。

  • 语种不支持translate_text 会校验语种代码/别名,若报错请检查是否使用了 language://catalog 中列出的值。

  • 路径或依赖问题:脚本依赖 uv,请先安装 pip install uv 或参考 uv 文档

  • 命令名称:通过 PyPI 安装后,可直接运行 mcp-translation-text;若 global PATH 中找不到,记得激活虚拟环境或使用 python -m mcp_translation_text

  • 发布/升级包

    python -m build
    twine upload dist/*

目录结构(关键文件)

E:\MCP
├── pyproject.toml
├── server.py                # 入口包装,确保 python server.py 可运行
├── src/
│   └── translation_server.py
├── scripts/
│   ├── start.ps1
│   └── start.sh
├── .env.example
├── LICENSE
└── README.md

发布后,用户只需设置 NiuTrans API Key,即可通过 mcp-translation-text 直接加载该 Provider。

Available Tools

1 tool
translate_textA

使用小牛翻译 API 将文本从 source 语种翻译到 target 语种。

支持 450+ 种语言代码,并可自动处理常见别名。返回结构包含译文和 API 原始响应。

Args:
    text (str): 待翻译的原文文本,可以是任意长度的字符串。
    source (str): 源语言代码或常见别名(例如 "zh"、"中文"、"chinese")。
    target (str): 目标语言代码或常见别名(例如 "en"、"英文"、"english")。

Returns:
    Dict[str, Any]: 包含以下字段的字典:
        - source: 标准化后的源语言代码
        - target: 标准化后的目标语言代码
        - original_text: 原文
        - translated_text: 译文
        - raw: 小牛翻译 API 的原始响应数据
ParametersJSON Schema
NameRequiredDescriptionDefault
textYes待翻译的原文文本,可以是任意长度的字符串。
sourceYes源语言代码或常见别名(例如 "zh"、"中文"、"chinese")。
targetYes目标语言代码或常见别名(例如 "en"、"英文"、"english")。

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4/5.0
Behavior4/5

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

With no annotations provided, the description carries full burden and does well by disclosing key behavioral traits: it specifies the external API integration ('小牛翻译 API'), mentions support for 450+ languages with alias handling, and describes the return structure. However, it doesn't cover rate limits, authentication needs, or error handling.

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?

The description is efficiently structured with a clear purpose statement upfront, followed by organized parameter and return value sections. Every sentence adds value without redundancy, making it easy to parse quickly.

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?

Given the tool's moderate complexity, 100% schema coverage, and presence of an output schema, the description is mostly complete. It covers purpose, parameters, and returns adequately, though it could benefit from mentioning authentication requirements or error scenarios for full completeness.

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 the baseline is 3. The description adds minimal value beyond the schema by briefly restating parameter purposes in the Args section, but doesn't provide additional semantic context like examples beyond what's already in the schema descriptions.

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?

The description clearly states the specific action ('使用小牛翻译 API 将文本从 source 语种翻译到 target 语种') with the resource (text) and scope (450+ languages with alias handling). It precisely defines what the tool does without being tautological or vague.

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?

The description implies usage context through language support details and API integration, but there are no explicit guidelines on when to use this tool versus alternatives. Since no sibling tools are provided, this is adequate but lacks proactive guidance about potential edge cases or limitations.

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 update
    • First observedtranslate_text

TDQS

A4.1/5.0

Scored across 1 tool

Disambiguation5/5

With only one tool, there is no possibility of ambiguity or overlap between tools. The single translate_text tool has a clearly defined purpose that cannot be confused with any other tool in this server.

Naming Consistency5/5

With only one tool, naming consistency is inherently perfect. The tool follows a clear verb_noun pattern (translate_text) that would serve as a good model if more tools were added.

Tool Count2/5

A single tool for a translation server feels thin and incomplete. While translation is a focused task, even basic translation workflows might benefit from additional tools like language detection, batch translation, or translation history management. One tool is insufficient for proper coverage of the domain.

Completeness2/5

The server provides only a single translation endpoint with no supporting operations. There are significant gaps: no language detection tool, no batch translation capability, no way to list supported languages, and no management of translation history or preferences. The surface is severely incomplete for a translation service.

Maintenance

ActivityInactive
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables translation and text rephrasing using DeepL's API through a cloud-deployed MCP server. Provides translation between multiple languages, text rephrasing, and language detection capabilities with professional deployment features.
    MIT
  • A
    license
    A
    quality
    D
    maintenance
    Provides text translation capabilities using the Niutrans API, supporting 455+ languages with code/alias mapping through a language catalog resource.
    1
    5
    MIT

Appeared in Searches