MCP认证助手

一个独立的CLI工具,用于通过OAuth客户端白名单认证远程MCP服务器(如Figma MCP),并将令牌保存以供OpenCode使用。

  • by sdaoudi
  • TypeScript
  • 本地部署
  • 27 星标
  • 更新于
在 GitHub 查看 sdaoudi/mcp-auth-helper

使用说明

mcp身份验证助手

⚠️ 临时解决方法 --此工具的存在是因为Figma的MCP服务器当前使用的OAuth客户端分配列表不包括OpenCode。一旦Figma将OpenCode添加到他们的allowlist中(在 sst/opencode#5636 和 sst/opencode#5583),将不再需要此工具。

一个独立的CLI工具,用于与使用OAuth客户端分配列表的远程MCP服务器进行身份验证(例如Figma MCP)。一旦通过身份验证,令牌将保存到 ~/.local/share/opencode/mcp-auth.json 使用vanilla OpenCode——不需要fork。

问题

一些MCP服务器(如Figma)只允许已知的OAuth客户端注册。OpenCode注册为“OpenCode”并被拒绝,因为它不在列表中。此工具注册为“Codex”(位于allowlist上),并以OpenCode期望的格式保存令牌。

这种方法基于 此变通方法提交 通过 @康诺拉兹,打包为独立工具,因此您不需要分叉OpenCode。

安装

git clone https://github.com/sdaoudi/mcp-auth-helper.git
cd mcp-auth-helper
npm install
npm run build

用法

Figma MCP

node dist/index.js auth figma --url https://mcp.figma.com/mcp

这将:

  1. 从Figma MCP服务器发现OAuth端点
  2. 注册为“Codex”OAuth客户端(位于Figma的allowlist上)
  3. 打开浏览器进行授权
  4. 将令牌保存到 ~/.local/share/opencode/mcp-auth.json

验证后,确保Figma MCP服务器已在您的 opencode.json OpenCode将自动提取保存的令牌:

{
  "mcp": {
    "figma": {
      "type": "remote",
      "url": "https://mcp.figma.com/mcp",
      "enabled": true
    }
  }
}

选项

--url <url>             MCP server URL (required)
--client-name <name>    OAuth client name (default: "Codex")
--callback-port <port>  Local callback port (default: 19876)
--output <path>         Token output path (default: ~/.local/share/opencode/mcp-auth.json)

多个服务器

您可以通过多个MCP服务器进行身份验证。每个条目都保存为单独的条目 mcp-auth.json:

node dist/index.js auth figma --url https://mcp.figma.com/mcp
node dist/index.js auth another --url https://another-mcp.example.com/mcp

运作原理

  1. 通过RFC 8414发现服务器的OAuth端点(/.well-known/oauth-authorization-server)
  2. 注册一个名为“Codex”的动态OAuth客户端(可配置)
  3. 使用PKCE启动OAuth授权代码流(S256)
  4. 启动本地HTTP服务器以接收回调
  5. 交换访问/刷新令牌的授权码
  6. 将所有内容保存到 ~/.local/share/opencode/mcp-auth.json 采用OpenCode的预期格式

需求

  • Node.js 18+

学分

基于 变通提交 通过 @康诺拉兹,重新打包为独立的CLI工具。

相关问题:

许可证

麻省理工学院