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ón | Tipo | Requerido |
|---|---|---|
type | String | Sí ("local") |
command | Array | Sí |
environment | Object | No |
timeout | Number | No (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-nameGestionar 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"
}
}
}