4.2 KiB
The hub as an MCP server — the hub-mcp plugin
Core's until 2026-11-28 (backend/mcpserver/, since 2026-11-03). The MCP
server an AI app — Claude.ai (web, phone, desktop), ChatGPT, Le Chat, Cursor,
VS Code — plugs in as a custom connector is a live plugin now:
~/projects/ai-agent-plugins/plugins/hub-mcp. Its README.md is this page's
successor: the address (https://ai-agent.gabvdl.xyz/mcp), the decisions, the
OAuth flow, the tools, how to connect each app, the limits and safety rules.
A hub without the plugin has no MCP server: /mcp, /oauth/* and the
OAuth .well-known documents answer 404. Install it from Settings → Plugins →
Catalog (operator approval: it answers HTTP on the hub's address and calls the
hub's API as you).
Decisions (Gabriel, 2026-11-28 form move-the-hub-mcp-server-into-a-plugin_2od10i)
| question | answer |
|---|---|
| how much moves | all of it: OAuth, consent, /mcp, the tools, Settings → AI apps |
| the consent page | plain HTML served by the plugin, no JavaScript |
| connections bound to a worker (Acts as) | removed; the bound ones revoked, never widened |
| existing connections, guests' AI apps switch | carried over when the plugin is installed |
| workers | the ai-agent CLI through the outbox — its switch gains Full |
What core keeps
Nothing about MCP — four generic contracts any plugin can use (plugins.md → "HTTP endpoints, the hub's API and asks"):
endpoints[]: HTTP a plugin answers on the hub's own address (/x/<pluginId>/…, or a protocol path:/mcp,/oauth/…,/.well-known/…), with what the host vouches for in the payload and an allowlist on the way back; HTML never runs a script.hub.api: the hub's API for the plugin's handlers, as the owner or — withX-AIA-As-User, through thecliscope — as a guest the plugin is granted to. Theai-agentCLI is its client library (AIA_CLI_DIR).notify.ask: a 2–3-button push to the owner and its answer (the consent page's number matching).security.record: aplugin_eventline in the Security log.
Also core's: the "mcp": true flag on a plugin's commands (which commands
an MCP server may offer as tools — GET /api/plugins/commands), the
meta.via stamp and its "via Claude.ai" pill, and the carry-over
(plugins/carryover.py hub_mcp).
Carry-over
Once the plugin is installed and enabled for the owner (at start, and right after the install):
/data/mcp.json(MCP_PATH) → the plugin's hub-scopedmcp.json, same shape. Tokens are stored hashed, so every connected app keeps working with the token it holds.- A connection bound to a worker is dropped with its tokens. It saw one profile and ran on one machine; unbound it would be the owner everywhere.
- Requests waiting for an approval and unredeemed codes are dropped.
- Every guest who held
mcp.connect— through their role (Member, an edited or custom role), anallowoverride or the pre-rolesmcpswitch, and nodeny— gets the plugin's managed grant. - A
.carried-overmarker makes it once; the old file is never deleted. - Whoever was pushed about
mcp_connected(Settings → Security) is pushed about Plugin events instead.
On a worker
A session on one of the owner's workers drives the hub with the ai-agent
CLI, in any harness, through that worker's outbox — the machine never calls
the hub (../worker/README.md, backend/workers/cli.py).
The worker's ai-agent CLI switch says how far: Off, Read, Read +
run here, or Full — the lab's CLI as the owner (any machine, the
plugins' commands), what an unbound MCP connection on the EVOX2 used to give.
Remove the old connector from a worker's Claude Code once this is deployed:
claude mcp remove --scope user ai-agent.
Routing
Unchanged: the homelab's ai-agent-mcp router (services/ai-agent/traefik.yml)
serves /mcp, /oauth/* and the OAuth .well-known files on the guest host —
no compress / secure-headers, 10 req/s per IP (burst 100) — and they never
answer on the owner's internet address. The consent page moved from the PWA's
/connect/<id> to the plugin's /oauth/connect/<id> (the old address
redirects), which the guest and admin routers already reach.