MCP Reference

Translate text, detect its language, and list supported languages from an MCP client. The server runs locally over stdio and forwards requests to the LibreTranslate instance you configure.

Set up your client for the hosted service or your own instance. The HTTP API also supports file translation and other operations beyond these three tools.

Connect your client

Add to your MCP client configuration:

{
  "mcpServers": {
    "libretranslate-mcp": {
      "command": "npx",
      "args": [
        "--yes",
        "@libretranslate/mcp@1.0.2"
      ],
      "env": {
        "LIBRETRANSLATE_API_URL": "https://libretranslate.com",
        "LIBRETRANSLATE_API_KEY": "your-api-key"
      }
    }
  }
}
Protocol MCP 2025-11-25Transport stdioCapabilities tools

Tools

detect

TOOL

Detect the language of a given text

Sends text as q to POST /detect on your configured instance.

Returns the first detection from the API: language is its language code and confidence is a score from 0 to 100. The tool returns one detection, even when the HTTP API supplies several. The JSON is encoded in content[0].text.

Errors. Failed requests set isError: true and return an error message in the JSON text block.

Response examples

Decoded success result:

{
  "language": "en",
  "confidence": 100
}

Decoded failure result (isError: true):

{
  "error": "No detection result returned"
}

Parameters

textstringrequired

Text to identify.

translate

TOOL

Translate text from one language to another

Sends text as q, together with source and target, to POST /translate on your configured instance.

Returns translatedText and requests up to three alternatives. With source: "auto", the API can also return detectedLanguage. Available alternatives depend on your instance’s models. The JSON is encoded in content[0].text.

Errors. Failed requests set isError: true and return an error message in the JSON text block. The managed service requires LIBRETRANSLATE_API_KEY; self-hosted instances use their own access settings.

Response examples

Decoded success result:

{
  "translatedText": "Hola",
  "alternatives": [
    "Hola."
  ]
}

Decoded failure result (isError: true):

{
  "error": "Unsupported target language"
}

Parameters

textstringrequired

Text to translate.

sourcestringrequired

Source language code, or auto for automatic detection.

targetstringrequired

Target language code, such as es for Spanish.

languages

TOOL

List all supported languages for translation

Calls GET /languages on your configured instance. No arguments are needed.

Returns an array of languages. Each entry has a code and an English name; the API can also supply targets, the language codes that entry can translate into. Use this list when choosing source and target for a translation. The JSON is encoded in content[0].text.

Errors. Failed requests set isError: true and return an error message in the JSON text block.

Response examples

Decoded success result:

[
  {
    "code": "en",
    "name": "English",
    "targets": [
      "es"
    ]
  },
  {
    "code": "es",
    "name": "Spanish",
    "targets": [
      "en"
    ]
  }
]

Decoded failure result (isError: true):

{
  "error": "Languages request failed: 503 Service Unavailable"
}