Enable MCP Servers
You can define MCP servers in your OpenCode Config undermcp. Add each MCP with a unique name. You can refer to that MCP by name when prompting the LLM.
opencode.jsonc
enabled to false. This is useful if you want to temporarily disable a server without removing it from your config.
Overriding Remote Defaults
Organizations can provide default MCP servers via their.well-known/opencode endpoint. These servers may be disabled by default, allowing users to opt-in to the ones they need.
To enable a specific server from your organization’s remote config, add it to your local config with enabled: true:
opencode.json
Local MCP Servers
Add local MCP servers usingtype set to "local" within the MCP object.
opencode.jsonc
@modelcontextprotocol/server-everything MCP server:
opencode.jsonc
use the mcp_everything tool to my prompts.
Local MCP Options
Here are all the options for configuring a local MCP server:| Option | Type | Required | Description |
|---|---|---|---|
type | String | Yes | Type of MCP server connection, must be "local". |
command | Array | Yes | Command and arguments to run the MCP server. |
environment | Object | No | Environment variables to set when running the server. |
enabled | Boolean | No | Enable or disable the MCP server on startup. |
timeout | Number | No | Timeout in ms for fetching tools from the MCP server. Defaults to 5000 (5 seconds). |
Remote MCP Servers
Add remote MCP servers by settingtype to "remote".
opencode.json
url is the URL of the remote MCP server and with the headers option you can pass in a list of headers.
Remote MCP Options
| Option | Type | Required | Description |
|---|---|---|---|
type | String | Yes | Type of MCP server connection, must be "remote". |
url | String | Yes | URL of the remote MCP server. |
enabled | Boolean | No | Enable or disable the MCP server on startup. |
headers | Object | No | Headers to send with the request. |
oauth | Object | No | OAuth authentication configuration. See OAuth section. |
timeout | Number | No | Timeout in ms for fetching tools from the MCP server. Defaults to 5000 (5 seconds). |
OAuth Authentication
OpenCode automatically handles OAuth authentication for remote MCP servers. When a server requires authentication, OpenCode will:Automatic OAuth
For most OAuth-enabled MCP servers, no special configuration is needed. Just configure the remote server:opencode.json
opencode mcp auth <server-name>.
Pre-registered OAuth Clients
If you have client credentials from the MCP server provider, you can configure them:opencode.json
Authenticating
You can manually trigger authentication or manage credentials. Authenticate with a specific MCP server:mcp auth command will open your browser for authorization. After you authorize, OpenCode will store the tokens securely.
Disabling OAuth
If you want to disable automatic OAuth for a server (e.g., for servers that use API keys instead), setoauth to false:
opencode.json
OAuth Options
| Option | Type | Description |
|---|---|---|
oauth | Object | false | OAuth config object, or false to disable OAuth auto-detection. |
clientId | String | OAuth client ID. If not provided, dynamic client registration will be attempted. |
clientSecret | String | OAuth client secret, if required by the authorization server. |
scope | String | OAuth scopes to request during authorization. |
Debugging OAuth
If a remote MCP server is failing to authenticate, you can diagnose issues with:mcp debug command shows the current auth status, tests HTTP connectivity, and attempts the OAuth discovery flow.
Managing MCP Tools
Your MCPs are available as tools in OpenCode, alongside built-in tools. So you can manage them through the OpenCode config like any other tool.Global Tool Management
You can enable or disable MCP tools globally:opencode.json
opencode.json
my-mcp* to disable all MCPs.
Per-Agent Tool Management
If you have a large number of MCP servers you may want to only enable them per agent and disable them globally. To do this:Enable per agent
In your agent config, enable the MCP server as a tool.
opencode.json
Glob Patterns
The glob pattern uses simple regex globbing patterns:*matches zero or more of any character (e.g.,"my-mcp*"matchesmy-mcp_search,my-mcp_list, etc.)?matches exactly one character- All other characters match literally
MCP server tools are registered with server name as prefix, so to disable all tools for a server simply use:
Examples
Below are examples of some common MCP servers. You can submit a PR if you want to document other servers.Sentry
Add the Sentry MCP server to interact with your Sentry projects and issues.opencode.json
Context7
Add the Context7 MCP server to search through docs.opencode.json
opencode.json
CONTEXT7_API_KEY environment variable set.
Add use context7 to your prompts to use Context7 MCP server.
AGENTS.md
Grep by Vercel
Add the Grep by Vercel MCP server to search through code snippets on GitHub.opencode.json
gh_grep, you can add use the gh_grep tool to your prompts to get the agent to use it.
AGENTS.md
FAQ
How many MCP servers can I enable at once?
How many MCP servers can I enable at once?
There’s no hard limit, but keep in mind that each MCP server adds to your context window. We recommend being selective about which servers you enable to avoid exceeding context limits.
Can I create my own MCP server?
Can I create my own MCP server?
Yes! You can create custom MCP servers that implement the Model Context Protocol. Check the MCP specification for details on building your own server.
What happens if an MCP server times out?
What happens if an MCP server times out?
By default, MCP servers have a 5-second timeout. If a server times out, OpenCode will mark it as failed. You can increase the timeout in your config using the
timeout property.How do I know which MCP tools are available?
How do I know which MCP tools are available?
You can list all available MCP tools and their status using
opencode mcp list. This shows connected servers and their available tools.