# Serveur MCP

LibreTranslate peut fournir des capacités de traduction automatique aux agents IA qui prennent en charge le protocole [MCP](https://modelcontextprotocol.io/docs/getting-started/intro).


## Configuration {#configuration}


Ajoutez ceci à la configuration de votre client :


### 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 de l'API LibreTranslate (par défaut : `https://libretranslate.com`)               |
| `LIBRETRANSLATE_API_KEY` | Clé API pour le service LibreTranslate (requise pour `libretranslate.com`) |



## Outils disponibles {#outils-disponibles}



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


Détecter la langue d'un texte donné.


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


Traduire un texte d'une langue à une autre.


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


Lister toutes les langues prises en charge pour la traduction.

Voir [LibreTranslate-MCP](https://github.com/LibreTranslate/LibreTranslate-MCP) pour les détails d'implémentation.



## Outils et points de terminaison HTTP {#outils-et-points-de-terminaison-http}


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

L’outil `translate` demande trois traductions alternatives. Les outils renvoient du JSON sous forme de texte dans un bloc de contenu MCP ; les requêtes en échec portent `isError: true`.



> [!NOTE]
> **Où la traduction est effectuée**
>
> Le processus MCP s’exécute sur votre machine. La traduction est effectuée par l’instance LibreTranslate définie dans `LIBRETRANSLATE_API_URL`. Pour utiliser votre propre instance, indiquez son adresse ; consultez le [guide d’auto-hébergement](https://sourcey-libretranslate.pages.dev/fr/guides/installation/index.md).
