Skip to main content
Glama
opencode-http-mcp

opencode-http-mcp

by xuanpass

opencode-http-mcp

A zero-dependency, pure-JavaScript stdio MCP server that bridges MCP clients (WorkBuddy, Claude Desktop, Cursor, any JSON-RPC stdio client) to an OpenCode 2.x / 3.x server.

It talks directly to OpenCode's official /api/... HTTP endpoints and hand-rolls the MCP stdio (JSON-RPC) protocol on top of node:readline. No @modelcontextprotocol/sdk, no zod, no build step — just Node standard library.

Why this exists

The community opencode-mcp 3.x package is TypeScript + @opencode-ai/sdk

  • zod and must be built before use. Its OpenCodeClient routes to whatever the installed SDK knows about — and the SDK currently only ships 1.x-style paths, so it does not match a running OpenCode 2.x/3.x server that moved every business endpoint behind an /api/... prefix. The result: 405, the Web UI HTML fallback, or .map is not a function crashes.

opencode-http-mcp speaks the current /api/... contract from the start, with full tooling parity to opencode-mcp 3.x — every one of the upstream's 87 unique tool names (92 locally, incl. 5 extras), grouped into layered modules — and honest no-route fallbacks for the small set of 1.x-only endpoints that a 2.x build does not expose (instead of faking data).

Related MCP server: opencode-mcp

Architecture (layered, mirrors upstream)

Layer 0    src/http.js      OpenCodeClient — HTTP + SSE + { data } unwrap
Layer 0.5  src/helpers.js   formatting / result envelopes / redaction
Layer 0.5  src/registry.js  tool registry
Layer 0.5  src/util.js      arg helpers (dir / req / modelOpts)
Layer 1    src/jobs.js      JobService — session-turn dispatch & observation
Layer 2    src/tools/*.js   grouped tool modules (one per upstream file)
Entry      src/index.js     stdio JSON-RPC MCP entry point

Upstream parity map (opencode-mcp 3.x → opencode-http-mcp)

Tool-surface parity — 100% of upstream names, plus 5 extras

upstream file

module

upstream tools

local tools

delta

session.ts

session.js

20

20

—

message.ts

message.js

6

6

—

file.ts

file.js

6

6

—

config.ts

config.js

3

3

—

provider.ts

provider.js

6

6

—

project.ts

project.js

3

3

—

misc.ts

misc.js

12

16

+integration/pty/reference/skill_list (2.x routes upstream doesn't wrap)

global.ts

global.js

1

1

—

events.ts

events.js

1

1

—

input.ts

input.js

6

4

job tools moved to workflow.js

tui.ts

tui.js

9

9

—

workflow.ts

workflow.js

13

17

+job_list/get/cancel/update (JobService tools live here)

total

86 registrations → 87 unique names

92 unique names

0 missing, 5 extra

  • 0 missing: every opencode_* tool name upstream registers exists locally, verified by name-level diff (comm), no duplicate registrations.

  • 5 extra: opencode_integration_list, opencode_pty_list, opencode_reference_list, opencode_skill_list (wrap 2.x routes upstream ignores), plus opencode_job_update as an alias of upstream's opencode_job_input (kept for existing callers).

  • opencode_job_input ≡ opencode_job_update — same implementation, two names.

opencode_run dual entry (upstream design, simplified here)

Upstream has two entry points to the same JobService.start():

  1. Legacy path (always available): the MCP client calls the opencode_run tool → tools/workflow.ts → jobs.start() + observe. Works on any MCP protocol version.

  2. Modern path (task-transport.ts interceptor): if the connection is a 2026-07-28+ "modern" session and the client advertised the Tasks extension capability, the interceptor hijacks the opencode_run tool call before it reaches the tool layer and converts it into a tasks/* JSON-RPC extension request (tasks/get / tasks/update / tasks/cancel become the observation channel instead of repeated tools/calls). Otherwise (-32021/-32022 errors) it falls through to the legacy path.

opencode-http-mcp implements only the legacy path. The interceptor is a transport-level concern that requires the Tasks extension handshake, which this bridge does not advertise (capabilities: { tools: {} }). Behavior is identical for every non-Tasks client — which is all stdio JSON-RPC clients today, including WorkBuddy.

Short-task tools vs long-task tools — sibling layers

OpenCodeClient (http.js)                ← Layer 0: single HTTP round-trip
   ▲                    ▲
   │                    │
short-task tools     JobService (jobs.js) ← Layer 1: multi-call state machine
(ask/reply/file/*)   start() → get() → update()/cancel()   + persistence
   │                    │
   └── BOTH dispatch one-shot tools through JobService when the route is
       fire-and-forget (2.x /prompt returns immediately), then observe via
       waitForSnapshot() until terminal — so the caller gets the AI reply,
       not an echo of its own prompt.
  • Short tools (opencode_file_read, opencode_provider_list, …): one request → format → return. They call OpenCodeClient directly.

  • Long tools (opencode_run / fire / check / wait / job_*): jobs.start() submits once and persists a durable jobId; observation is a separate read (jobs.get per poll — no self-polling loop inside the job record); waitForSnapshot() in workflow.js owns the wait loop.

  • Neither layer calls the other: short tools and JobService are siblings under OpenCodeClient. The one crossing point is the one-shot tools (ask/reply/provider_test/message_send), which route through jobs.start() + waitForSnapshot() purely to observe fire-and-forget prompt submissions.

Feature parity beyond tools

capability

upstream

opencode-http-mcp

Tools

87 unique names

92 (100% of upstream + 5)

Persistent JobService (store/lock/recover/TTL)

✅ jobs.ts

✅ jobs.js (ported, live-tested)

MCP prompts (6 templates)

✅ prompts.ts

✅ implemented

MCP resources (11 opencode:// URIs)

✅ resources.ts

✅ implemented

Tasks extension (task-transport, tasks/*)

✅

✅ implemented (handlers for tasks/get/update/cancel)

Server auto-spawn (opencode serve)

✅ server-manager.ts

✅ implemented (enabled via OPENCODE_AUTO_SERVE=true)

MCP form elicitation for pending inputs

✅ task-input.ts

✅ text fallback (relies on client-side input via job_input)

Test suite

✅ vitest

✅ test.js + live smoke (extended unit tests)

CacheHints

✅ (cacheHints in initialize)

✅ implemented (tools/list, prompts/list, resources/list, resources/templates/list, resources/read)

Build / dependencies

TS + sdk + zod, build step

zero-dep, no build

Features

  • Zero dependencies — only node:http, node:https, node:url from stdlib.

  • No build step — point your MCP client at src/index.js and it runs.

  • Correct /api/... routing for OpenCode 2.x/3.x.

  • Full tool parity — all 87 upstream opencode_* tool names (92 local).

  • Honest no-route fallbacks — for 1.x-only endpoints a 2.x build lacks, tools return a clear "unavailable on this build" message instead of 404s.

Requirements

  • Node.js >= 18

  • A running OpenCode server (opencode serve) reachable over HTTP, e.g. http://192.168.123.101:49374

Install

git clone <your-repo-url> opencode-http-mcp
cd opencode-http-mcp
# No `npm install` needed — there are no dependencies.

Configuration (environment variables)

Variable

Default

Description

OPENCODE_BASE_URL

http://127.0.0.1:49374

Base URL of the OpenCode server

OPENCODE_SERVER_USERNAME

opencode

Basic-auth username

OPENCODE_SERVER_PASSWORD

(empty)

Basic-auth password

OPENCODE_TIMEOUT_MS

120000

Per-request HTTP timeout (ms)

OPENCODE_MCP_STORE_ROOT

platform state dir

Job store root; "" = in-memory only

OPENCODE_MCP_SCOPE

default

Store partition (sha256 of baseUrl+scope)

OPENCODE_MCP_TTL_MS

86400000

Durable job TTL (24h)

OPENCODE_AUTO_SERVE

false

Reserved (currently not used)

Security note: never commit a real OPENCODE_SERVER_PASSWORD. Set it in your MCP client's env block or in your shell environment instead.

MCP client configuration

Example for a client that reads mcpServers:

{
  "mcpServers": {
    "opencode": {
      "command": "node",
      "args": ["/absolute/path/to/opencode-http-mcp/src/index.js"],
      "env": {
        "OPENCODE_BASE_URL": "http://192.168.123.101:49374",
        "OPENCODE_SERVER_USERNAME": "opencode",
        "OPENCODE_SERVER_PASSWORD": "YOUR_PASSWORD_HERE"
      }
    }
  }
}

Routes pinned (live-verified on OpenCode 2.0.31)

Live 200 endpoints used by real tools: /api/session, /api/session/{id}, /api/session/{id}/message, /api/session/{id}/prompt, /api/session/{id}/diff, /api/session/{id}/fork, /api/agent, /api/command, /api/config, /api/vcs, /api/vcs/status, /api/provider, /api/model, /api/project, /api/skill, /api/mcp, /api/integration, /api/reference, /api/pty, /api/event, /api/fs/list, /api/fs/find, /api/info, /global/health, /global/event.

Response shapes worth knowing (all verified against 2.0.31):

  • Bare arrays (no {data} envelope): /api/session, /api/project, /api/config. src/http.js unwraps .data only for non-array objects, so the array is passed through unchanged — callers must do their own Array.isArray check.

  • Nested object where 1.x had a scalar: /api/vcs returns {"branch":{}} outside a git worktree, and /api/mcp returns {"status":{"status":"connected"}}. helpers.js:displayScalar() is the one place that turns such values into text (or null).

  • Field renames: project rows use canonical, not worktree; provider rows have activation/methods/connections, not env/configured.

  • /global/health returns the SPA HTML on 2.x — the version lives in /api/info. opencode_health falls back automatically; so do opencode_setup and opencode_status.

Honest no-route fallbacks (1.x-only, 404 on 2.0.31): /api/question, /api/permission → opencode_question_*, opencode_job_input; /api/provider/auth, /api/provider/{id}/oauth/*, /api/auth/{id}; /api/tui/* → opencode_tui_*; /api/path, /api/lsp, /api/formatter, /api/log, /api/instance/dispose, /api/project/current, /api/session/{id}/abort|todo|share|summarize|revert|unrevert|children.

Semi-available (not a clean 404, but not usable either):

  • /api/session/status — GET answers 400 InvalidRequestError ("Expected a string starting with "ses"") and POST answers 404. opencode_session_status derives the same view from /api/session rows (outcome absent ⇒ still running).

  • /api/fs/find?query= — 200, honours query, type and limit, but ignores offset, directory and searchDirectory (the search always covers the whole project root). Backs opencode_find_text|file|symbol.

  • /api/event — SSE long connection, so it never "returns" on its own; opencode_events_poll reads it within a bounded window.

  • /api/provider/auth — 404 whose body is ProviderNotFoundError (providerID: "auth"), which is easy to mistake for a real provider lookup failure.

Run the smoke test

OPENCODE_BASE_URL=http://192.168.123.101:49374 \
OPENCODE_SERVER_USERNAME=opencode \
OPENCODE_SERVER_PASSWORD=*** \
node test.js

The test exercises tools/list plus a handful of read-only and no-route tools against a live server.

License

MIT — see LICENSE.

Available Tools

85 tools
opencode_agent_listA

List all available agents with names, descriptions, and modes.

Inputs: directory.

opencode_askB

Ask OpenCode in one step: create a session, send a prompt, return the AI response.

Inputs: prompt (required), agent, title, format, +5 more.

opencode_auth_setC

Set authentication credentials for a provider (API key).

Inputs: key (required), type (required), providerId (required).

opencode_checkC

Get current task status by observing a session. Pass detailed for full response text.

Inputs: sessionId (required), detailed, directory.

opencode_command_executeC

Execute a slash command in a session (e.g. /init, /undo).

Inputs: command (required), sessionId (required), agent, modelID, +4 more.

opencode_command_listC

List all available slash commands.

Inputs: directory.

opencode_config_getC

Get the current opencode configuration.

Inputs: directory.

opencode_config_providersB

List configured providers and their default models.

Inputs: directory.

opencode_config_updateC

Update the opencode configuration. Pass a partial config object.

Inputs: config (required), directory.

opencode_contextA

Get project context in one call: project, path, VCS, config, agents.

Inputs: directory.

opencode_conversationC

Get the full conversation history of a session, formatted for reading.

Inputs: sessionId (required), limit, directory.

opencode_events_pollB

Poll project events from OpenCode, or explicitly select global scope. Collects up to maxEvents within the duration.

Inputs: scope, directory, maxEvents, durationMs.

opencode_file_listC

List files and directories at a path (via /api/fs/list).

Inputs: path, directory.

opencode_file_readC

Read the content of a file (via /api/fs/read/{path}).

Inputs: path (required), directory.

opencode_file_statusC

Get VCS status for tracked files (via /api/vcs/status).

Inputs: directory.

opencode_find_fileB

Find files/directories by name. NOTE: 2.x server has no /api/fs/find route, so this reports unavailable.

Inputs: query (required), type, limit, directory, +1 more.

opencode_find_symbolB

Find workspace symbols by name. NOTE: 2.x server has no /api/fs/find route, so this reports unavailable.

Inputs: query (required), directory.

opencode_find_textB

Search text patterns in project files. NOTE: 2.x server has no /api/fs/find route, so this reports unavailable.

Inputs: pattern (required), directory.

opencode_fireB

Dispatch a background task and return its job/session IDs immediately. Use opencode_check or opencode_wait to observe.

Inputs: prompt (required), agent, title, format, +5 more.

opencode_healthC

Check server health and version.

Inputs: directory.

opencode_instance_disposeC

Dispose the current opencode instance (shuts it down).

Inputs: directory.

opencode_integration_listB

List registered integrations (plugins) on the server.

Inputs: directory.

opencode_job_cancelC

Abort the OpenCode session owned by a task.

Inputs: directory, sessionId.

opencode_job_getC

Observe a dispatched task by session, including current status and captured response text.

Inputs: jobId, pollMs, deadline, directory, +1 more.

opencode_logC

Write a log entry to the opencode server.

Inputs: level (required), message (required), service (required), extra, +1 more.

opencode_mcp_addC

Add an MCP server dynamically to opencode.

Inputs: name (required), config (required), directory.

opencode_mcp_statusB

Get the status of all MCP servers configured in opencode.

Inputs: directory.

opencode_message_getC

Get details of a specific message in a session.

Inputs: messageId (required), sessionId (required), directory.

opencode_message_listC

List all messages in a session with formatted roles and content.

Inputs: sessionId (required), limit, directory.

opencode_message_sendB

Send a prompt to a session and wait for the AI response.

Inputs: text (required), sessionId (required), agent, format, +6 more.

opencode_message_send_asyncB

Send a prompt asynchronously and return its messageId for opencode_wait. NOTE: 2.0.30 lacks /prompt_async; this falls back to a synchronous /prompt call which may block until the model replies.

Inputs: text (required), sessionId (required), agent, format, +4 more.

opencode_path_getC

Get the current working path of the opencode server.

Inputs: directory.

opencode_permission_listA

List pending permission requests across all sessions. Respond with opencode_session_permission.

Inputs: directory.

opencode_project_currentC

Get the current active project.

Inputs: directory.

opencode_project_initC

Create or open a project directory on the MCP host for an isolated OpenCode session.

Inputs: path (required).

opencode_project_listC

List all projects known to the opencode server.

Inputs: directory.

opencode_provider_auth_methodsB

Get available authentication methods for all providers.

Inputs: directory.

opencode_provider_listB

List all configured providers with connection status.

Inputs: directory.

opencode_provider_modelsC

List available models for a specific provider.

Inputs: providerId (required), limit, directory.

opencode_provider_oauth_authorizeC

Start OAuth authorization for a provider.

Inputs: providerId (required), inputs, method.

opencode_provider_oauth_callbackC

Handle OAuth callback for a provider.

Inputs: providerId (required), callbackData.

opencode_provider_testA

Quick-test whether a provider is working. Creates a temp session, sends a trivial prompt, cleans up.

Inputs: providerId (required), format, modelID, variant, +1 more.

opencode_pty_listC

List open pseudo-terminals managed by opencode.

Inputs: directory.

opencode_question_listB

List pending OpenCode questions (may be unavailable on this build).

Inputs: directory, sessionId.

opencode_question_rejectC

Reject a pending OpenCode question.

Inputs: requestId (required), directory.

opencode_question_replyC

Answer a pending OpenCode question.

Inputs: answers (required), requestId (required), directory.

opencode_reference_listC

List reference files/resources available to opencode.

Inputs: directory.

opencode_replyC

Send a follow-up message to an existing session.

Inputs: prompt (required), sessionId (required), agent, format, +4 more.

opencode_review_changesC

Get a formatted summary of all file changes made in a session.

Inputs: sessionId (required), directory, messageID.

opencode_runC

Send a task and wait for its correlated response. Returns a job snapshot; observation timeout leaves the remote session running.

Inputs: prompt (required), agent, title, format, +6 more.

opencode_session_abortC

Abort a running session.

Inputs: id (required), directory.

opencode_session_childrenC

Get child sessions of a session.

Inputs: id (required), directory.

opencode_session_createC

Create a new session. Optionally parentID and title.

Inputs: title, parentID, directory.

opencode_session_deleteC

Delete a session and all its data.

Inputs: id (required), directory.

opencode_session_diffC

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

Inputs: id (required), directory, messageID.

opencode_session_forkC

Fork an existing session, optionally at a specific message.

Inputs: id (required), directory, messageID.

opencode_session_getC

Get details of a specific session by ID.

Inputs: id (required), directory.

opencode_session_initC

Analyze the app and create AGENTS.md for a session. Long-running (30-60s+).

Inputs: id (required), modelID (required), messageID (required), providerID (required), +2 more.

opencode_session_listC

List all sessions.

Inputs: directory.

opencode_session_permissionC

Respond to a permission request: reply 'once'|'always'|'reject'.

Inputs: id (required), reply (required), permissionID (required), directory.

opencode_session_revertC

Revert a message in a session.

Inputs: id (required), messageID (required), partID, directory.

opencode_session_shareC

Share a session publicly.

Inputs: id (required), directory.

opencode_sessions_overviewB

Get a quick overview of all sessions with titles and status.

Inputs: directory.

opencode_session_statusC

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

Inputs: directory.

opencode_session_summarizeB

Summarize a session using a model. Long-running (30-60s+).

Inputs: id (required), modelID (required), providerID (required), variant, +1 more.

opencode_session_todoC

Get the todo list for a session.

Inputs: id (required), directory.

opencode_session_unrevertC

Restore all reverted messages in a session.

Inputs: id (required), directory.

opencode_session_unshareC

Unshare a previously shared session.

Inputs: id (required), directory.

opencode_session_updateC

Update session properties (e.g. title).

Inputs: id (required), title, directory.

opencode_setupB

Check OpenCode status, provider configuration, and project. Use as the first step when starting work.

Inputs: directory.

opencode_shell_executeC

Run a shell command through the opencode session.

Inputs: command (required), sessionId (required), agent, modelID, +2 more.

opencode_skill_listC

List available skills registered with opencode.

Inputs: directory.

opencode_statusB

Get a quick status dashboard: server health, provider count, session count, and VCS info.

Inputs: directory.

opencode_tui_append_promptB

Append text to the TUI prompt input field.

Inputs: text (required), directory.

opencode_tui_clear_promptC

Clear the current TUI prompt.

Inputs: directory.

opencode_tui_execute_commandC

Execute a slash command through the TUI.

Inputs: command (required), directory.

opencode_tui_open_helpB

Open the help dialog in the TUI.

Inputs: directory.

opencode_tui_open_modelsB

Open the model selector in the TUI.

Inputs: directory.

opencode_tui_open_sessionsC

Open the session selector in the TUI.

Inputs: directory.

opencode_tui_open_themesB

Open the theme selector in the TUI.

Inputs: directory.

opencode_tui_show_toastC

Show a toast notification in the TUI.

Inputs: message (required), title, variant, directory.

opencode_tui_submit_promptC

Submit the current TUI prompt.

Inputs: directory.

opencode_vcs_infoC

Get VCS (version control) info for the current project.

Inputs: directory.

opencode_waitC

Wait for a session turn to complete by observing /message + /active.

Inputs: sessionId (required), directory, messageId, pollIntervalMs, +1 more.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    C2.6/5.0

    Scored across 85 tools

    Disambiguation2/5

    Several tools overlap heavily in purpose: opencode_message_send, opencode_message_send_async, opencode_ask, opencode_reply, opencode_run, and opencode_fire all send prompts or tasks, while opencode_check, opencode_wait, opencode_job_get, opencode_session_status, opencode_sessions_overview, and opencode_status all observe session/task status. The boundaries between these are unclear, leading to likely misselection.

    Naming Consistency3/5

    All tools share the opencode_ prefix and use snake_case, which helps, but the naming pattern is mixed: many follow resource_action (opencode_session_list, opencode_message_get) while others are bare verbs or nouns (opencode_ask, opencode_check, opencode_reply, opencode_run, opencode_fire, opencode_wait). This inconsistency makes the set less predictable.

    Tool Count1/5

    85 tools is an extreme mismatch for a single MCP server. Even though the domain is broad (sessions, messages, providers, TUI, etc.), this count far exceeds what an agent can manage, and many tools are redundant or niche, suggesting the surface should be split.

    Completeness4/5

    The server covers a wide range of operations (session lifecycle, messaging, config, providers, projects, VCS, agents, TUI, events, questions). However, notable gaps exist: there is no direct file write/edit tool (only read/list/status), and several find tools (opencode_find_text, opencode_find_file, opencode_find_symbol) are marked unavailable on 2.x.

    Related MCP Connectors

    Related MCP Servers

    • 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 work — asking questions, implementing features, monitoring background jobs, answering prompts and permission requests, and reviewing changes across multiple projects. Supports synchronous runs, asynchronous jobs with polling and recovery, multi-project directory scoping, and configurable server authentication and tool profiles.
      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 ask questions, implement features, run background coding jobs, answer permission and question prompts, and review changes across multiple projects. It also exposes project-aware resources, prompts, and job monitoring tools with configurable provider and model defaults.
      22,181 npm
      MIT
    • A
      license
      Not graded
      quality
      A
      maintenance
      Connects MCP clients such as Claude, Cursor, and VS Code to an OpenCode server's headless API so coding work can be delegated, answered, and monitored. It supports asking questions, launching foreground or background jobs, supplying required input and permissions, and reviewing resulting 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 ask questions, start and monitor background coding jobs, answer prompts and permission requests, and review changes across projects. It also exposes setup, model selection, job recovery, and configuration tools, along with resources and prompts, for multi-project workflows.
      22,181 npm
      MIT