Complete guide to configure OpenCode MCP Server in Cursor IDE.
Cursor is an AI-first code editor with built-in MCP support. It uses stdio transport by default and stores MCP configuration in a JSON file.
- Cursor installed
- Node.js 18+ installed
- OpenCode server running (
opencode serve)
- Open Cursor
- Press
Cmd+,(macOS) orCtrl+,(Windows/Linux) to open Settings - Search for "MCP" or navigate to Features → MCP
- Click "Add MCP Server"
- Enter the following:
- Name:
opencode - Command:
npx - Args:
-y, @opencode-mcp/server - Environment Variables:
OPENCODE_SERVER_URL=http://localhost:4096
- Name:
Edit the MCP configuration file directly:
macOS/Linux:
~/.cursor/mcp.jsonWindows:
%USERPROFILE%\.cursor\mcp.json
Configuration:
{
"mcpServers": {
"opencode": {
"command": "npx",
"args": ["-y", "@opencode-mcp/server"],
"env": {
"OPENCODE_SERVER_URL": "http://localhost:4096"
}
}
}
}{
"mcpServers": {
"opencode": {
"command": "npx",
"args": ["-y", "@opencode-mcp/server"],
"env": {
"OPENCODE_SERVER_URL": "http://localhost:4096",
"OPENCODE_DEFAULT_MODEL": "anthropic/claude-sonnet-4"
}
}
}
}For HTTP transport, configure Cursor to connect to a remote MCP server:
{
"mcpServers": {
"opencode": {
"url": "http://localhost:3000/mcp"
}
}
}- Restart Cursor
- Open the Chat panel (
Cmd+L/Ctrl+L) - Click the tools icon to see available tools
- You should see 29 OpenCode tools listed
In Cursor Chat, reference OpenCode tools directly:
Use opencode_run to implement a rate limiter middleware for Express.js
Use opencode_agent_delegate to have the plan agent review the auth module
# Check if the server starts manually
node /path/to/opencode-mcp/dist/index.js
# Check Node.js version
node --version # Should be 18+- Completely quit Cursor (not just close the window)
- Check the config file syntax is valid JSON
- Verify the paths are correct for your system
# Ensure OpenCode server is running
curl http://localhost:4096/health
# Or start it
opencode serve| OS | Path |
|---|---|
| macOS | ~/.cursor/mcp.json |
| Linux | ~/.cursor/mcp.json |
| Windows | %USERPROFILE%\.cursor\mcp.json |
{
"mcpServers": {
"opencode": {
"command": "npx",
"args": ["-y", "@opencode-mcp/server"],
"env": {
"OPENCODE_SERVER_URL": "http://localhost:4096",
"OPENCODE_AUTO_START": "true",
"OPENCODE_TIMEOUT": "120000"
}
}
}
}