跳到正文
Skillpedia
连接器(MCP)260k · #504

mcp-oauth-remote-gateway

它能做什么

它为连接到远程 Hermes 网关的 MCP 服务器手动处理 OAuth 登录,然后把令牌保存到 Hermes 所需的位置。适合在容器、VPS 或其他远程机器上运行 Hermes 的人。

适用场景

  • ✓你想在远程 Hermes 环境中添加需要 OAuth 登录的远程 MCP 服务器的时候。
  • ✓因为 Hermes 运行在服务器上,普通的 OAuth 浏览器流程失败的时候。
  • ✓你希望重新加载后不必再次进行浏览器登录的时候。

技能链接

https://github.com/NousResearch/hermes-agent/blob/main/optional-skills/mcp/mcp-oauth-remote-gateway/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/NousResearch/hermes-agent/blob/main/optional-skills/mcp/mcp-oauth-remote-gateway/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“请把我们的 Linear MCP 服务器连接到我 VPS 上的 Hermes 网关,它需要 OAuth 登录。”

每周 5 个新技能,1 分钟读完。

工作原理

智能体引导你在浏览器中完成登录,获取授权码,并把令牌写入 Hermes 使用的文件中。之后重新加载时,Hermes 会找到已保存的令牌,不再需要浏览器流程。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

MCP OAuth on a Remote Hermes Gateway

Overview

Hermes' built-in MCP OAuth client runs a one-shot HTTP listener on 127.0.0.1:<port> inside the Hermes process and registers that loopback address as the OAuth redirect_uri. That works perfectly for a local CLI on the user's own machine. It breaks completely when Hermes runs as a remote gateway (container, VPS, messaging bot), because the user's browser resolves 127.0.0.1 to the user's own laptop, not the remote container — so the authorization code never reaches Hermes.

This skill does the OAuth dance by hand and writes the resulting tokens into the exact files Hermes' token storage expects, so a subsequent /reload-mcp finds cached tokens and skips the browser flow entirely.

When to Use

Use this skill when all of the following are true:

  1. The user wants to add a remote HTTP MCP server that requires OAuth (not a static Bearer token).
  2. Hermes is running as a remote gateway (container, VPS, Docker, managed service) — NOT a local CLI on the user's laptop.
  3. The server supports OAuth 2.1 with PKCE and RFC 7591 Dynamic Client Registration (most modern MCP servers do — Better Stack, Linear, Cloudflare, Datadog, etc.). If it doesn't support DCR (GitHub is the notable exception), this skill does not apply — use a pre-registered OAuth App or a Personal Access Token instead.

Do NOT use this for:

  • Local CLI Hermes — just set auth: oauth in mcp_servers.<name> and /reload-mcp. The built-in flow opens a browser and captures the callback on localhost. Works perfectly.
  • Servers that accept a static Bearer token (API key) — always prefer headers.Authorization: "Bearer <token>" when the user is willing. Simpler, no refresh dance.
  • GitHub Copilot MCP (api.githubcopilot.com/mcp/) — GitHub does not expose DCR. Use a PAT or a pre-registered OAuth App (see pitfall 12).

Why the Built-in OAuth Flow Fails on a Remote Gateway

Hermes' native MCP OAuth client (tools/mcp_oauth.py):

  1. Picks a free local port P.
  2. Registers a dynamic OAuth client with the AS, sending redirect_uri = http://127.0.0.1:P/callback.
  3. Starts an HTTP server on 127.0.0.1:P inside the Hermes process.
  4. Prints the authorize URL and waits for the code at its local endpoint.

When Hermes runs remotely, the 127.0.0.1 in the redirect_uri is the remote container's loopback, not the user's. After authorizing, the user's browser 302s to http://127.0.0.1:P/callback?code=..., which resolves to the user's own laptop and fails to connect. The callback never reaches the Hermes process, the flow times out, and /reload-mcp returns "No MCP tools available" with no detail.

Symptoms to recognize: [xdg-open] <defunct> processes under the hermes user, an empty or missing tokens directory ($HERMES_HOME/mcp-tokens/), and a reload that responds without any "Added/Reconnected: X" line in change_detail.

Cheap First Fallbacks: the Built-in Flow's Own Escape Hatches

Before any manual token surgery, check whether the built-in flow's fallbacks already cover the deployment. When Hermes detects a remote session it prints two options alongside the authorize URL (tools/mcp_oauth.py):

  1. Paste-back — on an interactive TTY, a stdin reader races the HTTP listener. The user authorizes, the browser fails to connect to 127.0.0.1:<port>, and they paste the full address-bar URL (?code=...&state=...) back at the prompt. Works for SSH'd-in CLI sessions.
  2. SSH port-forward — ssh -N -L <port>:127.0.0.1:<port> <user>@<host> makes the redirect reach the remote listener normally.

Both require an interactive terminal to the Hermes host. The rest of this skill is for when there is NO interactive TTY — Hermes running purely as a messaging gateway/bot where /reload-mcp triggers the flow with nobody at a prompt.

Preferred Front Door: the Hermes Dashboard (try this BEFORE manual token surgery)

A remote Hermes gateway often also runs the dashboard web UI as a SEPARATE process (e.g. hermes dashboard --host 0.0.0.0 --port <port>; check with ps aux | grep 'hermes dashboard'). It exposes a connector/MCP console — endpoints like /api/mcp/servers, /api/mcp/status, and /connectors (all login-gated; a cookieless curl returning 401/302 confirms they exist).

Why the dashboard solves the core problem: when the user drives OAuth from the dashboard in their own browser, the redirect lands in a context the dashboard can capture — sidestepp

常见问题

什么情况下不适用这个技能?

技能说明,如果 Hermes 安装在你自己的电脑上,则不应使用它,因为可以走普通的登录流程。

如果服务器不支持动态注册怎么办?

技能说明它不适用,此时请使用预先注册的 OAuth 应用或个人访问令牌。

为什么普通流程在服务器上会失败?

因为它的回调地址指向你自己的电脑,而不是远程服务器,所以登录码无法送达。

详情

作者的原始描述

Manual OAuth for remote MCP servers on headless gateways.

repo: NousResearch/hermes-agent

热度

GitHub 星标
260k
排名
#504
许可证
MIT
更新时间
2026/11/2

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能