Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ts-mcp

中英互译工具,支持终端直接使用和 Claude Code 集成,翻译由独立 LLM API 完成,不消耗 Claude Code 的 token。


安装

第一步:设置凭据

npx github:Cameron-xuan/ts-mcp config TS_API_KEY=你的密钥 TS_BASE_URL=https://你的API地址 TS_MODEL=你的模型名

常见服务配置:

服务 TS_BASE_URL TS_MODEL
豆包(火山引擎) https://ark.cn-beijing.volces.com/api/v3 doubao-seed-translation-250915
DeepSeek https://api.deepseek.com deepseek-chat
OpenAI 不填 gpt-4o-mini

第二步:安装

npx github:Cameron-xuan/ts-mcp install
source ~/.zshrc

完成。以后更新版本只需重跑第二步,凭据不会丢失。


使用方式

方式一:普通终端

t Hello world          # 英译中
t 苹果                 # 中译英
ts Hello world         # 英译中 + Samantha 朗读
ts 你好世界            # 中译英 + Samantha 朗读

新开终端自动生效,无需重新 source。

方式二:Claude Code 终端

在 Claude Code 对话框输入,! 前缀直接执行 shell 命令,不经过当前 AI:

! t Hello world
! ts 你好世界

方式三:Claude Code slash 命令

重启 Claude Code 后生效。当前 AI 会调用 MCP 工具完成翻译(消耗少量 claude code token):

/t Hello world
/ts 你好世界

ts 与 t 的区别

命令 功能
t / /t 纯翻译,输出文字结果
ts / /ts 翻译 + macOS Samantha 语音朗读英文部分

朗读逻辑:

  • 输入英文 → 朗读原文(帮助记忆发音)
  • 输入中文 → 朗读英文译文

更新凭据

随时切换 API 服务商,无需重新安装:

# 换 key
npx github:Cameron-xuan/ts-mcp config TS_API_KEY=新密钥

# 换模型
npx github:Cameron-xuan/ts-mcp config TS_MODEL=deepseek-chat

# 换服务商(多项同时改)
npx github:Cameron-xuan/ts-mcp config TS_BASE_URL=https://api.deepseek.com TS_MODEL=deepseek-chat TS_API_KEY=新密钥

修改立即生效,不需要重启。


卸载

npx github:Cameron-xuan/ts-mcp uninstall

自动清理 ~/.zshrc 函数、~/.claude/commands/ 文件、~/.claude.json 配置。


已知限制

技术词汇可能不翻译doubao-seed-translation-250915 是专业翻译模型,对中文技术圈直接沿用的英文词(如 shelltokencache)会原样返回,因为这在中文技术语境下是正确的。

如需翻译所有单词,可切换到聊天模型:

npx github:Cameron-xuan/ts-mcp config TS_MODEL=doubao-seed-2-0-pro-260215

常见问题

command not found: tcommand not found: ts

source ~/.zshrc

401 Unauthorized

npx github:Cameron-xuan/ts-mcp config TS_API_KEY=正确的密钥

404 Not Found

npx github:Cameron-xuan/ts-mcp config TS_BASE_URL=https://正确地址 TS_MODEL=正确模型名

查看当前配置

npx github:Cameron-xuan/ts-mcp config

About

An AI-based Chinese-English translation service running in the terminal

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages