XO

xuanpass/opencode-http-mcp

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

0 stars 0 forks 质量 81 趋势 14MIT

零依赖,纯JS标准MCP桥接OpenCode 2.x/3.x服务器(/api/...路由,无SDK,无构建步骤)

概览

一个 stdio MCP 服务器,将 MCP 客户端(WorkBuddy、Claude Desktop、Cursor、任何 JSON-RPC 标准客户端)桥接到 OpenCode 2.x / 3.x 服务器。 它与OpenCode官方的/api/...HTTP端点通信,并在node:readline之上手动滚动MCP标准协议(JSON-RPC)。没有@modelcontextprotocol/sdk,没有zod,没有构建步骤——只有Node标准库。 社区的opencode-mcp 3.x包是TypeScript + @opencode-ai/sdk + zod,必须在使用前构建。它的OpenCodeClient会路由到已安装SDK已知的内容——而SDK目前只发布1.x风格的路径,因此它与运行中的OpenCode服务器不匹配,后者将所有业务端点都放在/api/...前缀后。结果是:405,Web界面HTML备援,或者.map函数不会崩溃。 OpenCode-http-mcp 从一开始就使用 /api/...合同,从一开始就使用 OpenCode-MCP 3.x ——上游的 87 个唯一工具名(本地有 92 个,包括

概述(AI 翻译)

一个零依赖、纯JavaScript的标准MCP服务器,桥接MCP clients (WorkBuddy, Claude Desktop, Cursor, any JSON-RPC stdio client) to a OpenCode 2.x / 3.x 服务器。

它直接与OpenCode官方的/api/...HTTP端点通信,并且 在node:readline之上手动滚动MCP标准协议(JSON-RPC)。 没有@modelcontextprotocol/sdk,没有zod,也没有构建步骤——只有节点标准 图书馆。

为什么会有这样的存在

社区的 opencode-mcp 3.x 包是 TypeScript + [@opencode-ai/sdk

  • zod 和必须在使用前建造。它的 OpenCodeClient 路由到其他地方 已安装的SDK知道——而且目前SDK只发布1.x风格 路径,因此它与运行中的 OpenCode 2.x/3.x 服务器不匹配,而该服务器已移动 每个业务端点都位于 /api/... 前缀后。结果是:405, 网页界面HTML的备援,或者.map is not a function崩溃。

opencode-http-mcp 从一开始就说出当前的 /api/... 合同, 具备完全的模具齐称与opencode-mcp 3.x]——每一个 上游的87个独特工具名称(本地92个,包括5个额外工具),被归类为 分层模块——以及诚实的无路由备份,适用于这小部分 仅限1.x端点,即2.

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

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).

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,
在 GitHub 查看完整 README

安装

This server does not publish a one-line install command.

Open the repository installation guide 新手?先看 mcpskill.org 教程 →

配置

{ "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" } } } }