native

command module
v0.0.0-...-f80ff9f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 4, 2026 License: MIT Imports: 13 Imported by: 0

README

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.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
pkgs

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL