JSON-translations-MCP-server

JSON-translations-MCP-server

0

The JSON Translations MCP Server is a tool for managing translation files in JSON format, enabling updates and retrievals of translations via a dot-notation path. It supports multiple languages and maintains the original JSON structure.

JSON Translations MCP Server

A Model Context Protocol (MCP) server for updating and retrieving translations in JSON files.

Overview

This MCP server provides two tools: update-translation and get-translation. These tools allow you to update and retrieve translations in JSON files for different languages. It's designed to work with nested translation structures where keys are separated by dots.

Features

  • Update translations in JSON files using a dot-notation path
  • Retrieve translations from JSON files using a dot-notation path
  • Support for multiple language files
  • Preserves JSON structure and formatting
  • Handles nested translation keys
  • Graceful error handling
  • Optional default translations path

Tool: update-translation

Parameters

  • translationId - The translation ID using dot notation (e.g., "common.buttons.save")
  • language - The language code for the translation file (e.g., "sv", "en", ...)
  • path - (Optional) Path to the folder containing translation files. If not provided, the default path set during server initialization will be used.
  • translation - The new translation value to be inserted

Example

{
  "translationId": "common.buttons.save",
  "language": "en",
  "translation": "Save"
}

Tool: get-translation

Parameters

  • translationId - The translation ID using dot notation (e.g., "homepage.welcome.message")
  • language - The language code for the translation file (e.g., "sv", "en", ...)
  • path - (Optional) Path to the folder containing translation files. If not provided, the default path set during server initialization will be used.

Example

{
  "translationId": "homepage.welcome.message",
  "language": "en"
}

Setup and Usage

Prerequisites

  • Node.js or Bun

Installation

From npm
npm install -g json-translations-mcp-server
From source
  1. Clone the repository
  2. Install dependencies:
bun install
# or
npm install

Build

bun run build
# or
npm run build

Run

# 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

Development

Testing

bun test

Project Structure

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

Adding to Claude Desktop

To add the MCP server to Claude Desktop:

If installed from npm

{
  "mcpServers": {
    "json-translations-mcp-server": {
      "command": "json-translations-mcp-server",
      "args": ["--path", "/path/to/translations"]
    }
  }
}

If using from source

  1. Build the project:

    bun run build
    
  2. Add to your Claude Desktop config with default path:

    {
      "mcpServers": {
        "json-translations-mcp-server": {
          "command": "bun",
          "args": [
            "/path/to/your/project/dist/main.js",
            "--path",
            "/path/to/translations"
          ]
        }
      }
    }
    
  3. Or without default path (will require path in each tool call):

    {
      "mcpServers": {
        "json-translations-mcp-server": {
          "command": "bun",
          "args": ["/path/to/your/project/dist/main.js"]
        }
      }
    }
    

License

MIT