MCP servers
You can add external tools to opencode using the Model Context Protocol, or MCP. opencode supports both:
- Local servers
- And remote servers
Once added, MCP tools are automatically available to the LLM alongside built-in tools.
Configure
You can define MCP servers in your opencode config under mcp
.
Local
Add a local MCP servers under mcp.localmcp
.
{ "$schema": "https://opencode.ai/config.json", "mcp": { "localmcp": { "type": "local", "command": ["bun", "x", "my-mcp-command"], "environment": { "MY_ENV_VAR": "my_env_var_value" } } }}
Remote
Add a remote MCP servers under mcp.remotemcp
.
{ "$schema": "https://opencode.ai/config.json", "mcp": { "remotemcp": { "type": "remote", "url": "https://my-mcp-server.com" } }}