TranslateGemma MCP Server

TranslateGemma MCP Server

Enables on-device text translation via a local TranslateGemma LLM API, supporting multiple language pairs with automatic retries and rate limiting for privacy and low latency.

Category
访问服务器

README

🌐 TranslateGemma MCP Server

A Model Context Protocol (MCP) server that provides high-quality text translation via the local TranslateGemma LLM API. Designed for low-latency, private, and secure on-device translation with full control over the underlying model.

✨ Features

  • Local Translation Inference: Leverages TranslateGemma (or compatible OpenAI-like API) on your machine — no external data leaves your device.
  • Multi-Language Support: Translate between any language pairs using standardized BCP-47 codes (en, de-DE, fr-FR, ja-JP, etc.).
  • Automatic Retries & Rate Limiting: Built-in exponential backoff and 30 req/min rate limiting for stability.
  • Robust Error Handling: Graceful failures with clear, actionable error messages.
  • Browser/Client Friendly: CORS-enabled HTTP endpoint for direct integration.
  • LLM-Ready Output: Clean, structured responses optimized for tool-use workflows.

🛠️ Requirements

  • Python 3.9+
  • fastmcp, uvicorn, httpx, and starlette
  • A local TranslateGemma-compatible server (e.g., running via ollama, vllm, or custom server) exposing an OpenAI /v1/chat/completions endpoint.
pip install fastmcp uvicorn httpx starlette

🚀 Installation & Usage

1. Clone & Prepare

git clone https://github.com/your-username/translategemma-mcp-server.git
cd translategemma-mcp-server

2. Start TranslateGemma Backend

Ensure your TranslateGemma API is accessible at http://127.0.0.1:8080/v1/chat/completions (or configure via --api-url).

llama-server -ngl 99 -m translategemma-27b-it.Q6_K.gguf -c 8000 --no-jinja

3. Launch the MCP Server

python3 server.py --host 0.0.0.0 --port 3000

Or override the API endpoint:

python3 server.py --api-url http://192.168.1.100:8000/v1/chat/completions

The server exposes an MCP-compatible HTTP endpoint at http://localhost:3000/mcp.


🧰 Available Tools

translate

Translates text using TranslateGemma with intelligent language handling.

async def translate(
    text: str,
    source_lang_code: str,
    target_lang_code: str,
    ctx: Context,
    max_retries: int = 2,
) -> str

Parameters

Name Type Description
text str Required. The text to translate (up to ~2k chars recommended).
source_lang_code str Required. Source language code (e.g., "en", "auto", "zh-Hans").
target_lang_code str Required. Target language code (e.g., "de-DE", "fr-FR", "ja-JP").
ctx Context MCP context (auto-injected). Used for logging.
max_retries int Retry attempts on transient failures (default: 2).

Returns

  • ✅ Translated text (clean, trimmed)
  • ❌ Error message (prefixed with ❌ / ⚠️) on failure

⚙️ Configuration

CLI Flag Environment Default Description
--host HOST 127.0.0.1 Server host (use 0.0.0.0 for external access)
--port PORT 3000 Server port
--api-url API_URL http://127.0.0.1:8080/v1/chat/completions TranslateGemma API endpoint

🔒 Security & Privacy

  • All translation is performed locally on your machine.
  • No telemetry, external tracking, or data collection.
  • CORS configured permissively (*) for local dev — restrict origins in production.

📄 License

MIT License — see LICENSE for details.


推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选