使用说明
JSON翻译MCP服务器
用于更新和检索JSON文件翻译的模型上下文协议(MCP)服务器。
概述
此MCP服务器提供两个工具: update-translation 和 get-translation这些工具允许您更新和检索不同语言的JSON文件中的翻译。它设计用于使用嵌套的翻译结构,其中键由点分隔。
特性
- 使用点标记路径更新JSON文件中的翻译
- 使用点符号路径从JSON文件中检索翻译
- 支持多种语言文件
- 保留JSON结构和格式
- 处理嵌套翻译键
- 优雅的错误处理
- 可选默认翻译路径
工具:更新翻译
参数
translationId-使用点符号的翻译ID(例如“common.buttons.save”)language-翻译文件的语言代码(例如,“sv”、“en”等)path-(可选)包含翻译文件的文件夹的路径。如果没有提供,将使用服务器初始化期间设置的默认路径。translation-要插入的新翻译值
示例
{
"translationId": "common.buttons.save",
"language": "en",
"translation": "Save"
}
工具:获取翻译
参数
translationId-使用点符号的翻译ID(例如,“homepage.ewelcome.message”)language-翻译文件的语言代码(例如,“sv”、“en”等)path-(可选)包含翻译文件的文件夹的路径。如果没有提供,将使用服务器初始化期间设置的默认路径。
示例
{
"translationId": "homepage.welcome.message",
"language": "en"
}
设置和使用
先决条件
- Node.js或Bun
安装
来自npm
npm install -g json-translations-mcp-server
来源
- 克隆存储库
- 安装依赖项:
bun install
# or
npm install
构建
bun run build
# or
npm run build
跑
# If installed from npm globally
json-translations-mcp-server --path /path/to/translations
# or
json-translations-mcp-server -p /path/to/translations
# If running from source
bun start --path /path/to/translations
# or
npm run start -- --path /path/to/translations
发展
测试
bun test
项目结构
json-translations-mcp-server/
├── src/
│ ├── main.ts # Server entry point
│ └── tools/
│ ├── updateTranslation/
│ │ ├── index.ts # Tool implementation
│ │ └── schema.ts # Tool schema
│ └── getTranslation/
│ ├── index.ts # Tool implementation
│ └── schema.ts # Tool schema
├── tests/ # Test files
├── biome.json # Linting configuration
├── tsconfig.json # TypeScript configuration
└── package.json # Project dependencies
添加到Claude桌面
要将MCP服务器添加到Claude Desktop,请执行以下操作:
如果从npm安装
{
"mcpServers": {
"json-translations-mcp-server": {
"command": "json-translations-mcp-server",
"args": ["--path", "/path/to/translations"]
}
}
}
如果从源代码使用
-
构建项目:
bun run build -
使用默认路径添加到您的Claude Desktop配置中:
{ "mcpServers": { "json-translations-mcp-server": { "command": "bun", "args": [ "/path/to/your/project/dist/main.js", "--path", "/path/to/translations" ] } } } -
或者没有默认路径(每次工具调用都需要路径):
{ "mcpServers": { "json-translations-mcp-server": { "command": "bun", "args": ["/path/to/your/project/dist/main.js"] } } }
许可证
麻省理工学院