feat(mcp): 安全物化 OpenCode HTTP MCP 配置 - #4
Closed
wanglongan587 wants to merge 4 commits into
Closed
Conversation
Author
|
建议关闭。本 PR 属于已被规格否决的工作区文件物化方案。后续请看 #6 (ACP 透明转发,不再写 OpenCode 配置文件)。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
关联 Issue
Closes ora-space/desktop#488
背景与问题
Desktop 已定义 Agent MCP Configuration protocol v1,用来让 Host(负责启动和协调 Agent 的桌面端进程)把 Workspace 中完整的 MCP 配置快照交给 Agent。MCP 即 Model Context Protocol,是应用向模型提供外部工具和数据源的一套协议。
OpenCode Agent 之前没有声明和实现这项能力,因此 Host 即使解析出了 HTTP MCP,也无法把它安全地写成 OpenCode 能直接读取的配置。若简单覆盖用户配置,还会带来密钥泄漏、误删用户文件、并发覆盖和错误接管既有文件等风险。
本 PR 提交的功能
声明 HTTP-only MCP 能力
物化 OpenCode 托管配置
<workspace>/.opencode/opencode.json。$schema和顶层mcp映射,使用严格 UTF-8 JSON、两空格缩进、LF 换行、固定字段顺序和唯一末尾换行。type: "remote"、enabled: true、oauth: false。稳定标识与回执
mcp映射中稳定且可读的配置键;版本或配置修订变化不会改变该键。所有权与冲突保护
.opencode/opencode.json不会被接管。opencode.json/opencode.jsonc只用于检测 native-key 冲突,不会被修改。JSONC 是允许注释的 JSON 变体。文件系统与 Git 安全措施
/.opencode/opencode.json,不修改.gitignore,也不忽略整个.opencode目录。.opencode目录及任何相邻文件。版本、文档与测试
为什么采用这种方案
.opencode下其他用户文件和 Skill Surface 仍可正常被版本控制。权衡与取舍
@ora-space/plugin-sdk@0.6.0,因为该版本对应 Desktop 固定基线中的 MCP 高层 API。目前该版本尚未发布到 JSR,发布前标准依赖解析会失败;本地验证使用固定 Desktop SDK 基线完成。这里没有回退到旧 SDK,也没有在 Agent 仓库复制协议定义,以避免形成长期不兼容实现。SDK 0.6.0 需要先于 OpenCode Agent 0.3.0 发布。验证
deno fmt --check:通过deno check(映射到固定 Desktop SDK 基线):通过deno lint:通过deno bundle(映射到固定 Desktop SDK 基线):通过未修改 Desktop 仓库,也未包含 #489 或后续 ticket 的实现。