A plugin declares `commands` in plugin.json — each one names a declared action, with a summary, its args and how to print the answer — and gets `ai-agent plugin <id> <command> …` and, opt-in (`"mcp": true`), the MCP tool `plugin_<id>_<command>`. Core no longer names any plugin (Gabriel's form ai-agent-cli-and-mcp-for-live-plugins_fevcts: manifest commands, namespaced under `plugin`, MCP opt-in, guests by their grants). - backend/plugins/commands.py: validation (names, typed args, positional order, output text|rows, ≤ 64-char tool names, no commands for a plugin named like a core verb) and the caller's catalogue; GET /api/plugins/commands (plugins.use — a guest's CLI and AI-app connection see the plugins granted to them, never an ownerOnly action). Not in the approval fingerprint: a command only reaches an action the plugin already declares, through the same route. The consent card lists them. - cli/plugin_commands.py: the per-plugin argparse parser, table/text printing, `ai-agent plugin commands`, `ai-agent plugin call ID ACTION` (any action, raw), and the MCP tool specs. readOnly actions go by GET ?payload=, so read-only MCP connections work. - cli/mcp_tools.py: tools/list appends the plugin tools (read group when readOnly, run otherwise; none on a worker-bound connection); tools/call runs them. - Removed the hard-coded plugin surfaces: `ai-agent plans|memories|goals`, MCP browse plans|goals|memories, read_document, work_on_goal (goals is not used — Gabriel). Plans and memories come back as their plugins' commands. This also fixes read-only MCP connections, which got "this connection is read-only" on plans and memories since they moved to plugins (the CLI POSTed). `ai-agent plans` now says where its commands are. - openapi.json + orval regenerated, authz golden matrix (+1 route), docs (plugins.md "Commands", mcp.md, CLAUDE.md, create-plugin skill). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
9.9 KiB
The hub as an MCP server
Since 2026-11-03. An AI app — Claude.ai (web, phone, desktop), ChatGPT, Le
Chat, Cursor, VS Code — plugs ai-agent in as a custom connector and drives
it with the ai-agent CLI's commands as tools: start a conversation, continue
one, wait for its answer, read and search them, schedule work, run an agent.
Address: https://ai-agent.gabvdl.xyz/mcp — the guest host, the one
the internet reaches (the apps call it from their own servers, not from the
browser).
Decisions (Gabriel, 2026-11-03 form)
| question | answer |
|---|---|
| who can connect | the owner, and the guests he switches AI apps on for |
| endpoint | ai-agent.gabvdl.xyz/mcp (already public) |
| the owner approves | both: on the admin host (Authelia) or from the Pixel, by number matching (since 2026-11-15) |
| tool groups | read, run, schedule, agents & cron (not worktrees, not What's new) |
| read-only vs full | picked per connection, on the consent page |
| personal tokens | no — every app goes through OAuth + an approval |
stdio ai-agent mcp |
no |
| tokens | 1 h access, 90-day rolling refresh, revocable |
| "via Claude.ai" pill | yes |
Flow
app ──POST /mcp──────────────────────────────► 401 + WWW-Authenticate (resource_metadata)
app ──GET /.well-known/oauth-protected-resource/mcp, …/oauth-authorization-server
app ──POST /oauth/register (RFC 7591) ───────► client_id (+ secret if confidential)
browser ──GET /oauth/authorize?…&code_challenge (S256)
└─► parked request ─► 302 /connect/<id> (PWA page, outside the shell)
· owner on ai-agent.lab (Authelia): Allow (full / read) ─► code
· owner elsewhere: picks full / read, "Approve on my phone" ─► the page shows a
two-digit number, the push offers three: the one on the page allows, any
other refuses (the page polls /oauth/consent/<id>) ─► code
· guest signed in on ai-agent.gabvdl.xyz, AI apps on: "Allow as Dom" ─► code
└─► 302 back to the app's redirect URI with code + state + iss
app ──POST /oauth/token (code + verifier) ───► access (1 h) + refresh (90 d, rolled)
app ──POST /mcp Authorization: Bearer … ────► initialize · tools/list · tools/call
The tools run inside the backend against its own API over loopback, as the
connection's caller: the owner, or — via the X-AIA-MCP-User downgrade — the
guest, limited to their CLI's routes.
Tools
| group | tools |
|---|---|
| read | list_conversations · get_conversation · search_conversations · past_conversations · inbox · browse (projects, services, skills, agents, cron, scheduled, models, workers, usage, budget) · wait_for_conversation |
| run | start_conversation · send_message · fork_conversation · stop_conversation · rename_conversation · archive_conversation |
| schedule | schedule_conversation (in / at, new or to an existing one) · cancel_scheduled |
| agents | run_agent · run_cron_job · set_cron_job |
| plugins | plugin_<id>_<command> — every command a live plugin's plugin.json marks "mcp": true (in group read when its action is readOnly, else run), e.g. plugin_plans_ls, plugin_plans_show, plugin_memories_ls, plugin_memories_show |
A guest gets the conversation tools, inbox, browse (projects, models,
budget) and the plugin tools of the plugins granted to them. A read-only
connection gets the read tools — the read-only plugin tools too, called by
GET. Plugin tools are listed from GET /api/plugins/commands on each
tools/list (the hub answers as the connection's caller); a hub that can't
list them leaves the core tools. Plans, memories and goals were core tools
until 2026-11-26 (browse plans|goals|memories, read_document,
work_on_goal); plans and memories are now their plugins' tools, goals has
none. Docs: docs/plugins.md → "Commands".
Connecting an app
- Claude.ai: Settings → Connectors → Add custom connector → paste the
address → Add → Connect. Its callback is
https://claude.ai/api/mcp/auth_callback(claude.com later — both fine). - ChatGPT: Settings → Apps & Connectors → Advanced → Developer mode, then Create → the address, authentication OAuth.
- Others (Le Chat, Cursor, VS Code, Claude Code
claude mcp add --transport http ai-agent https://ai-agent.gabvdl.xyz/mcp): a remote HTTP MCP server with OAuth. Claude Code on a worker: see "On a worker" below.
On a worker (Claude Code on the Orus MacBook)
Since 2026-11-18 (Gabriel's form: this replaces the ai-agent CLI through
the worker's outbox, 2026-11-16 → 11-18). A Claude Code on one of the owner's
workers drives the hub with these tools through a connection bound to that
worker:
| what | answer |
|---|---|
| the CLI path | removed for every worker — the CLI keeps only past there (an outbox lookup) |
| what the connection sees | bound to the worker: its profile's conversations, runs on that machine only |
| setup | one-time, by hand on the Mac |
Setup on the Mac (once):
- In a terminal:
claude mcp add --transport http --scope user ai-agent https://ai-agent.gabvdl.xyz/mcp— user scope, so the runs the hub launches there get it too (same~/.claude.json). - In
claude:/mcp→ ai-agent → Authenticate. The browser opens the consent page: pick Read only, Approve on my phone, tap the number the page shows (or approve onai-agent.lab). - On the hub: Settings → AI apps → the new Claude Code connection → Acts as → the worker (Orus Macbook), then switch Read-only off for full access. Approving read-only first means it never holds full owner access, not even for the minute before it is bound.
What binding does (grant.worker, PATCH /api/mcp/connections/{id}
{worker}, "" unbinds; owner connections only, never to a guest's
computer). Every tool call carries X-AIA-As-Worker: <id> and
X-AIA-As-Worker-Mode: run|read (from the connection's scope), and the gate
answers it as workers/bound.py worker_caller — the owner, narrowed:
- tools:
WORKER_TOOLS(cli/mcp_tools.py) — the conversation tools,wait,past,browse(scheduled, models, workers, usage, budget) and the schedule tools. Noinbox, agents, cron or plugin tools, no browse of projects / services / skills (the lab's own files). OnlyREAD_ROUTES(+RUN_ROUTESfor a full connection) answer. - reads: the worker's own profile's conversations only
(
Caller.profile→users/access.pyvisible/filter_cards). - writes: on that worker only.
start_conversation/schedule_conversationare pinned to it (anotherworkeris a 403,newProjecttoo); send / fork / stop / rename / archive take only conversations that ran there (access.ensure_runs_here), cancel only its own scheduled entries, and aparentit can't see is dropped. - A bound connection whose worker is unpaired gets nothing (403), never the owner's full access.
The Mac now calls the hub — ai-agent.gabvdl.xyz, the public host, over
OAuth — where a worker otherwise never does. That is the trade Gabriel picked;
the binding is what keeps a work laptop's Claude Code out of the Personal
profile.
Limits and safety
- Registration is open (it grants nothing): ≤ 200 apps and ≤ 10 a day per
address, unapproved ones pruned after a day; redirect URIs https, loopback
http or an app's own scheme — plain ASCII, a lower-case host, no userinfo,
no backslash or whitespace, and they must survive a parse/unparse round
trip (
https://evil.example\@claude.ai/cbis claude.ai to Python and evil.example to a browser). - ≤ 20 requests waiting at once and ≤ 3 per address, each for 15 min. Approval pushes: ≤ 2 per address and ≤ 6 overall per 10 min, ≤ 20 a day; past that the page says to approve on the admin host.
- The phone approves by number matching (2026-11-15). Before, the push
had Allow / Read only / Deny, and whoever had opened the consent page
collected the code once Allow was tapped: anyone on the internet could
register an app named "Claude" with the real claude.ai callback, raise the
push and wait for a reflex tap. Now the page that asks for the push shows a
number (in the answer to that request only — the poll never repeats it; the
tab keeps it in
sessionStorage), the push offers three, and only that number approves, with the access picked on the page. Any other answer refuses and closes the request. The page always says "only allow this if you just started it from the app". - A decision takes the request out of the store in the same step and hands the code to the caller that decided — it is never parked where a poll on the request's id could pick it up.
- A refusal (or a request refused before consent: no PKCE, wrong resource…)
is only sent back to the usual apps' callbacks (
KNOWN_REDIRECT_HOSTS); for any other address the page says so and redirects nowhere. - The owner's approve call needs Authelia and a same-origin request.
- Tokens: a rolled refresh token is remembered. Presented again after its
60 s grace, it ends the connection if anything minted after it was ever
used (two holders); if nothing was (the app never got the answer), it is
served again and the unused pair dies. Revoking a refresh token
(
/oauth/revoke) ends its connection; ≤ 12 token records per connection. Deleting a guest ends their connections. A connection with no user is refused, never the owner's. /oauth/registertakes ≤ 64 KB,/oauth/tokenand/oauth/revoke≤ 16 KB,/mcp≤ 2 MB.- Revoking (Settings → AI apps → Disconnect, or a guest's own page) drops the connection's tokens at once; switching a guest's AI apps off cuts theirs on the next call.
- Traefik:
ai-agent-mcprouter, no compress / secure-headers, 10 req/s per IP (burst 100).