背景
最近把 Nowledge Mem 部署到了 Docker 里,希望在 ChatGPT 里添加它提供的 Remote MCP。
问题出在官方流程的第一步。按照 Nowledge Mem 的 ChatGPT Remote MCP 文档,需要在 Mem 里进入「集成 → Plugins → 通过 OAuth 远程连接 MCP」,点击「开始设置」。接着 Mem 会打开浏览器配对页,并复制 /mcp 地址。后续 ChatGPT OAuth 授权也要在同一个浏览器 Profile 里继续。
Docker 部署卡在这里:容器里只有 Nowledge Mem 服务,没有桌面端 UI,也没有由 Mem 打开的浏览器 Profile。ChatGPT 打开的 pairing 页面无法和这个 Docker 服务绑定到同一个 “Mem server device”,页面就会提示只能在服务端设备上继续。
所以 Docker 服务虽然能暴露 /mcp,也能返回 OAuth metadata,但它自己无法完成这一步 pairing。
方案
最后采用了临时切换公网入口的方案:
- 让桌面设备上的 Nowledge Mem 临时接管同一个公网域名。
- 在桌面设备上打开 ChatGPT pairing 链接,完成 OAuth。
- 找到桌面端生成的 OAuth 状态文件。
- 把状态文件复制到 Docker 服务的持久化配置目录。
- 把公网域名切回 Docker 服务。
授权时的流量大概是这样:
ChatGPT / Browser
-> https://mem.example.com
-> Cloudflare Tunnel
-> 桌面设备上的 Nowledge Mem迁移完成后再切回:
ChatGPT
-> https://mem.example.com/mcp
-> Cloudflare Tunnel
-> Docker 里的 Nowledge Mem核心点是 OAuth 完成后的服务端状态可以持久化。Docker 服务只要能读到这份状态文件,就可以继续为 ChatGPT 提供 Remote MCP。
OAuth 状态文件路径
macOS 桌面版 Nowledge Mem 的状态文件一般在:
~/Library/Application Support/co.nowledge.mem.desktop/remote-mcp-oauth.jsonDocker 容器内对应路径通常是:
/etc/nowledge-mem/co.nowledge.mem.desktop/remote-mcp-oauth.json如果 compose 把配置目录挂载为 ./config,宿主机侧大概是:
./config/co.nowledge.mem.desktop/remote-mcp-oauth.json实际位置以 compose 的 volume 映射为准。定位时可以搜索 remote-mcp-oauth.json,或者先找 co.nowledge.mem.desktop 这个配置目录。
迁移前先备份旧文件:
cp remote-mcp-oauth.json remote-mcp-oauth.json.bak-$(date +%Y%m%d-%H%M%S)再覆盖 Docker 挂载目录里的同名文件,并重启容器。
最后
这套方案属于临时方案。Nowledge Mem 的 Remote MCP OAuth 管理流程要求桌面服务端设备,Docker 长期运行服务时就会遇到这个设备限制。
更理想的方案是官方支持 headless/server 部署场景,比如:
- Docker 服务生成一次性的 Remote MCP OAuth pairing URL。
- CLI 完成 Remote MCP OAuth 初始化。
- 桌面端 OAuth 状态支持导出和导入。
- 文档说明 Docker 部署时如何备份、恢复和迁移 OAuth 状态。
Docker 很适合作为长期运行的 MCP server。如果 Nowledge Mem 官方提供无浏览器 OAuth 流程,这类部署会顺很多。