Complete guide to configure OpenCode MCP Server in Zed Editor.
Zed is a high-performance code editor with built-in MCP support. It supports stdio transport and stores MCP configuration in the settings file.
Official Docs: https://zed.dev/docs/ai/mcp
- Zed Editor installed
- Node.js 18+ installed
- OpenCode server running (
opencode serve)
- Open Zed
- Press
Cmd+,(macOS) orCtrl+,(Windows/Linux) - Search for "MCP" or navigate to AI settings
- Add MCP server configuration
Edit the Zed settings file:
macOS/Linux:
~/.config/zed/settings.jsonWindows:
%APPDATA%\Zed\settings.json
Add to your settings.json:
{
"features": {
"edit_prediction_provider": "copilot"
},
"mcp_servers": {
"opencode": {
"command": "npx",
"args": ["-y", "@opencode-mcp/server"],
"env": {
"OPENCODE_SERVER_URL": "http://localhost:4096"
}
}
}
}If you have existing settings, merge carefully:
{
"theme": "One Dark",
"vim_mode": false,
"features": {
"edit_prediction_provider": "copilot"
},
"mcp_servers": {
"opencode": {
"command": "npx",
"args": ["-y", "@opencode-mcp/server"],
"env": {
"OPENCODE_SERVER_URL": "http://localhost:4096"
}
}
}
}{
"mcp_servers": {
"opencode": {
"command": "npx",
"args": ["-y", "@opencode-mcp/server"],
"env": {
"OPENCODE_SERVER_URL": "http://localhost:4096",
"OPENCODE_DEFAULT_MODEL": "anthropic/claude-sonnet-4",
"OPENCODE_TIMEOUT": "120000"
}
}
}
}Zed uses a secure-by-default approach:
- New worktrees are not trusted by default
- MCP servers in project settings won't run until you trust the worktree
- You'll be prompted to review before executing
To trust a worktree:
- Open a project
- You'll see a prompt about worktree trust
- Review the MCP servers listed
- Click Trust to enable
- Restart Zed completely
- Open the Assistant panel
- Look for available MCP tools
- Verify OpenCode tools are listed
In Zed's Assistant:
Use opencode_run to implement a rate limiter middleware
Use opencode_agent_delegate to have the plan agent review the code
You can also configure MCP servers per-project in .zed/settings.json:
{
"mcp_servers": {
"opencode": {
"command": "npx",
"args": ["-y", "@opencode-mcp/server"],
"env": {
"OPENCODE_SERVER_URL": "http://localhost:4096"
}
}
}
}Note: Project-level servers require worktree trust.
# Check settings syntax
cat ~/.config/zed/settings.json | python -m json.tool
# Test server manually
node /path/to/opencode-mcp/dist/index.jsIf servers aren't running:
- Check if you've trusted the worktree
- Look for trust prompts in Zed
- Review what the MCP server can access
# Verify OpenCode server
curl http://localhost:4096/health
# Start if not running
opencode serve| OS | Path |
|---|---|
| macOS | ~/.config/zed/settings.json |
| Linux | ~/.config/zed/settings.json |
| Windows | %APPDATA%\Zed\settings.json |
| Project | .zed/settings.json |
{
"theme": "One Dark",
"features": {
"edit_prediction_provider": "copilot"
},
"mcp_servers": {
"opencode": {
"command": "npx",
"args": ["-y", "@opencode-mcp/server"],
"env": {
"OPENCODE_SERVER_URL": "http://localhost:4096",
"OPENCODE_AUTO_START": "true"
}
}
}
}