文档
Documentación en Español
Servidores MCP

Servidores MCP

OpenCode soporta el Model Context Protocol (MCP) para agregar herramientas externas a través de servidores locales y remotos.

Importante: Los servidores MCP agregan a tu contexto, así que ten cuidado con cuáles habilitas.

Habilitar Servidores MCP

{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "server-name": {
      "enabled": true
    }
  }
}

Servidores MCP Locales

{
  "mcp": {
    "my-local-server": {
      "type": "local",
      "command": ["npx", "-y", "my-mcp-command"],
      "enabled": true,
      "environment": {
        "MY_ENV_VAR": "value"
      }
    }
  }
}

Opciones de Servidor Local

OpciónTipoRequerido
typeStringSí ("local")
commandArray
environmentObjectNo
timeoutNumberNo (default: 5000)

Servidores MCP Remotos

{
  "mcp": {
    "my-remote-server": {
      "type": "remote",
      "url": "https://my-mcp-server.com",
      "headers": {
        "Authorization": "Bearer API_KEY"
      }
    }
  }
}

Autenticación OAuth

opencode mcp auth server-name
opencode mcp list
opencode mcp logout server-name

Gestionar Herramientas MCP

Global

{
  "tools": {
    "my-mcp*": false
  }
}

Por Agente

{
  "agent": {
    "my-agent": {
      "tools": {
        "my-mcp*": true
      }
    }
  }
}

Ejemplos

Sentry

{
  "mcp": {
    "sentry": {
      "type": "remote",
      "url": "https://mcp.sentry.dev/mcp"
    }
  }
}

Búsqueda de Código GitHub

{
  "mcp": {
    "gh_grep": {
      "type": "remote",
      "url": "https://mcp.grep.app"
    }
  }
}