feat(plugins): the MCP server leaves core for the hub-mcp plugin; a worker's CLI gets Full #41
Closed
gabrielvidal
wants to merge 0 commits from
hub-mcp-plugin into main
pull from: hub-mcp-plugin
merge into: gabrielvidal:main
gabrielvidal:main
gabrielvidal:agy-tasks
gabrielvidal:home-declutter
gabrielvidal:perf-plugin-batching
gabrielvidal:fresh-context-plugin
gabrielvidal:remove-hooks-page
gabrielvidal:palette-plugins
gabrielvidal:linear-projects
gabrielvidal:agent-messaging
gabrielvidal:model-router
gabrielvidal:conv-card-layout
gabrielvidal:ask-more-options
gabrielvidal:agent-limits
gabrielvidal:generic-ui-strings
gabrielvidal:android-push-bridge
gabrielvidal:auto-translate
gabrielvidal:filter-chips
gabrielvidal:plugin-catalog
gabrielvidal:file-viewers
gabrielvidal:plugins-page-rework
gabrielvidal:translation-plugin
gabrielvidal:scheduled-doors
gabrielvidal:cron-jobs-plugin
gabrielvidal:context-skills-plugin
gabrielvidal:files-plugins
gabrielvidal:worker-names
gabrielvidal:details-panel-perf
gabrielvidal:services-plugin-only
gabrielvidal:fix-test-env-leaks
gabrielvidal:bg-shells-plugin
gabrielvidal:feat-commits-plugins
gabrielvidal:fix-branch-line-tag-rows
gabrielvidal:retire-dead-leftovers
gabrielvidal:runner-into-harness-pi
gabrielvidal:retire-tool-proxy
gabrielvidal:new-project-policy-plugin-only
gabrielvidal:guest-jobs-sonnet
gabrielvidal:push-buttons-everywhere
gabrielvidal:mail-send-plugin
gabrielvidal:ui-polish-batch
gabrielvidal:command-palette-plugin
gabrielvidal:keyboard-shortcuts-plugin
gabrielvidal:prompt-shortcuts-plugin
gabrielvidal:matomo-site-grants
gabrielvidal:lab-chrome-plugin
gabrielvidal:performance-plugin
gabrielvidal:whats-new-plugin
gabrielvidal:skills-agents-plugin
gabrielvidal:goals-plugin-only
gabrielvidal:storage-server-side
gabrielvidal:plugin-scheduled-conversations
gabrielvidal:plugin-fences
gabrielvidal:handoff-plugin
gabrielvidal:plugin-commands
gabrielvidal:plugin-speed
gabrielvidal:cleanup-provider-harness
gabrielvidal:plugin-conversation-labels
gabrielvidal:plugin-plan-usage
gabrielvidal:fix-worker-harness-sync
gabrielvidal:plugin-gcloud-reauth
gabrielvidal:feat/plugin-cards-in-thread
gabrielvidal:feat/plugin-proxy-wake
gabrielvidal:unify-subagents-children
gabrielvidal:wave3d-frontend-typed-plugins
gabrielvidal:wave3c-sidecar-strict-plugins
gabrielvidal:wave3a-catalog-accounts-profiles
gabrielvidal:wave3b-pricing-usage-cutover
gabrielvidal:wave1a-typed-plugins
gabrielvidal:wave1b-sidecar-runtime
gabrielvidal:fix-ios-overlay-scroll
gabrielvidal:batch2-work-resources-core
gabrielvidal:batch2-apikeys
gabrielvidal:plugin-blue-green-deploy
gabrielvidal:plugin-ship
gabrielvidal:plugin-project-env
gabrielvidal:plugin-memories
gabrielvidal:plugin-activity
gabrielvidal:plugin-templates
gabrielvidal:plugin-desk-phone
gabrielvidal:batch1-platform
gabrielvidal:plugins-list-view
gabrielvidal:dash-plugins
gabrielvidal:pets-plugin
gabrielvidal:ha-push-channel
gabrielvidal:mail-agents
gabrielvidal:graph-fix
gabrielvidal:graph-plugin
gabrielvidal:services-plugin
gabrielvidal:left-to-do-plugin
gabrielvidal:plugins-gallery
gabrielvidal:home-conv-menu
gabrielvidal:meta-business
gabrielvidal:agy-rdrand
gabrielvidal:bg-lag
gabrielvidal:conv-load-perf
gabrielvidal:askform-instant
gabrielvidal:fix/drawer-menu-done-chip
gabrielvidal:pi-midrun-compaction
gabrielvidal:interrupt-menu-btn
gabrielvidal:authz
gabrielvidal:inkling
gabrielvidal:repo-plugins
gabrielvidal:work-sync
gabrielvidal:leftovers
gabrielvidal:fix/agy-guest-guard
gabrielvidal:feat/model-presets
gabrielvidal:scroll-back
gabrielvidal:feedback-bell
gabrielvidal:feat/movies-tool
gabrielvidal:feat/running-thread-padding
gabrielvidal:feat/drawer-filter-button-card-chat
gabrielvidal:burn-rate
gabrielvidal:guest-install
gabrielvidal:guest-usage
gabrielvidal:guest-palette
gabrielvidal:guest-form-links
gabrielvidal:form-open-buttons
gabrielvidal:clarifier-lean
gabrielvidal:auto-archive
gabrielvidal:guests-profile
gabrielvidal:conv-motion
gabrielvidal:share-target
gabrielvidal:terminal-sync
gabrielvidal:work-context-past
gabrielvidal:work-context-brief
gabrielvidal:enroll-codes
gabrielvidal:open-image-file
gabrielvidal:worker-uploads
gabrielvidal:conv-drawer-search
gabrielvidal:stack-motion-v3
gabrielvidal:notif-stack-fixes
gabrielvidal:home-motion
gabrielvidal:i18n-fr
gabrielvidal:local-electricity-cost
gabrielvidal:cache-pill-thread
gabrielvidal:cache-scenarios
gabrielvidal:fresh-start
gabrielvidal:msg-select
gabrielvidal:shortcuts-setup
gabrielvidal:ui-0-40-3
gabrielvidal:outbox-landing
gabrielvidal:resume-scope
gabrielvidal:conv-filter-range
gabrielvidal:fix-subagent-form-session
gabrielvidal:ask-form-integration
gabrielvidal:form-visual-options
gabrielvidal:watcher-perf
gabrielvidal:last-msg-summary
gabrielvidal:secret-fields
gabrielvidal:commit-review
gabrielvidal:summary-mode-fixes
gabrielvidal:service-tag-parser
gabrielvidal:clarifier
gabrielvidal:fetch-diet-2
gabrielvidal:fetch-diet
gabrielvidal:conv-look
gabrielvidal:pwa-links
gabrielvidal:tool-widgets
gabrielvidal:worker-autoupdate
gabrielvidal:usage-rings
gabrielvidal:opencode-harness
gabrielvidal:notif-diet
gabrielvidal:conv-resources
gabrielvidal:scheduled-tasks
gabrielvidal:profiles
gabrielvidal:notify-exact-cost
gabrielvidal:usage-measuring
gabrielvidal:guest-projects
gabrielvidal:usage-calibration
gabrielvidal:account-switch
gabrielvidal:multiuser-improve
gabrielvidal:form-groups
gabrielvidal:multiuser
gabrielvidal:motion-reel
gabrielvidal:dashboards-fixes
gabrielvidal:split-big-files
gabrielvidal:held-regex
gabrielvidal:subagent-interrupts
gabrielvidal:form-html
gabrielvidal:tokunia-video
gabrielvidal:settings-uniform
gabrielvidal:worker-ask-fix
gabrielvidal:worker-generic-mac
gabrielvidal:runner-shortcuts
gabrielvidal:notify-unify
gabrielvidal:perf-list-cache
gabrielvidal:mac-worker
gabrielvidal:model-switch
gabrielvidal:pipeline-paths
gabrielvidal:multi-account
gabrielvidal:feature-flags
gabrielvidal:qwen38-support
gabrielvidal:url-prompt
gabrielvidal:running-pages
gabrielvidal:homelab-tag
gabrielvidal:root-project
gabrielvidal:or-models
gabrielvidal:deploying-loader
gabrielvidal:worktree-diff
gabrielvidal:conv-tags
gabrielvidal:tags-page
gabrielvidal:agents-page
gabrielvidal:icon-picker-shortcuts
gabrielvidal:conv-cta
gabrielvidal:stamp-refine
gabrielvidal:post-task-cache
gabrielvidal:post-tidy-completed
gabrielvidal:form-badge
gabrielvidal:hooks-delay-seconds
gabrielvidal:cost-dashboard
gabrielvidal:plan-forms
gabrielvidal:form-mobile
gabrielvidal:guidelines-dag
gabrielvidal:skills-view
gabrielvidal:navbar-hold
gabrielvidal:spawnbox-status
gabrielvidal:hold-editable-expand
gabrielvidal:drawer-transparent
gabrielvidal:hold-fix
gabrielvidal:hold-editable
gabrielvidal:charroll-bump
No Reviewers
Labels
No items
No labels
Milestone
No items
No Milestone
Projects
Clear projects
No projects
Assignees
gabrielvidal (Gabriel Vidal)
Clear assignees
No Assignees
gabrielvidal
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: gabrielvidal/ai-agent#41
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Summary
The hub's MCP server — the OAuth 2.1 server, the consent page,
/mcp, the tools, Settings → AI apps — leaves core for an installable live plugin,hub-mcp(ai-agent-plugins). Core keeps nothing about MCP: four generic plugin contracts replacebackend/mcpserver/. Workers drive the hub with theai-agentCLI instead (PR #33), whose switch gains a Full level for a machine trusted like the lab (the EVOX2). Gabriel's picks: formmove-the-hub-mcp-server-into-a-plugin_2od10i.A hub without the plugin has no MCP server (
/mcp,/oauth/*and the OAuth metadata answer 404). After deploying this, installhub-mcp(see "After merging").Key changes
endpoints[](backend/plugins/endpoints.py): HTTP a plugin answers on the hub's own address — under/x/<pluginId>/…or on a protocol path (/mcp,/oauth/…,/.well-known/…), nothing else. The request goes to the endpoint's action as JSON: an allowlist of headers, the body, the client's address, the surface, andcaller— who the browser is signed in as, by the gate's own rules (core/auth.identify). The answer comes back through header and type allowlists; HTML never runs a script (forced CSP: forms, links, a meta refresh). Body cap, per-address rate, 16 runs at once on their own threads. Owner's installs only, operator approval, in the approval fingerprint.hub.api(plugins/hubapi.py,plugins/actas.py): the hub's/api/*for the plugin's handlers — as the owner, or withX-AIA-As-Useras a guest through thecliscope while the plugin is theirs. Replaces the gate'sX-AIA-MCP-User. The CLI is its client library (AIA_CLI_DIR);hub/viastampsmeta.via = {kind: "plugin", …}(the "via Claude.ai" pill).notify.askandsecurity.record(plugins/hubsignals.py): a 2–3-button push to the owner and its answer (the consent page's number matching); aplugin_eventline in the Security log.Removed:
backend/mcpserver/,schemas/mcp.py,cli/mcp_tools.py+cli/mcp_server.py(now the plugin's handlers),frontend/src/business/aiApps/(Settings → AI apps,/connect/<id>— both old addresses redirect),/api/mcp*,/api/me/ai-apps, themcpSSE event, themcp.connect/mcp.managepermissions and the per-guest AI apps switch (the plugin's managed grant).Carry-over (
plugins/carryover.pyhub_mcp, at start and right after the plugin's install):/data/mcp.json→ the plugin's store, same shape, so every connected app keeps its tokens — minus the connections bound to a worker, dropped with their tokens; every guest who heldmcp.connectgets the grant; whoever was pushed aboutmcp_connectedis pushed about Plugin events.Worker CLI — Full (
backend/workers/cli.py,WorkerCli.tsx): a fourth level of the ai-agent CLI switch — the lab's CLI as the owner: every command butworktrees, any machine (--on lab),inbox,cron, the plugins' commands. Anewwithout--onstill starts on the asking worker. The worker-side CLI no longer filters commands itself: the hub's switch decides.authz/catalog.RETIRED: a retired permission still in a stored record reads without it, is never refused on save, and stays in the record for a carry-over that hasn't run yet.cli/test_library_surface.pypins the names ofai_agent/plugin_commandsthe plugin imports.Docs:
docs/plugins.md→ "HTTP endpoints, the hub's API and asks";docs/mcp.mdrewritten as the plugin's pointer;CLAUDE.md,docs/permissions.md,docs/settings.md,worker/README.md, the create-plugin skill.Caught up with main (merge
aee457cd, after cron jobs #37 and Send later #36 left core): the MCP files main had edited stay deleted; a worker's CLI on Read / Read + run here no longer haslater/scheduled/unschedule(main removed those commands — on Full the scheduled-conversations plugin's commands do it);/settings/cronand/settings/jobsredirect to the cron-jobs plugin,/settings/ai-appsand/connect/<id>to this plugin's pages;parse_whenleft the pinned CLI library surface.The finer permissions Gabriel asked for on 2026-11-28 (form
ai-apps-finer-permissions_bhloav: per tool, per connection; allow / ask on the phone / deny; projects, models, accounts, machines, expiry and own-conversations limits; a ceiling per guest) are entirely in the plugin — no core change was needed for them.Key decisions
request.caller). Through the normal action routes that would be the caller's own word: a guest granted the plugin could have posted "the caller is the owner" to the consent handler and approved an owner connection. The action routes (POST, GET, the batch read — one check inplugins/batch.resolve_call) refuse those actions, the manifest can't wire them to a command / webhook / event / provider / export, and the plugin refuses any run that isn't the dispatcher's. Found while reviewing the plugin against the contract; tested from both sides and on a live hub./oauth/connect/<id>, not under/x/hub-mcp/: browsers that already hold the app's service worker only leave/oauth/,/mcpand/.well-known/alone — a new/x/path would be answered with the app shell until the worker updates. (/x/is excluded from this build on.)originand every URL the plugin gives out are the hub's configured addresses (GUEST_PUBLIC_URL,AI_AGENT_VIEW_URL), never a request's Host — asMCP_PUBLIC_URLwas.guest_disabled); only a deleted guest's are revoked (guest_gone) — what core did.Changelog
ai-agentCLI; the bound connections are revokedTest notes
/data), on this branch merged with main: 168 modules, the only failure istest_typed_plugins(fails on main too). New:backend/test_plugin_endpoints.py(33 tests: manifest rules, dispatch, allowlists, CSP, caller identification incl. impersonation, rate and body caps, the endpoint-only rule on every action door,hub.apias owner / guest / read-only, asks, security lines, carry-over, retired permission).aee457cd): backend 171 modules, 2149 passed (main, same setup: 2142);test_typed_pluginspasses withWORKTREES_DIRset to where this worktree sits.cli/: 108 passed.tscclean,vite buildOK, vitest 1111 passed, 1 failed (the sameFreshContextCacheExpiredNotice, also failing on main). The live run below was done before that merge; the plugin's own live run (its PR) was done on the merged branch.cli/: 108 passed. Frontend:tscclean; vitest 1106 passed, 1 failed (FreshContextCacheExpiredNotice — inscripts/test-known-failures.txt, fails on main).mcp.json(an owner connection, one bound to a worker, a guest's) and a guest holdingmcp.connect; the plugin installed throughPOST /api/plugins/install. Then, over real HTTP: the MCP paths 404 before the install; carry-over (bound connection gone, old owner and guest tokens still valid, the guest granted); discovery; register → authorize → consent as the owner → token; PKCE mismatch; the phone path (the push, the right number approves, a wrong one refuses, a poll without the number gets nothing); a guest approving for themselves;tools/listandtools/callthrough the bridge as owner and as the guest; refresh rolling; revoke; a cross-site approval refused; a forged "caller is the owner" action call from a granted guest refused (403endpoint_only); the Security log lines. Scripts:.ai/artefacts/2026-11-28/hub-mcp/e2e.py,e2e_phone.py.plugin commands,inbox,workers) and as a narrowed one (403).After merging
hub-mcp→ approve (orai-agent plugin install ~/projects/ai-agent-plugins/plugins/hub-mcp). Until then Claude.ai / ChatGPT get 404s. The install carriesdata/mcp.jsonover.claude mcp remove --scope user ai-agent(the old connector; the EVOX2's unbound connection survives the carry-over as a plain owner connection until it is disconnected in Settings → AI apps).~/.claude/CLAUDE.mdon the EVOX2 still says "the hub is reachable as theai-agentMCP server": change that line to the CLI.Screenshots
On 2026-11-28 an agy run on the EVOX2 (2ca176fc) had no way to start a conversation: since 2026-11-18 a worker's CLI kept only `past`, and the hub's MCP — its stand-in — existed in Claude Code only. It shelled out to three `claude -p --model haiku` relays to call start_conversation, which named the worker EVOX2 (refused), had no parent to report to and polled wait_for_conversation for 10+ minutes. Another agy run (25c32ca5) gave up delegating. Gabriel's call: the CLI back on workers, the MCP stays. The 2026-11-16 path, on today's code: - cli/ai_agent.py: on a worker (AI_AGENT_OUTBOX_URL) the WORKER_COMMANDS go into the outbox as a `cli` item {argv, sessionId}; what the hub's run printed comes back (≈ 2–4 s, a `wait` when the run ends). The hub's run sends X-AIA-As-Worker + X-AIA-As-Worker-Mode. - backend/workers/cli.py: CliJobs runs the same CLI in a clean env (host token, AIA_AS_WORKER, its switch as the mode, CLAUDE_SESSION_ID = the sending session → the parent of what it starts: children nest and report back). The narrowing is workers/bound.py worker_caller — the same caller as a worker-bound MCP connection, worker.read / worker.run scopes. - The per-worker switch: workers.json `cli` off | read | run (unset = run, a guest's computer always off), PATCH /api/workers/{id} {cli}, Machines → the worker → Details → "ai-agent CLI". - sidecar/outbox.py: the `cli` kind (results dropped 10 min after they end); outbox_mirror answers it; worker/install.sh writes the `ai-agent` terminal shim again. - The conv-ref hook names the CLI on a worker; `past`'s lookup follows the switch. The bound MCP connection stays, optional. - Docs: CLAUDE.md, docs/mcp.md, worker/README.md. Tests: test_worker_cli.py (new), test_worker_bound.py, test_worker_routing.py, sidecar test_outbox.py, cli test_ai_agent.py / test_conv_ref.py; the whole backend per module matches main (test_typed_plugins' git-clone case fails on both). A live local hub answered every worker command through the gate. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>The hub as an MCP server (OAuth 2.1, the consent page, /mcp, Settings → AI apps) is the `hub-mcp` live plugin now (ai-agent-plugins). Core keeps nothing about MCP: four generic plugin contracts replace backend/mcpserver/. Gabriel's picks: form move-the-hub-mcp-server-into-a-plugin_2od10i. New contracts (docs/plugins.md → "HTTP endpoints, the hub's API and asks"): - `endpoints[]` (plugins/endpoints.py): HTTP a plugin answers on the hub's own address — under /x/<pluginId>/… or a protocol path (/mcp, /oauth/…, /.well-known/…). The request goes to the endpoint's action with what the host vouches for (client address, surface, and `caller`: who the browser is signed in as, by the gate's own rules — core/auth.identify); the answer comes back through header and type allowlists, and HTML never runs a script (forced CSP). Body cap, per-address rate, 16 runs at once on their own threads. An endpoint's action answers HTTP only: the action routes refuse it and the manifest can't wire it to anything else — its payload is the host's word on who is asking. - `hub.api` (plugins/hubapi.py, plugins/actas.py): the hub's API for the plugin's handlers, as the owner or — `X-AIA-As-User`, the `cli` scope — as a guest the plugin is granted to. The CLI is its library (AIA_CLI_DIR; the names a plugin leans on are pinned by cli/test_library_surface.py). `hub/via` stamps meta.via = {kind: "plugin", …}: the "via Claude.ai" pill. - `notify.ask` and `security.record` (plugins/hubsignals.py): a tappable question to the owner and its answer; a `plugin_event` Security log line. Removed: backend/mcpserver/, schemas/mcp.py, cli/mcp_tools.py + mcp_server.py, the frontend's business/aiApps (Settings → AI apps, /connect/<id> — both old addresses redirect), /api/mcp*, /api/me/ai-apps, the `mcp` SSE event, the mcp.connect / mcp.manage permissions and the per-guest AI apps switch (the plugin's managed grant). A retired permission still in a record reads without it and is never refused (authz/catalog.RETIRED). Carry-over (carryover.hub_mcp, at start and after the plugin's install): /data/mcp.json → the plugin's store, same shape, so connected apps keep working — minus the connections bound to a worker, which are dropped with their tokens rather than left as plain owner connections; every guest who held mcp.connect gets the grant; whoever was pushed about mcp_connected is pushed about plugin events. Workers: the `ai-agent` CLI switch gains Full — the lab's CLI as the owner (every command but worktrees, any machine, the plugins' commands), what the EVOX2's unbound MCP connection gave. The worker-side CLI no longer filters commands: the hub's switch decides. "Acts as" is gone; workers/bound.py stays as the CLI's narrowing. Until the plugin is installed after a deploy, /mcp and /oauth/* answer 404. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>Merged into
mainasbfeed18aby the auto-ship batch https://ai-agent.lab.gabvdl.xyz/conversation/cadefe6f-0940-4688-bc56-1306d9265430.Pull request closed