Configure servers
Define each server by a unique name undermcp.servers in your OpenCode configuration. V2 does not place server names directly under mcp.
opencode.jsonc
disabled is true. There is no V2 enabled field.
Local servers
A local server is a command that OpenCode starts using the MCP stdio transport.opencode.jsonc
| Field | Required | Description |
|---|---|---|
type | Yes | Must be "local". |
command | Yes | Executable followed by its arguments. |
cwd | No | Process working directory. Relative paths resolve from the workspace directory; the workspace is the default. |
environment | No | String environment variables added to the inherited OpenCode process environment. |
disabled | No | Set to true to prevent the server from connecting. Defaults to false. |
timeout | No | Per-server timeout overrides. |
{env:NAME} to substitute an environment variable while loading config. Shell expressions such as $NAME are not expanded in JSON strings.
Remote servers
A remote server uses the MCP Streamable HTTP transport. Itsurl must be a valid absolute URL.
opencode.jsonc
| Field | Required | Description |
|---|---|---|
type | Yes | Must be "remote". |
url | Yes | Streamable HTTP endpoint. |
headers | No | String HTTP headers sent to the MCP endpoint. |
oauth | No | OAuth client settings, or false to disable OAuth support. |
disabled | No | Set to true to prevent the server from connecting. Defaults to false. |
timeout | No | Per-server timeout overrides. |
oauth: false for a server that exclusively uses an API key or another header-based credential.
OAuth
OAuth support is enabled for remote servers unlessoauth is false. OpenCode discovers the authorization server, uses PKCE, refreshes tokens, and attempts dynamic client registration when the server supports it. OAuth credentials are stored outside project configuration.
For a server that supports dynamic client registration, only the remote server is required:
opencode.jsonc
/connect in the TUI:
opencode.jsonc
| OAuth field | Description |
|---|---|
client_id | Pre-registered OAuth client ID. If omitted, OpenCode attempts dynamic client registration. |
client_secret | Client secret for a pre-registered client. |
scope | Space-delimited scopes to request. |
callback_port | Local callback port, from 1 through 65535. An available ephemeral port is used by default. |
redirect_uri | Pre-registered loopback redirect URI. Its path and port must reach the local callback listener. |
Timeouts
Timeouts are positive integer milliseconds. Configure defaults undermcp.timeout; a server’s timeout fields override matching defaults.
opencode.jsonc
| Timeout | Default | Applies to |
|---|---|---|
startup | 30 seconds | Establishing the transport and initializing the server. |
catalog | 30 seconds | Listing tools, prompts, resources, and resource templates. |
execution | 12 hours | Calling tools, getting prompts, and reading resources. |
Names and permissions
OpenCode combines the server name and MCP tool name as<server>_<tool>. Characters other than letters, numbers, _, and - are replaced with _; for example, server context 7 and tool resolve.library/id become context_7_resolve_library_id. MCP prompts appear as slash commands named <server>:<prompt> using the same normalization.
Choose short server names that remain unique after normalization. Under the default Code Mode, MCP tools are grouped by the normalized server name.
Use permission actions to hide or deny a server’s tools without stopping its connection:
CLI commands
V2 provides these MCP management commands:mcp add accepts either --url for a remote server or a command after -- for a local server, not both. Use --header NAME=VALUE only with remote servers and --env NAME=VALUE only with local servers. Edit the config directly for OAuth, timeout, working-directory, or enablement settings.