Documentation
¶
Overview ¶
Demonstrates WithMCPServers: attach an external MCP server to every new session. The server runs in its own process — opencode launches it over whichever transport is declared (stdio, HTTP, or SSE) and discovers its tools automatically.
This example defaults to the everything-server reference implementation over stdio:
npx -y @modelcontextprotocol/server-everything
Override the command + args with the EXTERNAL_MCP_COMMAND (space-separated) environment variable to point at a different stdio MCP server, e.g.
EXTERNAL_MCP_COMMAND="uvx mcp-server-time" go run ./examples/external_mcp
For HTTP/SSE transports, substitute `acp.McpServer{Http: ...}` for the stdio block below.
Click to show internal directories.
Click to hide internal directories.