feat: HTTP 传输的 MCP 端点 — 任意 agent 用 URL+token 远程挂载真相库 (v0.1.18)#4
Merged
Conversation
抽出 mcp/tools.mjs 作为 8 个只读原语的唯一真相源(schema + 格式化 + INSTRUCTIONS), stdio(remoteExec 走 REST)与新的服务器内 HTTP MCP(localExec 直连 query.mjs)共用,杜绝漂移。 新增 POST /mcp(无状态 + JSON 响应),复用 authMember 鉴权与现有 8 个 query 函数; read 出口仍过 redactReadable,只读、不暴露 ingest。让任意远程 agent(IM bot / Cursor / 云端 agent)无需安装客户端即可挂载。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
bump 0.1.17 → 0.1.18 + 双语 CHANGELOG。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
FakeHank
added a commit
that referenced
this pull request
Jun 25, 2026
* fix(cli): brain status「最近同步」改读最近一条 tick(logfmt),不再匹配老格式的「·」 现版 tick 是 logfmt(无「·」),旧过滤匹配不到会显示过期时间戳。改成取最近一条 tick 行、只显示时间 + 计数体。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * feat(viewer): 本机 viewer 去 token 登录 + 展示设备 token;线上加「本机控制台」按钮 (v0.1.20) #2 本机 viewer:本机 loopback 不该要 token 登录 —— 去掉 token 闸,改用 Host/Origin 守卫挡跨站 + DNS-rebind(同源请求照常放行)。`brain viewer` 直接开 http://127.0.0.1:7878。 采集配置页新增「连接」区,展示服务器/身份/设备 token(可显示·复制),方便粘到网站登录。 #4 线上共享库网站:顶栏加「本机控制台」按钮,新标签打开本机 viewer(双语)。 bump v0.1.20,让 #1(brain status 修复)+ #2 随自动更新下发;#4 随服务端部署即生效。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
做了什么
给真相库加一个 HTTP 传输的 MCP 端点
POST /mcp:任何支持 MCP 的 agent(队友的 Cursor、基于 Agent SDK / Codex SDK 的 IM 机器人、云端 agent)现在只需「URL + Bearer token」即可挂载团队记忆,无需安装客户端、无需 spawn 子进程。这是把团队大脑从「只能编辑器挂」推进到「任何 agent 都能挂」的第一步(纯只读真相层 / 产品 B 路线)。怎么做的
mcp/tools.mjs(新) — 抽出 8 个只读原语的唯一真相源:schema + 描述 + 格式化 +INSTRUCTIONS。stdio 与 HTTP 两种传输共用,杜绝漂移。mcp/server.mjs(瘦身) — stdio 改为注入remoteExec(走api()fetch 打后端 REST,含跨境重试),行为不变。server/mcpexec.mjs(新) —localExec:服务器进程内直连query.mjs,逐路对齐现有 REST 路由。server/mcphttp.mjs(新) —POST /mcp,无状态(sessionIdGenerator: undefined)+ JSON 响应;每请求一对 server+transport,用完即弃。server/server.mjs(+) —/mcp路由,复用现有authMember鉴权。不变量
只读、不暴露
ingest;read出口仍过redactReadable(脱敏单源化);sessions/stats透传roster/registry;REST(网页在用)与 stdio(客户端在用)路径均未改动。测试
新增
test/mcphttp.test.mjs:用真 MCP 客户端(StreamableHTTPClientTransport)跑通initialize → tools/list(8 原语)→ grep/read/ls/sessions。全套 167 测试通过。经一轮
/simplify(4 agent 并行审查):ls 默认值上移到共享 handler、测试脚手架收进withClient。留作后续:把readTruth/githubTruth抽进query.mjs单源化/read脱敏不变量(需动既有 REST 路由)。🤖 Generated with Claude Code