opencode-mcp
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@opencode-mcpadd input validation to POST /api/users"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
opencode-mcp
Give any MCP client the power of OpenCode.
opencode-mcp is an MCP server that bridges your AI tools (Claude, Cursor, Windsurf, VS Code, etc.) to OpenCode's headless API. It lets your AI delegate real coding work — building features, debugging, refactoring, running tests — to OpenCode sessions that autonomously read, write, and execute code in your project.
80 tools | 10 resources | 6 prompts | Multi-project | Auto-start
Why Use This?
Delegate coding tasks — Tell Claude "build me a REST API" and it delegates to OpenCode, which creates files, installs packages, writes tests, and reports back.
Parallel work — Fire off multiple tasks to OpenCode while your primary AI keeps working on something else.
Any MCP client — Works with Claude Desktop, Claude Code, Cursor, Windsurf, VS Code Copilot, Cline, Continue, Zed, Amazon Q, and any other MCP-compatible tool.
Zero setup — The server auto-starts the OpenCode HTTP server in-process via the official
@opencode-ai/sdkif one isn't already running. No manual steps.
Related MCP server: Multi-CLI MCP
Quick Start
Prerequisite: OpenCode must be installed.
curl -fsSL https://opencode.ai/install | bashornpm i -g opencode-aiorbrew install sst/tap/opencode
Claude Code:
claude mcp add opencode -- npx -y opencode-mcpClaude Desktop / Cursor / Windsurf / Cline / Continue (add to your MCP config):
{
"mcpServers": {
"opencode": {
"command": "npx",
"args": ["-y", "opencode-mcp"]
}
}
}That's it. Restart your client and OpenCode's tools will be available.
See Configuration for all client configs (VS Code Copilot, Zed, Amazon Q, etc.) and environment variables.
How It Works
MCP Client <--stdio--> opencode-mcp <--HTTP--> OpenCode Server
(Claude, Cursor, etc.) (this package) (in-process via @opencode-ai/sdk,
or external opencode serve)Your MCP client calls tools over stdio. This server translates them into HTTP requests to the OpenCode headless API. If no OpenCode server is reachable at OPENCODE_BASE_URL, one is started in-process via the official @opencode-ai/sdk. The directory parameter on every tool routes that request to a specific project via the x-opencode-directory header, so a single MCP instance can fan out across many project roots.
Key Tools
The 80 tools are organized into tiers. Start with the workflow tools — they handle the common patterns in a single call.
Workflow Tools (13) — Start Here
Tool | What it does |
| Check server health, providers, and project status. Use first. |
| Create session + send prompt + get answer. One call. |
| Follow-up message in an existing session |
| Send a task and wait for completion (session + async send + polling) |
| Fire-and-forget: dispatch a task, return immediately |
| Compact progress report for a running session (status, todos, files changed) |
| Get formatted conversation history |
| Quick overview of all sessions |
| Project + VCS + config + agents in one call |
| Formatted diff summary for a session |
| Poll an async session until it finishes |
| Quick-test whether a provider is working |
| Health + providers + sessions + VCS dashboard |
Recommended Patterns
Quick question:
opencode_ask({ prompt: "Explain the auth flow in this project" })Build something and wait:
opencode_run({ prompt: "Add input validation to POST /api/users", maxDurationSeconds: 300 })Parallel background tasks:
opencode_fire({ prompt: "Refactor the auth module to use JWT" })
→ returns sessionId immediately
opencode_check({ sessionId: "..." })
→ check progress anytimeAll Tool Categories
Category | Count | Description |
13 | High-level composite operations | |
20 | Create, list, fork, share, abort, revert, permissions | |
6 | Send prompts, execute commands, run shell | |
6 | Search text/regex, find files/symbols, read files | |
13 | Health, VCS, LSP, MCP servers, agents, logging | |
9 | Remote-control the OpenCode terminal UI | |
6 | List providers/models, set API keys, OAuth | |
3 | Get/update configuration | |
3 | List, inspect, and initialize projects | |
1 | Poll real-time SSE events |
Resources (10)
Browseable data endpoints — your client can read these without tool calls:
URI | Description |
| Current active project |
| Current configuration |
| Providers with models |
| Available agents |
| Available commands |
| Server health and version |
| Version control info |
| All sessions |
| MCP server status |
| VCS file status |
Prompts (6)
Guided workflow templates your client can offer as selectable actions:
Prompt | Description |
| Review diffs from a session |
| Step-by-step debugging workflow |
| Get oriented in a new project |
| Have OpenCode build a feature |
| Setup, tool selection, monitoring, and pitfalls |
| Summarize what happened in a session |
Multi-Project Support
Every tool accepts an optional directory parameter to target a different project. No restarts needed.
opencode_ask({ directory: "/home/user/mobile-app", prompt: "Add navigation" })
opencode_ask({ directory: "/home/user/web-app", prompt: "Add auth" })Use opencode_project_init to scaffold a new project directory (or open a preexisting one) before the first call, so the OpenCode server registers it as a project:
opencode_project_init({ path: "/home/user/new-project" })
// → "Successfully initialized project directory at: /home/user/new-project"
opencode_run({ directory: "/home/user/new-project", prompt: "Set up a Vite + React app" })Environment Variables
All optional. Only needed if you've changed defaults on the OpenCode server.
Variable | Default | Description |
|
| OpenCode server URL |
|
| HTTP basic auth username |
| (none) | HTTP basic auth password (enables auth when set) |
|
| Auto-start an in-process OpenCode server (via |
| (none) | Default provider ID when not specified per-tool (e.g. |
| (none) | Default model ID when not specified per-tool (e.g. |
Development
git clone https://github.com/AlaeddineMessadi/opencode-mcp.git
cd opencode-mcp
npm install
npm run build
npm start # run the MCP server
npm run dev # watch mode
npm test # 328 testsSmoke Testing
End-to-end test against a running OpenCode server:
npm run build && node scripts/mcp-smoke-test.mjsDocumentation
Getting Started — step-by-step setup
Configuration — env vars and all client configs
Tools Reference — all 80 tools in detail
Resources — 10 MCP resources
Prompts — 6 guided workflow templates
Examples — real workflow examples
Architecture — system design and data flow
References
License
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/AlaeddineMessadi/opencode-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server