External Tool Integration with MCP
Discover how to use MCP servers to add prebuilt external tool integrations into OpenCode. Learn configuration methods for local and remote MCP servers, manage authentication including OAuth, control available tools, and understand best practices to enhance your AI coding agent's capabilities within your workflow.
We'll cover the following...
- What are MCP servers?
- What types of MCP servers exist?
- How do we configure an MCP server?
- How do we add a local MCP server?
- How do we add a remote MCP server?
- How does OAuth authentication work?
- What if we have preregistered client credentials?
- How do we manage OAuth credentials?
- Can we disable OAuth for API key-based servers?
- How do we control which MCP tools are available?
- What should we know about MCP and context?
- What are some practical MCP server examples?
- How do we tell OpenCode to use MCP tools?
- What’s the difference between MCP servers and custom tools?
- Can we build our own MCP server?
- What’s the time-out configuration?
- What’s next?
So far, we’ve extended OpenCode with custom tools and commands. But what if you want to integrate with services like Sentry, GitHub, or internal APIs without building and maintaining your own tools? That’s where MCP (Model Context Protocol) servers come in.
MCP servers provide prebuilt integrations that we can add to OpenCode through configuration. They extend OpenCode’s capabilities by connecting it to external systems, giving the model access to tools it wouldn’t have otherwise.
What are MCP servers?
MCP servers are external programs that expose tools to OpenCode through a standard protocol. Instead of writing custom tool code, we configure OpenCode to connect to an MCP server, and all of that server’s tools are automatically available to the model.
Think of MCP servers as plugin systems. A Sentry MCP server provides OpenCode tools for querying issues and projects. A GitHub MCP server provides OpenCode tools for searching code and managing repositories. These tools work exactly like built-in tools; OpenCode decides when to call them based on context.
The key advantage is reusability. Someone else has already written and maintained these integrations. We just configured OpenCode to use them.
What types of MCP servers exist?
MCP servers come in two forms:
Local MCP servers run on our machine as separate processes. OpenCode starts them using a command (like
npxorbun), and they communicate over standard input/output. Local servers are good for tools that need access to our filesystem or local resources.Remote MCP servers run on external infrastructure, and OpenCode connects to them over HTTP. These servers are typically managed by service providers and handle authentication, scaling, and maintenance for us.
Both types expose tools in the same way. The difference is where the code runs and how we configure the ...