# MCP Server

LibreTranslate can give machine translation capabilities to AI agents that support the [MCP](https://modelcontextprotocol.io/docs/getting-started/intro) protocol.


## Configuration {#configuration}


Add this to your client's configuration:


### OpenCode {#opencode}


```json
{
  "mcp": {
    "LibreTranslate": {
      "type": "local",
      "command": ["npx", "-y", "@libretranslate/mcp"],
      "environment": {
        "LIBRETRANSLATE_API_URL": "https://libretranslate.com",
        "LIBRETRANSLATE_API_KEY": "your-api-key"
      }
    }
  }
}
```


### Claude {#claude}


```json
{
  "mcpServers": {
    "libretranslate": {
      "command": "npx",
      "args": ["-y", "@libretranslate/mcp"],
      "env": {
        "LIBRETRANSLATE_API_URL": "https://libretranslate.com",
        "LIBRETRANSLATE_API_KEY": "your-api-key"
      }
    }
  }
}
```

| Variable                 | Description                                                                |
| ------------------------ | -------------------------------------------------------------------------- |
| `LIBRETRANSLATE_API_URL` | URL of the LibreTranslate API (default: `https://libretranslate.com`)      |
| `LIBRETRANSLATE_API_KEY` | API key for the LibreTranslate service (required for `libretranslate.com`) |



## Available Tools {#available-tools}



### [`detect`](https://sourcey-libretranslate.pages.dev/mcp/index.md#operation-detect-tool) {#detect}


Detect the language of a given text.


### [`translate`](https://sourcey-libretranslate.pages.dev/mcp/index.md#operation-translate-tool) {#translate}


Translate text from one language to another.


### [`languages`](https://sourcey-libretranslate.pages.dev/mcp/index.md#operation-languages-tool) {#languages}


List all supported languages for translation.

See [LibreTranslate-MCP](https://github.com/LibreTranslate/LibreTranslate-MCP) for implementation details.


## Tools and HTTP endpoints {#tools-and-http-endpoints}


| MCP | Arguments | HTTP request |
| --- | --- | --- |
| [`detect`](https://sourcey-libretranslate.pages.dev/mcp/index.md#operation-detect-tool) | `text` | [`POST /detect`](https://sourcey-libretranslate.pages.dev/api/operations/detect/index.md) |
| [`translate`](https://sourcey-libretranslate.pages.dev/mcp/index.md#operation-translate-tool) | `text`, `source`, `target` | [`POST /translate`](https://sourcey-libretranslate.pages.dev/api/operations/translate/index.md) |
| [`languages`](https://sourcey-libretranslate.pages.dev/mcp/index.md#operation-languages-tool) | None | [`GET /languages`](https://sourcey-libretranslate.pages.dev/api/operations/languages/index.md) |

The `translate` tool requests three alternatives. The tools return JSON as text in an MCP content block; failed requests carry `isError: true`.



> [!NOTE]
> **Where translation runs**
>
> The MCP process runs on your machine. Translation happens on the LibreTranslate instance named by `LIBRETRANSLATE_API_URL`. To use your own instance, set this to its address; see the [self-hosting guide](https://sourcey-libretranslate.pages.dev/guides/installation/index.md).
