A stdio-based MCP (Model Context Protocol) server that provides translation between Chinese and English using the Youdao translation API.
-
Dual Mode Operation
- Pure text mode: Pipe text directly for translation
- MCP protocol mode: Full JSON-RPC MCP support
-
Auto Language Detection
- Automatically detects source language (Chinese/English)
- Translates to the opposite language by default
-
Youdao Translation API
- Uses the free public Youdao API
- No API key required
go build -o native main.goPipe plain text to get translation:
# English to Chinese
echo "hello world" | ./native
# Output: δ½ ε₯½δΈη
# Chinese to English
echo "δ½ ε₯½δΈη" | ./native
# Output: hello worldUse via any MCP-compatible client (e.g., Claude Desktop):
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "translate",
"arguments": {
"text": "hello world"
}
}
}Response:
{
"original_text": "hello world",
"translated_text": "δ½ ε₯½δΈη",
"source_lang": "en",
"target_lang": "zh-CN"
}Arguments:
| Name | Type | Required | Description |
|---|---|---|---|
| text | string | Yes | Text to translate |
| source_lang | string | No | Source language (en, zh-CN) |
| target_lang | string | No | Target language (en, zh-CN) |
native/
βββ main.go # Entry point with mode detection
βββ go.mod
βββ go.sum
βββ LICENSE # MIT License
βββ .gitignore
βββ .markdownlint.json
βββ README.md
βββ pkgs/
βββ domain/ # Business entities
β βββ entity.go
β βββ repository.go
βββ application/ # Use cases
β βββ service.go
βββ infrastructure/ # External implementations
βββ translator/
βββ youdao.go
The project follows Domain-Driven Design (DDD) principles:
- Domain Layer: Business entities and repository interfaces
- Application Layer: Use cases and orchestration
- Infrastructure Layer: External service implementations (Youdao API)
Logs are written to ~/logs/native-mcp.log to avoid polluting stdio.
MIT License - see LICENSE for details.