opencode-mcp
Click on "Deploy 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-mcpask opencode to add 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
Delegate coding work to OpenCode from your MCP client.
opencode-mcp connects Claude, Cursor, VS Code, and other MCP clients to OpenCode's headless API. Ask questions, implement features, monitor background work, respond to questions and permissions, and review changes across projects.
Version 3.0.0 requires Node.js 22 or newer. Upgrading from 2.x? See the migration notes.
Quick Start
Install OpenCode and start its server from your project:
opencode serve --hostname 127.0.0.1 --port 4096If you use the TUI, start it with opencode --port 4096 and share that server. Set OPENCODE_BASE_URL for another endpoint.
For Claude Code:
claude mcp add opencode -- npx -y opencode-mcpFor clients using an mcpServers configuration:
{
"mcpServers": {
"opencode": {
"command": "npx",
"args": ["-y", "opencode-mcp"]
}
}
}Restart the client and call opencode_setup. Choose a provider from its configured providers, then use opencode_provider_models to select a model. Set OPENCODE_DEFAULT_PROVIDER and OPENCODE_DEFAULT_MODEL together or pass the selected IDs in each prompt call.
Client-specific configuration includes VS Code, Windsurf, Continue, Zed, and Amazon Q. To test unreleased changes, build from source and configure your client to run node with the absolute path to dist/index.js.
Related MCP server: codex-mcp-opencode
Choose a Workflow
Need | Tools |
Setup and orientation |
|
Quick question or follow-up |
|
Start work and wait |
|
Work in the background |
|
Recover or control a recorded job |
|
Resolve required input |
|
Review the result |
|
opencode_fire({
directory: "/absolute/path/to/project",
prompt: "Add input validation to POST /api/users and run the relevant tests",
providerID: "<configured-provider>",
modelID: "<available-model>"
})
// Save the returned job and session IDs; use them to monitor or resume observation.Async results distinguish accepted, running, input_required, completed, failed, cancelled, and unknown. An observation timeout returns current progress; it does not mean the task failed or was cancelled. Follow the returned state and IDs instead of assuming an absent busy status means success.
Modern clients can use the MCP Tasks extension for opencode_run. Clients without that extension use ordinary tools, including opencode_fire and opencode_check. Task status is retrieved by polling; this package does not promise to wake an idle assistant with completion notifications.
Tools retain readable text and provide structured results for clients that consume them. Prompt tools accept optional model variants and OpenCode structured-output formats. See the generated tools reference and examples.
Multi-Project Use
Project-scoped tools accept directory: an absolute path on the OpenCode server. POSIX, Windows drive, and UNC paths are preserved across client operating systems. Relative paths are rejected; OpenCode checks existence and access.
opencode_project_init({path: "/absolute/local/project"}) creates or opens a directory on the MCP host. For remote OpenCode servers, create the project on that server instead. Authentication tools are global. Resources offer both static reads of the default project and explicit project/session templates.
Independent sessions do not isolate filesystem changes. Use separate project directories or Git worktrees when running overlapping coding tasks in parallel.
Configuration
All settings are optional; an OpenCode server must already be running by default.
Variable | Purpose |
| Server endpoint; defaults to |
| Optional server HTTP authentication |
| Set to |
| Default prompt provider/model pair |
|
|
| Override the local directory for persisted job records |
See configuration for storage, permissions, and client setup. Auto-start only supports local loopback HTTP endpoints; custom OpenCode CLI flags require a manually started server.
Development and Verification
npm ci
npm test
npm run test:coverageTests use local fixtures and do not require a model subscription. For controlled live checks against a local OpenCode server:
npm run build
node scripts/mcp-smoke-test.mjsLive smoke checks use a disposable project and owned session. Inference is opt-in with an explicitly selected provider and model. See live verification and releases for scope, skipped capabilities, and publishing checks.
Documentation
This server cannot be deployed
Maintenance
Related MCP Connectors
The OpenRouter MCP server plugs OpenRouter into the AI tools you already use. Once connected, your assistant can pull live OpenRouter data (models, prices, your credits, rankings, and docs) and send quick test messages, all without leaving your editor.
- QuallaaOAuthcom.quallaa
Talk to your public-facing AI from any MCP client — Claude, ChatGPT, Cursor, Cline, Windsurf.
MCP server that lets AI assistants use all OneSchema features exposed via the public API.
One connector for 15,000+ MCP servers plus your team's private MCPs, from any AI client.
Related MCP Servers
- AlicenseBqualityAmaintenanceBridges MCP clients to OpenCode's headless API, enabling AI to delegate autonomous coding tasks like building features, debugging, and refactoring across multiple projects.8722,031 npm149MIT
- AlicenseAqualityBmaintenanceA project-local MCP bridge that allows Codex Desktop to plan tasks and OpenCode to execute them within the current project directory, with session reuse and native OpenCode background subagents.41MIT
- FlicenseAqualityAmaintenanceAn MCP server that provides OpenCode's native tools (file read/write/edit, search, shell, web fetch/search, and more) to compatible Code CLIs like Codex and Claude Code.11282 npm-
- AlicenseNot gradedqualityBmaintenanceEnables MCP clients such as Notion AI to execute native OpenCode file, search, shell, web-fetch, and todo tools with job management and permission approvals.17 npmMIT