Skip to main content
Glama
DSH ⇄ ChatGPT Fusion Gateway

DSH ⇄ ChatGPT Fusion Gateway

by 2025ashore

DSH ⇄ ChatGPT 融合网关

一个极简的 MCP 桥接器,它将 DeepSeek Harness(DSH)保持为唯一代理与运行时,并仅将 ChatGPT Web 用作无状态的、单轮推理提供方。

DSH 负责代理、工具、权限、会话、压缩、子代理、工作流、目标以及真实的文件/Shell 执行。网关只是将一份不可变的 DSH 上下文快照转发给 ChatGPT “Brain” 会话,并原样返回一个决策——一个最终答案、一个操作建议,或一个受限只读批次。网关从不自行执行所建议的操作。

User
 ↓
DSH UI
 ↓
DSH Native Agent Loop  →  Context / Compaction
 ↓
ChatGPT Fusion LLM Adapter
 ↓
Fusion Reasoning Gateway          ← this repository
 ↓
ChatGPT Brain Worker              (a dedicated ChatGPT Web conversation + optional wake extension)
 ↓
final | action_proposal | readonly_batch
 ↓
Gateway validation
 ↓
DSH Permissions / ToolRuntime  →  DSH Native Tool  →  Next DSH Tick

功能特点

  • 严格单结果推理契约 — 每个请求都携带一份完整、不可变的快照;Brain 恰好返回一个终结结果(final、action_proposal,或由 read/glob/grep 组成的受限 readonly_batch)。

  • 可恢复的投递 — 请求会记入磁盘日志;网关崩溃时可恢复进行中的声明(claim),而不是丢失它们。通过快照 + nonce 实现幂等重试。

  • 多 worker 故障转移 — 多个 Brain 会话可以为同一模型路由提供支持;停滞的声明会被释放,并以轮换后的 nonce 重新交付给健康的备用会话。

  • OAuth 2.0(loopback) — 为公共 ChatGPT 连接器(/brain-mcp)提供可选授权,并支持访问/刷新令牌轮换。

  • 跨平台 — 网关和 Node 守护进程可在 Linux、macOS 和 Windows 上运行。

  • 可选浏览器唤醒 — 一个 Chrome 扩展(browser-autowake/)会轮询 loopback 队列元数据,并在有待处理工作时唤醒路由所绑定的 Brain 标签页。

Related MCP server: antigravity-with-chatgpt

运行要求

  • Node.js 18+(使用全局 fetch)。

  • git(在 Linux 上还需要你配置的命令用户)用于工作区工具。

DSH 的自身代理循环和工具运行时必须可用;网关会自动检测 DSH 自带的 node_modules,或者你也可以通过 DSH_NODE_MODULES 环境变量指定其位置。

快速开始

git clone <your-repo-url>
cd dsh-chatgpt-mcp
npm install

将真实凭据填入 config.json 和 model-bindings.json(所有值均以 REDACTED_* 占位符形式提供),然后启动:

npm run daemon:start     # background, supervised with auto-restart
npm run daemon:status

…或者在前台运行:

npm start                # node server.strict.cjs

网关将绑定 http://127.0.0.1:7688。详细的架构设计和不变性约束见 ARCHITECTURE.md。

配置

config.json

键

含义

host / port

Loopback 绑定地址(默认为 127.0.0.1:7688)。

workspaceRoot

工具可访问的项目工作区。. 表示项目根目录。

ownerPassword

用于 OAuth 授权的拥有者密码(至少 16 个字符)。

staticToken

用于 loopback Brain MCP 的静态 Bearer 令牌(至少 32 个字符)。

allowedPrograms

工作区 run_command 工具可启动的可执行文件。

commandUser

仅限 Linux:沙箱命令通过 setpriv 切换到的用户。

ownerPassword、staticToken 和绑定键是必填项,使用前必须填写。在 macOS/Windows 上没有可移植的 setuid 辅助程序,因此沙箱命令以当前用户身份运行,commandUser 会被忽略。

model-bindings.json

将每条 modelId + reasoningEffort 路由映射到一个 bindingKey。bindingKey 是与对应 brain-worker-*.txt 共享的密钥;两者要保持同步。

服务控制

在 Linux、macOS 和 Windows 上行为完全相同:

node scripts/daemon.mjs start      # start detached supervisor + server
node scripts/daemon.mjs stop
node scripts/daemon.mjs restart
node scripts/daemon.mjs status

这些命令也通过 npm run daemon:start|stop|restart|status 暴露。仅限 Linux 的基于 screen 的脚本仍保留在 scripts/ 中(control.sh、public_quick.sh 等),用于 Cloudflare quick-tunnel 和无头 Chrome worker 池。

推理协议(v4)

网关与 ChatGPT “Brain” 之间采用严格协议:

fusion_wait_for_reasoning_request  →  one immutable snapshot + data-only action catalog
fusion_submit_reasoning_result     →  exactly one {final} | {action_proposal} | {readonly_batch}
fusion_fail_reasoning_request      →  terminal failure for the assigned snapshot

actionCatalog 纯粹是数据——对 DSH 原生工具的描述,永远不会安装为 ChatGPT/MCP 工具。action_proposal 是一个建议,之后由 DSH 在自身的沙箱/权限策略下执行,网关不会运行它。

公共端点为 GET|POST /brain-mcp。先前的 /mcp 和 /fusion/tasks… 路由返回 HTTP 410(已禁用)。

权限

采用 DSH 原生的三级权限模型——read-only、workspace-write、danger-full-access,默认使用 workspace-write。

仓库结构

server.strict.cjs        active gateway (strict v4; no legacy /mcp)
server.cjs               full gateway incl. workspace file/shell tools
config.json              runtime configuration (secrets are placeholders)
model-bindings.json      modelId → bindingKey map
scripts/daemon.mjs       cross-platform daemon (start/stop/restart/status)
scripts/*.sh             Linux deployment helpers (screen, cloudflared, Chrome workers)
brain-worker-*.txt       per-route prompts for dedicated Brain conversations
browser-autowake/        optional Chrome extension that wakes Brain tabs
tests/                   selftests and headless integration workers
state/  logs/            runtime artifacts (gitignored)

测试

npm install
node tests/reasoning-contract-v4-selftest.mjs   # primary protocol test
# …plus oauth, worker-recovery, failover, context-overflow, payload-limit selftests

完整的测试矩阵请参见实现说明中的 ## Verification 章节。

安全说明

  • 默认绑定 127.0.0.1;只有 quick-tunnel 脚本会暴露公网 URL。

  • 不要将含真实密钥的 config.json 或 model-bindings.json 提交到仓库——本仓库正是因此才默认提供占位符。

  • 在 Linux 上使用 /bin/setpriv 将沙箱命令降权到 commandUser;在其他平台,命令以当前用户身份运行。


DSH ⇄ ChatGPT Fusion 是一个社区桥接项目,与 OpenAI 或 DeepSeek 无关联,也未获得其认可。使用 ChatGPT 须遵守 OpenAI 的服务条款。

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    A
    maintenance
    Enables hosts like Claude Code, Codex, Antigravity, and Grok to dispatch work to full DeepSeek Harness agent sessions that appear as native subagents with live progress, tier/effort presets, failure escalation, and workspace-cycle guardrails. Also lends a text-only harness multimodal abilities by describing pasted images and generating images through DeepSeek's vision model, existing CLIs, or a custom endpoint.
    354 npm
    MIT
  • A
    license
    Not graded
    quality
    A
    maintenance
    Enables hosts like Claude Code, Codex, Antigravity and Grok to dispatch tasks to DeepSeek Harness agents while still showing them as native subagents with live progress, tier/effort presets, escalation, dispatch guardrails and a jobs board. Also lends text-only harnesses vision and image generation through DeepSeek's VL model or existing CLIs and custom OpenAI-compatible endpoints.
    354 npm
    MIT