Skip to main content
Glama

opencode-mcp

npm version license node

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 4096

If 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-mcp

For 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

opencode_setup, opencode_context, opencode_provider_models

Quick question or follow-up

opencode_ask, opencode_reply

Start work and wait

opencode_run

Work in the background

opencode_fire, then opencode_check or opencode_wait

Recover or control a recorded job

opencode_job_list, opencode_job_get, opencode_job_cancel

Resolve required input

opencode_job_input, permission and question tools

Review the result

opencode_review_changes, opencode_conversation

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

OPENCODE_BASE_URL

Server endpoint; defaults to http://127.0.0.1:4096

OPENCODE_SERVER_USERNAME, OPENCODE_SERVER_PASSWORD

Optional server HTTP authentication

OPENCODE_SERVER_TOKEN

Optional bearer token, e.g. an OpenChamber client token

OPENCODE_OPENCHAMBER_PASSWORD, OPENCODE_OPENCHAMBER_URL

Sign in to an OpenChamber-fronted server

OPENCODE_OPENCHAMBER_CLIENT_ID

Overrides the per-process OpenChamber client identifier; see configuration

OPENCODE_AUTO_SERVE

Set to true to opt in to launching a local server

OPENCODE_DEFAULT_PROVIDER, OPENCODE_DEFAULT_MODEL

Default prompt provider/model pair

OPENCODE_TOOL_PROFILE

full (default) or a smaller essential tool set

OPENCODE_TASK_STORE

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:coverage

Tests 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.mjs

Live 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

MIT license · OpenCode API · Model Context Protocol

Available Tools

87 tools
opencode_agent_listA
Read-onlyIdempotent

List all available agents with their names, descriptions, and modes (primary/subagent)

Inputs: directory. Returns: data, text, isError

opencode_askB
Destructive

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_setB
Destructive

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_checkA
Read-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_executeB
Destructive

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_listA
Read-onlyIdempotent

List all available commands (built-in and custom slash commands)

Inputs: directory. Returns: data, text, isError

opencode_config_getB
Read-onlyIdempotent

Get the current opencode configuration

Inputs: directory. Returns: data, text, isError

opencode_config_providersB
Read-onlyIdempotent

List all configured providers and their default models

Inputs: directory. Returns: data, text, isError

opencode_config_updateC
Destructive

Update the opencode configuration. Pass a partial config object with fields to update.

Inputs: config (required), directory. Returns: data, text, isError

opencode_contextA
Read-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_conversationB
Read-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_pollA
Read-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_listB
Read-onlyIdempotent

List files and directories at a path

Inputs: path, directory. Returns: data, text, isError

opencode_file_readB
Read-onlyIdempotent

Read the content of a file

Inputs: path (required), directory. Returns: data, text, isError

opencode_file_statusA
Read-onlyIdempotent

Get status for tracked files (VCS changes: modified, added, deleted, etc.)

Inputs: directory. Returns: data, text, isError

opencode_find_fileA
Read-onlyIdempotent

Find files and directories by name (fuzzy match)

Inputs: query (required), type, limit, directory, +1 more. Returns: data, text, isError

opencode_find_symbolA
Read-onlyIdempotent

Find workspace symbols by name (functions, classes, variables, etc.)

Inputs: query (required), directory. Returns: data, text, isError

opencode_find_textA
Read-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_fireA
Destructive

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_statusC
Read-onlyIdempotent

Get the status of configured formatters

Inputs: directory. Returns: data, text, isError

opencode_healthA
Read-onlyIdempotent

Check server health and version

Inputs: directory. Returns: data, text, isError

opencode_instance_disposeA
Destructive

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_cancelA
Destructive

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_getA
Read-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_inputB
Destructive

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_listA
Read-onlyIdempotent

List locally retained jobs in this OpenCode server and credential scope.

Inputs: limit. Returns: data, text, isError

opencode_logB
Destructive

Write a log entry to the opencode server

Inputs: level (required), message (required), service (required), extra, +1 more. Returns: data, text, isError

opencode_lsp_statusB
Read-onlyIdempotent

Get the status of LSP (Language Server Protocol) servers

Inputs: directory. Returns: data, text, isError

opencode_mcp_addC
Destructive

Add an MCP server dynamically to opencode

Inputs: name (required), config (required), directory. Returns: data, text, isError

opencode_mcp_statusA
Read-onlyIdempotent

Get the status of all MCP servers configured in opencode

Inputs: directory. Returns: data, text, isError

opencode_message_getA
Read-onlyIdempotent

Get details of a specific message in a session

Inputs: messageId (required), sessionId (required), directory. Returns: data, text, isError

opencode_message_listA
Read-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_sendB
Destructive

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_asyncA
Destructive

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_getB
Read-onlyIdempotent

Get the current working path of the opencode server

Inputs: directory. Returns: data, text, isError

opencode_permission_listA
Read-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_currentC
Read-onlyIdempotent

Get the current active project

Inputs: directory. Returns: data, text, isError

opencode_project_initA
Destructive

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_listA
Read-onlyIdempotent

List all projects known to the opencode server

Inputs: directory. Returns: data, text, isError

opencode_provider_auth_methodsB
Read-onlyIdempotent

Get available authentication methods for all providers

Inputs: directory. Returns: data, text, isError

opencode_provider_listA
Read-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_modelsA
Read-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_authorizeC
Destructive

Start OAuth authorization for a provider

Inputs: providerId (required), inputs, method. Returns: data, text, isError

opencode_provider_oauth_callbackC
Destructive

Handle OAuth callback for a provider

Inputs: providerId (required), callbackData (required). Returns: data, text, isError

opencode_provider_testA
Destructive

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_listA
Read-onlyIdempotent

List pending OpenCode questions, optionally filtered to a session.

Inputs: directory, sessionId. Returns: data, text, isError

opencode_question_rejectB
Destructive

Reject a pending OpenCode question explicitly.

Inputs: requestId (required), directory. Returns: data, text, isError

opencode_question_replyB
Destructive

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_replyA
Destructive

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_changesA
Read-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_runA
Destructive

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_abortB
Destructive

Abort a running session

Inputs: id (required), directory. Returns: data, text, isError

opencode_session_childrenA
Read-onlyIdempotent

Get child sessions of a session

Inputs: id (required), directory. Returns: data, text, isError

opencode_session_createB
Destructive

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_deleteA
Destructive

Delete a session and all its data

Inputs: id (required), directory. Returns: data, text, isError

opencode_session_diffB
Read-onlyIdempotent

Get the diff for a session, optionally for a specific message

Inputs: id (required), directory, messageID. Returns: data, text, isError

opencode_session_forkB
Destructive

Fork an existing session, optionally at a specific message

Inputs: id (required), directory, messageID. Returns: data, text, isError

opencode_session_getB
Read-onlyIdempotent

Get details of a specific session by ID

Inputs: id (required), directory. Returns: data, text, isError

opencode_session_initA
Destructive

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_listB
Read-onlyIdempotent

List all sessions

Inputs: directory. Returns: data, text, isError

opencode_session_permissionA
Destructive

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_revertC
Destructive

Revert a message in a session

Inputs: id (required), messageID (required), partID, directory. Returns: data, text, isError

opencode_session_shareC
Destructive

Share a session publicly

Inputs: id (required), directory. Returns: data, text, isError

opencode_sessions_overviewA
Read-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_statusA
Read-onlyIdempotent

Get status for all sessions (running, idle, etc.)

Inputs: directory. Returns: data, text, isError

opencode_session_summarizeA
Destructive

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_todoA
Read-onlyIdempotent

Get the todo list for a session

Inputs: id (required), directory. Returns: data, text, isError

opencode_session_unrevertA
Destructive

Restore all reverted messages in a session

Inputs: id (required), directory. Returns: data, text, isError

opencode_session_unshareB
Destructive

Unshare a previously shared session

Inputs: id (required), directory. Returns: data, text, isError

opencode_session_updateB
Destructive

Update session properties (e.g. title)

Inputs: id (required), title, directory. Returns: data, text, isError

opencode_setupB
Read-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_executeC
Destructive

Run a shell command through the opencode session

Inputs: agent (required), command (required), sessionId (required), modelID, +2 more. Returns: data, text, isError

opencode_statusA
Read-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_idsA
Read-onlyIdempotent

List all available tool IDs that the LLM can use (experimental)

Inputs: directory. Returns: data, text, isError

opencode_tool_listA
Read-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_promptB
Destructive

Append text to the TUI's prompt input field

Inputs: text (required), directory. Returns: data, text, isError

opencode_tui_clear_promptB
Destructive

Clear the current prompt text in the TUI

Inputs: directory. Returns: data, text, isError

opencode_tui_execute_commandA
Destructive

Execute a slash command through the TUI (e.g. '/init', '/undo')

Inputs: command (required), directory. Returns: data, text, isError

opencode_tui_open_helpA
Destructive

Open the help dialog in the TUI

Inputs: directory. Returns: data, text, isError

opencode_tui_open_modelsB
Destructive

Open the model selector in the TUI

Inputs: directory. Returns: data, text, isError

opencode_tui_open_sessionsB
Destructive

Open the session selector in the TUI

Inputs: directory. Returns: data, text, isError

opencode_tui_open_themesB
Destructive

Open the theme selector in the TUI

Inputs: directory. Returns: data, text, isError

opencode_tui_show_toastC
Destructive

Show a toast notification in the TUI

Inputs: message (required), title, variant, directory. Returns: data, text, isError

opencode_tui_submit_promptA
Destructive

Submit the current prompt in the TUI (equivalent to pressing Enter)

Inputs: directory. Returns: data, text, isError

opencode_vcs_infoA
Read-onlyIdempotent

Get VCS (version control) info for the current project (branch, remote, status)

Inputs: directory. Returns: data, text, isError

opencode_waitA
Read-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

    B3.1/5.0

    Scored across 87 tools

    Disambiguation2/5

    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.

    Naming Consistency4/5

    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.

    Tool Count1/5

    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.

    Completeness4/5

    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

    ActivityNo data
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      A
      maintenance
      Connects 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 npm
      MIT
    • A
      license
      Not graded
      quality
      A
      maintenance
      Connects 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 npm
      MIT
    • A
      license
      Not graded
      quality
      A
      maintenance
      Connects 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 npm
      MIT
    • A
      license
      Not graded
      quality
      A
      maintenance
      Connects 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 npm
      MIT