Skip to content

Worthies/Native

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

native - MCP Translation Server

A stdio-based MCP (Model Context Protocol) server that provides translation between Chinese and English using the Youdao translation API.

Features

  • 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

Installation

go build -o native main.go

Usage

Pure Text Mode

Pipe plain text to get translation:

# English to Chinese
echo "hello world" | ./native
# Output: δ½ ε₯½δΈ–η•Œ

# Chinese to English
echo "δ½ ε₯½δΈ–η•Œ" | ./native
# Output: hello world

MCP Protocol Mode

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

MCP Tool: translate

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)

Project Structure

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

Architecture

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)

Logging

Logs are written to ~/logs/native-mcp.log to avoid polluting stdio.

License

MIT License - see LICENSE for details.

About

A translator based on youdao APIπŸš€πŸš€πŸš€

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages