mcp-oauth-remote-gateway
Skill này làm gì
Skill xử lý đăng nhập OAuth thủ công cho một máy chủ MCP kết nối với gateway Hermes từ xa, rồi lưu token vào nơi Hermes cần. Phù hợp với người chạy Hermes trong container, VPS hoặc máy từ xa khác.
Khi nào nên dùng
- ✓Khi bạn muốn thêm một máy chủ MCP từ xa cần đăng nhập OAuth trên thiết lập Hermes từ xa.
- ✓Khi luồng đăng nhập OAuth trên trình duyệt thất bại vì Hermes chạy trên máy chủ.
- ✓Khi bạn muốn tránh phải đăng nhập lại trên trình duyệt sau mỗi lần tải lại.
Liên kết skill
https://github.com/NousResearch/hermes-agent/blob/main/optional-skills/mcp/mcp-oauth-remote-gateway/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Kết nối máy chủ MCP Linear của chúng tôi với gateway Hermes trên VPS, nơi cần đăng nhập OAuth.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Agent hướng dẫn bạn đăng nhập trên trình duyệt, lấy mã ủy quyền và ghi token vào các file mà Hermes dùng. Những lần tải lại sau đó sẽ tìm thấy token đã lưu và bỏ qua bước đăng nhập trên trình duyệt.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
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:
- The user wants to add a remote HTTP MCP server that requires OAuth (not a static Bearer token).
- Hermes is running as a remote gateway (container, VPS, Docker, managed service) — NOT a local CLI on the user's laptop.
- 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: oauthinmcp_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):
- Picks a free local port
P. - Registers a dynamic OAuth client with the AS, sending
redirect_uri = http://127.0.0.1:P/callback. - Starts an HTTP server on
127.0.0.1:Pinside the Hermes process. - 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):
- 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. - 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
Câu hỏi thường gặp
Khi nào skill này không áp dụng?
Skill nói không dùng cho bản cài Hermes trên máy riêng của bạn, vì máy đó có thể dùng luồng đăng nhập thông thường.
Nếu máy chủ không hỗ trợ đăng ký động thì sao?
Skill nói nó không áp dụng, vậy hãy dùng một ứng dụng OAuth đã đăng ký trước hoặc một personal access token.
Vì sao luồng thông thường bị lỗi trên máy chủ?
Địa chỉ callback của nó trỏ về máy tính của bạn thay vì máy chủ từ xa, nên mã đăng nhập không bao giờ đến nơi.
Chi tiết
Mô tả gốc của tác giả
Manual OAuth for remote MCP servers on headless gateways.
Độ phổ biến
- Sao GitHub
- 260k
- Vị trí xếp hạng
- #504
- Giấy phép
- MIT
- Cập nhật
- 2/11/2026
Bình luận
- …
Thêm skill từ kho mã này
agent-merge-conflict-arbiter
260kGiải quyết xung đột merge git giữa nhánh của hai agent với vai trò bên trung lập, tạo ra một kết quả merge duy nhất cho repo.
antigravity-cli
260kHướng dẫn bạn cài đặt, cập nhật và khắc phục sự cố công cụ dòng lệnh Antigravity, gồm plugin, đăng nhập và sandbox.
blackbox
260kCho phép agent của bạn giao một tác vụ lập trình cho công cụ dòng lệnh Blackbox AI, công cụ chạy nhiều mô hình và chọn kết quả tốt nhất.
dynamic-workflow
260kDạy agent của bạn chạy các đợt công việc tương tự lớn như một script đã lưu, để chỉ kết quả đã kiểm chứng mới quay về cuộc trò chuyện chính.
Skill tương tự
mcporter
394kGiúp agent của bạn liệt kê, gọi và kiểm tra các máy chủ MCP cùng công cụ của chúng qua HTTP hoặc stdio, và quản lý cài đặt đăng nhập.
chatgpt-app-builder
144kGiúp agent của bạn xây dựng ứng dụng ChatGPT với widget tương tác, dùng framework mcp-use và OpenAI Apps SDK.
mcp-apps-builder
144kGiúp agent của bạn xây dựng và sửa máy chủ MCP với tool, resource, prompt và widget, theo các thực hành tốt nhất của framework mcp-use.