Skilllibrary opencode-bridge
Connect MCP servers to the OpenCode agent runtime. Use when configuring MCP servers for OpenCode, adapting existing MCP servers to work with OpenCode's conventions, or troubleshooting OpenCode-MCP integration issues.
install
source · Clone the upstream repo
git clone https://github.com/merceralex397-collab/skilllibrary
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/merceralex397-collab/skilllibrary "$T" && mkdir -p ~/.claude/skills && cp -r "$T/07-mcp/opencode-bridge" ~/.claude/skills/merceralex397-collab-skilllibrary-opencode-bridge && rm -rf "$T"
manifest:
07-mcp/opencode-bridge/SKILL.mdsource content
Purpose
Bridge MCP servers into the OpenCode agent runtime. OpenCode is an open-source terminal-based AI coding agent that supports MCP servers for extending its capabilities. This skill covers OpenCode-specific configuration, conventions, and integration patterns.
When to use this skill
- Configuring MCP servers for use with OpenCode
- Adapting an existing MCP server to work with OpenCode's agent model
- Troubleshooting OpenCode-MCP connection issues
- Understanding how OpenCode discovers and invokes MCP tools
Do not use this skill when
- Targeting Claude Desktop, VS Code, Codex, or other hosts → use
mcp-host-integration - Building the MCP server itself → use
mcp-development - Working on OpenCode's internal primitives → use
opencode-primitives
Operating procedure
Phase 1 — OpenCode MCP configuration
OpenCode reads MCP server configuration from its project config file (
.opencode/config.json) or environment config.
Local stdio server:
{ "mcpServers": { "my-server": { "command": "node", "args": ["/absolute/path/to/dist/index.js"], "env": { "API_KEY": "your-key" } } } }
Remote Streamable HTTP server:
{ "mcpServers": { "remote-server": { "url": "https://my-server.example.com/mcp", "headers": { "Authorization": "Bearer <token>" } } } }
Phase 2 — OpenCode integration patterns
Tool usage in OpenCode:
- OpenCode discovers tools via
during initializationtools/list - The agent decides when to call tools based on descriptions and the user's request
- Tool results are incorporated into the agent's context for further reasoning
Best practices for OpenCode:
- Keep tool descriptions concise and action-oriented — OpenCode's agent model benefits from clarity
- Return text content (not just structured content) — OpenCode displays text to the user
- Tools that read/write files should use absolute paths — OpenCode runs from the project root
- Error messages should suggest next steps — the agent uses them to recover
Resources and Prompts:
- OpenCode supports MCP tools as its primary integration point
- Resource and prompt support varies — test with the specific OpenCode version
Phase 3 — Debugging OpenCode connections
- Verify the server works independently with MCP Inspector first
- Check config file path and JSON validity
- Ensure command paths are absolute
- Check that env vars are set in the config
blockenv - Restart OpenCode after config changes
- Check OpenCode logs for MCP connection errors
Decision rules
- Use stdio transport for local servers with OpenCode (default and best-supported)
- Use absolute paths in all config entries
- Set secrets in config
block, not system environmentenv - Test with MCP Inspector before connecting to OpenCode
- Keep tool count reasonable (<30) for best agent tool selection
Output requirements
- OpenCode configuration file with MCP server entry
- Verified tool discovery in OpenCode
- Verified tool invocation end-to-end
Related skills
— OpenCode paths, naming, and config primitivesopencode-primitives
— general host configuration patternsmcp-host-integration
— debugging server issues before connecting to OpenCodemcp-inspector-debugging
Failure handling
- If OpenCode doesn't see tools, restart it after config changes — config is read at startup
- If connection times out, check that the server process starts within the timeout window
- If tools are visible but calls fail, check server stdout for non-JSON-RPC output (breaks stdio)