MCP-Lingvanex-Translate Server
官方Lingvanex MCP Server Cloud API – 一個模型上下文協定伺服器,透過 Lingvanex Cloud API 提供快速且準確的文字翻譯。支援超過 100 種語言,並可與 Claude Desktop 及其他相容 MCP 的客戶端無縫整合。
文件
MCP 原型 – 翻譯伺服器
本專案實作了一個用於文字翻譯的 MCP(模型上下文協定)伺服器。該伺服器支援兩種傳輸方式:
- stdio – 用於與 Claude Desktop 整合
- http(可串流) – 用於透過 HTTP + SSE 進行測試與操作
⚙️ 需求
- Node.js >= 18
- Yarn 或 npm
- 已安裝 Claude Desktop(用於 stdio 整合)
- 用於文字翻譯的 Lingvanex Translator 帳戶
🔑 Lingvanex Translator 設定
若要使用 Lingvanex Translator,您需要一個 Lingvanex 帳戶。
- 如果您還沒有帳戶,請免費註冊
- 前往 Cloud API 分頁:Cloud API
- 填寫 帳單地址 資料
- 點擊 繼續付款
- 若要取得免費試用,不需要 新增您的付款卡
- 您的 API 金鑰 將會產生並顯示在 Cloud API 分頁中:API 金鑰
現在您已準備好開始使用翻譯 API。以下是整體流程的影片教學(如果 Lingvanex 網站上有提供的話)。
🚀 安裝與建置
複製儲存庫
git clone https://github.com/lingvanex-mt/MCP-Lingvanex-Translate.git cd mcp-prototype
安裝相依套件
yarn install
🔌 以 stdio 模式執行(Claude Desktop)
stdio 模式由 Claude Desktop 用於連接到本機 MCP 伺服器。
設定環境變數:
TRANSPORT=stdio
啟動伺服器:
yarn build yarn start
預期輸出:
MCP stdio transport running
Translate MCP Server ready
🌐 以 HTTP 模式執行(可串流)
http 模式會執行一個帶有 HTTP 傳輸的本機 HTTP 伺服器。適用於瀏覽器測試或與 curl 搭配使用。
設定環境變數:
TRANSPORT=http HTTP_PORT=3000
測試伺服器:
curl http://127.0.0.1:3000/ping
預期回應:
{ "status": "ok", "transport": "http" }
使用 MCP Inspector 進行除錯:
npx @modelcontextprotocol/inspector
在 MCP Inspector 使用者介面中,選擇 Transport Type - Streamable HTTP;URL - http://localhost:3000/mcp. 點擊 Connect。
🖥️ 與 Claude Desktop 整合
Claude Desktop 透過設定檔來探索本機 MCP 伺服器:
- Windows:
%APPDATA%\Claude\claude_desktop_config.json - macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Linux:
~/.config/Claude/claude_desktop_config.json
設定範例(Windows)
開啟(或建立)claude_desktop_config.json 並新增:
{ "mcpServers": { "translate": { "command": "node", "args": [ "C:\Users\path\to\project\dist\index.js" ] } } }
⚠️ 請務必在建置後更新指向您本機
dist/index.js的路徑!
✅ 如何驗證
- 啟動 Claude Desktop。
- 輸入一個請求,例如:"使用 MCP 工具
translatetext將 'Hello world' 翻譯成俄語。" - 如果一切設定正確,Claude 將會呼叫您的 MCP 伺服器並回傳翻譯結果。
📌 可用工具
translate_text
將文字從一種語言翻譯成另一種語言。
參數:
text– 要翻譯的文字sourceLang– 來源語言代碼(例如"en")targetLang– 目標語言代碼(例如"ru")
請求範例:
{ "tool": "translate_text", "args": { "text": "Good morning", "sourceLang": "en", "targetLang": "fr" } }
回應範例:
{ "content": [ { "type": "text", "text": "Bonjour" } ] }