opencode-mcp
This server exposes OpenCode’s headless API through MCP so clients can delegate coding work, manage sessions, and inspect results.
Check server health, configuration, setup status, providers, paths, VCS info, and project context.
Initialize/open projects and list/get current projects.
Create, list, get, update, delete, fork, share, abort, summarize, revert, and inspect sessions, messages, conversations, statuses, todos, and diffs.
Ask questions, reply in sessions, send prompts with provider/model/variant and structured output, execute commands/shell commands, and run tasks synchronously or as durable background jobs.
Observe, wait for, check, cancel, and provide input to jobs, including pending questions and permissions.
List and respond to permission requests and OpenCode questions.
Browse/read files, search text/files/symbols, inspect file status, and review changes.
Discover providers/models, manage authentication (API keys/OAuth), test providers, and manage MCP servers, agents, and commands.
Inspect LSP/formatter/MCP/tool status, poll project/global events, write logs, control TUI prompts/dialogs/commands, and dispose the OpenCode instance.
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-mcp 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.x requires Node.js 22 or newer and works with OpenCode 1.x (tested with 1.18.31 and 1.19.3). Support for OpenCode 2.x is planned for 4.0. 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: opencode-mcp
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 |
| Optional bearer token, e.g. an OpenChamber client token |
| Sign in to an OpenChamber-fronted server |
| Overrides the per-process OpenChamber client identifier; see configuration |
| 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
Available Tools
87 toolsopencode_agent_listARead-onlyIdempotent
List all available agents with their names, descriptions, and modes (primary/subagent)
Inputs: directory. Returns: data, text, isError
opencode_askBDestructive
Ask OpenCode a question in one step. Creates a new session, sends your prompt, and returns the AI response. This is the easiest way to interact with OpenCode.
Inputs: prompt (required), agent, title, format, +5 more. Returns: data, text, isError
opencode_auth_setBDestructive
Set authentication credentials for a provider (e.g. API key). Credentials are stored globally and shared across all projects.
Inputs: key (required), type (required), providerId (required). Returns: data, text, isError
opencode_checkARead-onlyIdempotent
Get current task status, pending input, todos and file counts. Uses session summary metadata instead of fetching patches. Pass jobId for exact durable turn correlation; detailed includes response text.
Inputs: jobId, detailed, directory, messageId, +1 more. Returns: text, error, jobId, result, +5 more
opencode_command_executeBDestructive
Execute a slash command in a session (e.g. /init, /undo, /redo)
Inputs: command (required), sessionId (required), agent, modelID, +4 more. Returns: data, text, isError
opencode_command_listARead-onlyIdempotent
List all available commands (built-in and custom slash commands)
Inputs: directory. Returns: data, text, isError
opencode_config_getBRead-onlyIdempotent
Get the current opencode configuration
Inputs: directory. Returns: data, text, isError
opencode_config_providersBRead-onlyIdempotent
List all configured providers and their default models
Inputs: directory. Returns: data, text, isError
opencode_config_updateCDestructive
Update the opencode configuration. Pass a partial config object with fields to update.
Inputs: config (required), directory. Returns: data, text, isError
opencode_contextARead-onlyIdempotent
Get full project context in one call: current project, path, VCS info, config, and available agents. Useful to understand the current state before starting work.
Inputs: directory. Returns: data, text, isError
opencode_conversationBRead-onlyIdempotent
Get the full conversation history of a session, formatted for easy reading. Shows all messages with their roles and content.
Inputs: sessionId (required), limit, directory. Returns: data, text, isError
opencode_events_pollARead-onlyIdempotent
Poll project events from OpenCode, or explicitly select global scope. Collects up to maxEvents within the duration. Connection failures are reported with any partial events; stopping observation does not abort remote work.
Inputs: scope, directory, maxEvents, durationMs. Returns: data, text, isError
opencode_file_listBRead-onlyIdempotent
List files and directories at a path
Inputs: path, directory. Returns: data, text, isError
opencode_file_readBRead-onlyIdempotent
Read the content of a file
Inputs: path (required), directory. Returns: data, text, isError
opencode_file_statusARead-onlyIdempotent
Get status for tracked files (VCS changes: modified, added, deleted, etc.)
Inputs: directory. Returns: data, text, isError
opencode_find_fileARead-onlyIdempotent
Find files and directories by name (fuzzy match)
Inputs: query (required), type, limit, directory, +1 more. Returns: data, text, isError
opencode_find_symbolARead-onlyIdempotent
Find workspace symbols by name (functions, classes, variables, etc.)
Inputs: query (required), directory. Returns: data, text, isError
opencode_find_textARead-onlyIdempotent
Search for text patterns in project files (regex supported). Returns file paths, line numbers, and matching lines.
Inputs: pattern (required), directory. Returns: data, text, isError
opencode_fireADestructive
Dispatch a durable background task and return its job, session and message IDs immediately. Use opencode_check or opencode_wait to observe; job_cancel stops the task.
Inputs: prompt (required), agent, title, format, +5 more. Returns: text, error, jobId, result, +5 more
opencode_formatter_statusCRead-onlyIdempotent
Get the status of configured formatters
Inputs: directory. Returns: data, text, isError
opencode_healthARead-onlyIdempotent
Check server health and version
Inputs: directory. Returns: data, text, isError
opencode_instance_disposeADestructive
Dispose the current opencode instance (shuts it down). WARNING: This is destructive and will terminate the server.
Inputs: directory. Returns: data, text, isError
opencode_job_cancelADestructive
Explicitly abort the OpenCode session owned by a job. This also stops other work in that session.
Inputs: jobId (required). Returns: text, error, jobId, result, +5 more
opencode_job_getARead-onlyIdempotent
Observe a durable job by ID, including pending inputs and final results.
Inputs: jobId (required). Returns: text, error, jobId, result, +5 more
opencode_job_inputBDestructive
Respond to a job's pending questions or permissions. Omit responses to request MCP forms when supported, or receive manual response instructions. Never approves automatically.
Inputs: jobId (required), responses. Returns: data, text, isError
opencode_job_listARead-onlyIdempotent
List locally retained jobs in this OpenCode server and credential scope.
Inputs: limit. Returns: data, text, isError
opencode_logBDestructive
Write a log entry to the opencode server
Inputs: level (required), message (required), service (required), extra, +1 more. Returns: data, text, isError
opencode_lsp_statusBRead-onlyIdempotent
Get the status of LSP (Language Server Protocol) servers
Inputs: directory. Returns: data, text, isError
opencode_mcp_addCDestructive
Add an MCP server dynamically to opencode
Inputs: name (required), config (required), directory. Returns: data, text, isError
opencode_mcp_statusARead-onlyIdempotent
Get the status of all MCP servers configured in opencode
Inputs: directory. Returns: data, text, isError
opencode_message_getARead-onlyIdempotent
Get details of a specific message in a session
Inputs: messageId (required), sessionId (required), directory. Returns: data, text, isError
opencode_message_listARead-onlyIdempotent
List all messages in a session with formatted output showing roles and content
Inputs: sessionId (required), limit, directory. Returns: data, text, isError
opencode_message_sendBDestructive
Send a prompt message to a session and wait for the AI response. Use parts to send text, and optionally specify a model.
Inputs: text (required), sessionId (required), agent, format, +6 more. Returns: data, text, isError
opencode_message_send_asyncADestructive
Send a prompt asynchronously and return its messageId. Pass sessionId and messageId to opencode_wait to observe this exact turn.
Inputs: text (required), sessionId (required), agent, format, +4 more. Returns: data, text, isError
opencode_path_getBRead-onlyIdempotent
Get the current working path of the opencode server
Inputs: directory. Returns: data, text, isError
opencode_permission_listARead-onlyIdempotent
List all pending permission requests across all sessions. When a session is blocked waiting for approval (e.g. to run a shell command or access a file outside the project), it appears here. Respond with opencode_session_permission.
Inputs: directory. Returns: data, text, isError
opencode_project_currentCRead-onlyIdempotent
Get the current active project
Inputs: directory. Returns: data, text, isError
opencode_project_initADestructive
Initialize or open a project directory to host an independent OpenCode session. Use this to create new empty folders, or to explicitly open preexisting projects on the MCP host machine for parallel code generation workloads. This tool operates on the local filesystem; create remote server directories separately.
Inputs: path (required). Returns: data, text, isError
opencode_project_listARead-onlyIdempotent
List all projects known to the opencode server
Inputs: directory. Returns: data, text, isError
opencode_provider_auth_methodsBRead-onlyIdempotent
Get available authentication methods for all providers
Inputs: directory. Returns: data, text, isError
opencode_provider_listARead-onlyIdempotent
List all configured providers with their connection status. Returns a compact summary — use opencode_provider_models to see models for a specific provider.
Inputs: directory. Returns: data, text, isError
opencode_provider_modelsARead-onlyIdempotent
List available models for a specific provider. Call opencode_provider_list first to see provider IDs.
Inputs: providerId (required), limit, directory. Returns: data, text, isError
opencode_provider_oauth_authorizeCDestructive
Start OAuth authorization for a provider
Inputs: providerId (required), inputs, method. Returns: data, text, isError
opencode_provider_oauth_callbackCDestructive
Handle OAuth callback for a provider
Inputs: providerId (required), callbackData (required). Returns: data, text, isError
opencode_provider_testADestructive
Quick-test whether a provider is working. Creates a temporary session, sends a trivial prompt, checks the response, and cleans up. Great for debugging auth issues.
Inputs: providerId (required), format, modelID, variant, +1 more. Returns: data, text, isError
opencode_question_listARead-onlyIdempotent
List pending OpenCode questions, optionally filtered to a session.
Inputs: directory, sessionId. Returns: data, text, isError
opencode_question_rejectBDestructive
Reject a pending OpenCode question explicitly.
Inputs: requestId (required), directory. Returns: data, text, isError
opencode_question_replyBDestructive
Answer an OpenCode question request. Supply one array of selected labels or free text per question.
Inputs: answers (required), requestId (required), directory. Returns: data, text, isError
opencode_replyADestructive
Send a follow-up message to an existing session. Use this to continue a conversation started with opencode_ask or opencode_session_create.
Inputs: prompt (required), sessionId (required), agent, format, +4 more. Returns: data, text, isError
opencode_review_changesARead-onlyIdempotent
Get a formatted summary of all file changes made in a session. Shows diffs in a readable format.
Inputs: sessionId (required), directory, messageID. Returns: data, text, isError
opencode_runADestructive
Send a task and wait for its correlated response. Returns a durable job ID; an observation timeout leaves the remote job running and can be resumed with opencode_wait.
Inputs: prompt (required), agent, title, format, +6 more. Returns: text, error, jobId, result, +5 more
opencode_session_abortBDestructive
Abort a running session
Inputs: id (required), directory. Returns: data, text, isError
opencode_session_childrenARead-onlyIdempotent
Get child sessions of a session
Inputs: id (required), directory. Returns: data, text, isError
opencode_session_createBDestructive
Create a new session. Optionally provide a parentID to create a child session, and a title.
Inputs: title, parentID, directory. Returns: text, isError, session, sessionId
opencode_session_deleteADestructive
Delete a session and all its data
Inputs: id (required), directory. Returns: data, text, isError
opencode_session_diffBRead-onlyIdempotent
Get the diff for a session, optionally for a specific message
Inputs: id (required), directory, messageID. Returns: data, text, isError
opencode_session_forkBDestructive
Fork an existing session, optionally at a specific message
Inputs: id (required), directory, messageID. Returns: data, text, isError
opencode_session_getBRead-onlyIdempotent
Get details of a specific session by ID
Inputs: id (required), directory. Returns: data, text, isError
opencode_session_initADestructive
Analyze the app and create AGENTS.md for a session. NOTE: This is a long-running operation that may take 30-60+ seconds depending on project size.
Inputs: id (required), modelID (required), messageID (required), providerID (required), +2 more. Returns: data, text, isError
opencode_session_listBRead-onlyIdempotent
List all sessions
Inputs: directory. Returns: data, text, isError
opencode_session_permissionADestructive
Respond to a permission request in a session. Use opencode_permission_list to see pending requests. Reply values: 'once' (approve this request only), 'always' (approve this + future matching requests for this session), 'reject' (deny the request).
Inputs: id (required), reply (required), permissionID (required), directory. Returns: data, text, isError
opencode_session_revertCDestructive
Revert a message in a session
Inputs: id (required), messageID (required), partID, directory. Returns: data, text, isError
opencode_session_searchARead-onlyIdempotent
Search sessions by keyword in title. Useful for finding a specific session among many.
Inputs: query (required), directory. Returns: data, text, isError
opencode_sessions_overviewARead-onlyIdempotent
Get a quick overview of all sessions with their titles and status. Useful to find which session to continue working in.
Inputs: directory. Returns: data, text, isError
opencode_session_statusARead-onlyIdempotent
Get status for all sessions (running, idle, etc.)
Inputs: directory. Returns: data, text, isError
opencode_session_summarizeADestructive
Summarize a session using a specified model. NOTE: This is a long-running operation that may take 30-60+ seconds.
Inputs: id (required), modelID (required), providerID (required), variant, +1 more. Returns: data, text, isError
opencode_session_todoARead-onlyIdempotent
Get the todo list for a session
Inputs: id (required), directory. Returns: data, text, isError
opencode_session_unrevertADestructive
Restore all reverted messages in a session
Inputs: id (required), directory. Returns: data, text, isError
opencode_session_updateBDestructive
Update session properties (e.g. title)
Inputs: id (required), title, directory. Returns: data, text, isError
opencode_setupBRead-onlyIdempotent
Check OpenCode status, provider configuration, and optionally initialize a project directory. Use this as the first step when starting work — it tells you what is ready and what still needs configuration.
Inputs: directory. Returns: data, text, isError
opencode_shell_executeCDestructive
Run a shell command through the opencode session
Inputs: agent (required), command (required), sessionId (required), modelID, +2 more. Returns: data, text, isError
opencode_statusARead-onlyIdempotent
Get a quick status dashboard: server health, provider count, session count, and VCS info. Lighter than opencode_setup — good for at-a-glance checks.
Inputs: directory. Returns: data, text, isError
opencode_tool_idsARead-onlyIdempotent
List all available tool IDs that the LLM can use (experimental)
Inputs: directory. Returns: data, text, isError
opencode_tool_listARead-onlyIdempotent
List tools with JSON schemas for a given provider and model (experimental)
Inputs: model (required), provider (required), directory. Returns: data, text, isError
opencode_tui_append_promptBDestructive
Append text to the TUI's prompt input field
Inputs: text (required), directory. Returns: data, text, isError
opencode_tui_clear_promptBDestructive
Clear the current prompt text in the TUI
Inputs: directory. Returns: data, text, isError
opencode_tui_execute_commandADestructive
Execute a slash command through the TUI (e.g. '/init', '/undo')
Inputs: command (required), directory. Returns: data, text, isError
opencode_tui_open_helpADestructive
Open the help dialog in the TUI
Inputs: directory. Returns: data, text, isError
opencode_tui_open_modelsBDestructive
Open the model selector in the TUI
Inputs: directory. Returns: data, text, isError
opencode_tui_open_sessionsBDestructive
Open the session selector in the TUI
Inputs: directory. Returns: data, text, isError
opencode_tui_open_themesBDestructive
Open the theme selector in the TUI
Inputs: directory. Returns: data, text, isError
opencode_tui_show_toastCDestructive
Show a toast notification in the TUI
Inputs: message (required), title, variant, directory. Returns: data, text, isError
opencode_tui_submit_promptADestructive
Submit the current prompt in the TUI (equivalent to pressing Enter)
Inputs: directory. Returns: data, text, isError
opencode_vcs_infoARead-onlyIdempotent
Get VCS (version control) info for the current project (branch, remote, status)
Inputs: directory. Returns: data, text, isError
opencode_waitARead-onlyIdempotent
Wait for a session or durable job. Returns completed, failed, input_required, or a resumable timeout. Cancelling this wait stops observation; use job_cancel or session_abort to stop OpenCode.
Inputs: jobId, directory, messageId, sessionId, +2 more. Returns: text, error, jobId, result, +5 more
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 87 tools
Many tools overlap heavily: opencode_session_list/opencode_sessions_overview/opencode_session_status, opencode_message_send/opencode_ask/opencode_reply/opencode_run, opencode_wait/opencode_check/opencode_job_get, and opencode_tui_* commands are numerous. An agent would struggle to pick the right tool among these near-duplicates.
The opencode_ prefix and mostly verb_noun pattern (e.g. opencode_session_create, opencode_file_read) is consistent. Minor deviations exist like opencode_ask, opencode_reply, opencode_fire, opencode_run, and opencode_log which break the verb_noun convention, but the overall pattern is predictable.
87 tools is far beyond the typical well-scoped MCP server. The count is extreme and includes many overlapping or highly granular tools (e.g. 10 TUI tools, 6 provider tools, 5 job tools) that could be consolidated.
The surface is very comprehensive for the opencode domain: sessions, messages, files, providers, permissions, jobs, TUI, and VCS are all covered. There are no obvious dead ends, though the sheer number of tools makes it hard to verify every workflow.
Maintenance
Related MCP Connectors
Talk to your public-facing AI from any MCP client — Claude, ChatGPT, Cursor, Cline, Windsurf.
Connect MCP clients to 2,000+ AI models without managing provider API keys.
One connector for 15,000+ MCP servers plus your team's private MCPs, from any AI client.
One MCP endpoint for Claude, GPT & Gemini: 100+ tools + no-code connectors + agent workers.
Related MCP Servers
- AlicenseNot gradedqualityAmaintenanceConnects MCP clients to OpenCode's headless API so users can delegate coding tasks, ask questions, monitor background work, respond to prompts and permissions, and review changes across projects.22,181 npmMIT
- AlicenseNot gradedqualityAmaintenanceConnects MCP clients such as Claude, Cursor, and VS Code to OpenCode's headless API, enabling users to ask questions, implement features, run and monitor background coding jobs, handle prompts and permissions, and review changes across projects.22,181 npmMIT
- AlicenseNot gradedqualityAmaintenanceConnects MCP clients to OpenCode's headless API so users can delegate coding work, ask questions, implement features, monitor background jobs, respond to prompts and permissions, and review changes across projects.22,181 npmMIT
- AlicenseNot gradedqualityAmaintenanceConnects MCP clients such as Claude, Cursor, and VS Code to OpenCode's headless API so users can delegate coding tasks, ask questions, run work in the background, and resolve permission or input requests across projects. It also supports monitoring job progress, reviewing resulting changes, and inspecting conversation history.22,181 npmMIT