# Servidor MCP

LibreTranslate puede dar capacidades de traducción automática a agentes de IA que soporten el protocolo [MCP](https://modelcontextprotocol.io/docs/getting-started/intro).


## Configuración {#configuración}


Añade esto a la configuración de tu cliente:


### 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                 | Descripción                                                                |
| ------------------------ | -------------------------------------------------------------------------- |
| `LIBRETRANSLATE_API_URL` | URL de la API de LibreTranslate (por defecto: `https://libretranslate.com`)      |
| `LIBRETRANSLATE_API_KEY` | Clave de API para el servicio LibreTranslate (requerida para `libretranslate.com`) |



## Herramientas disponibles {#herramientas-disponibles}



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


Detecta el idioma de un texto dado.


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


Traduce texto de un idioma a otro.


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


Lista todos los idiomas soportados para la traducción.

Consulta [LibreTranslate-MCP](https://github.com/LibreTranslate/LibreTranslate-MCP) para detalles de implementación.



## Herramientas y endpoints HTTP {#herramientas-y-endpoints-http}


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

La herramienta `translate` solicita tres traducciones alternativas. Las herramientas devuelven JSON como texto en un bloque de contenido MCP; las solicitudes fallidas incluyen `isError: true`.



> [!NOTE]
> **Dónde se realiza la traducción**
>
> El proceso MCP se ejecuta en tu equipo. La traducción se realiza en la instancia de LibreTranslate indicada por `LIBRETRANSLATE_API_URL`. Para usar tu propia instancia, configura su dirección; consulta la [guía de autoalojamiento](https://sourcey-libretranslate.pages.dev/es/guides/installation/index.md).
