Repository navigation
Add a local MCP server core so other apps can use Aiden's chats - #800
Conversation
Aiden can now serve MCP on a dedicated loopback listener, off by default, so Claude Code, Codex or any MCP client on the same computer can list workspaces and chats, read them, and (with Supervised access) start, send to, wait on and stop Aiden turns. Approvals and questions stay with the person in Aiden; no tool can answer them. - Stateless Streamable HTTP on 127.0.0.1 with a stable saved port, exact Host and same-origin checks, no CORS, a 1 MiB body limit and a connection cap. - Outside apps are Remote devices of type "agent" with their own tokens, quota and a Read/Supervised capability ceiling re-applied on every state parse; /api/aiden/v1 refuses them and /mcp refuses phones and Macs. - Per-app turn rate limit and run cap, idempotent clientRequestId, own-run wait and stop, Bot chats and hidden workspaces out of reach. - Revoking an app ends its waits, stops its runs and denies their approvals through the shared revocation path. - Local-only "started by" provenance, never projected. - Main-process status/enable/issue/list/revoke functions for the Settings UI that follows; no UI or CLI wiring yet. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An agent credential could read, wait on, send to or stop assistant and design-project chats by id although aiden_chat_list hides them. Every chat tool now refuses any chat the list leaves out with the unknown-id answer, so an app cannot learn such a chat exists. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Important
MCP turns currently violate the documented analytics contract, and two lifecycle guarantees can fail after cache pressure or stream races.
Reviewed changes in 0300151, covering the complete 18-file diff and the surrounding Remote state, chat, stream, analytics, and lifecycle paths.
- Loopback transport. Adds the off-by-default Streamable HTTP listener, stable-port selection, Host/Origin checks, bearer authentication, request limits, and connection handling.
- Outside-app identity. Adds
agentrecords, capability ceilings, audience separation, quotas, persisted server settings, and revocation integration. - Chat tools. Adds read/write tool schemas, ordinary-chat/workspace filtering, run ownership, long polling, rate/concurrency limits, and request replay.
- Runtime integration. Reuses the Remote chat and stream services, adds observer-only stream watches and local provenance, exposes main-process controls, and documents the threat model and follow-up UI/CLI work.
⚠️ MCP activity is sent as phone analytics
aiden_chat_start reaches both the existing chat_created and chat_message_sent reporters, while aiden_chat_send reaches chat_message_sent. Since an agent is not a peer, the latter is recorded with origin: "phone", contradicting the new no-analytics guarantee and contaminating phone usage metrics.
Technical details
# Keep MCP activity out of product analytics
## Affected sites
- `main/services/aiden-remote-service-main.ts:1285-1290` — the MCP runner receives the shared Remote chat service without an MCP-specific analytics policy.
- `main/services/chat-application-service.ts:274-275` — every newly created chat reports `chat_created`.
- `main/services/aiden-remote-chats.ts:2942-2950` — every started Remote turn reports `chat_message_sent`, and a non-peer device becomes `origin: "phone"`.
- `docs/aiden-mcp-server.md:99` and `docs/security/aiden-remote-threat-model.md:196` — both state that the MCP server sends no analytics events.
## Required outcome
- Starting or sending an MCP turn must not emit `chat_created`, `chat_message_sent`, or another analytics event if the documented no-analytics policy remains the intended contract.
- Add behavioral coverage with a registered analytics reporter so this is proved at the MCP entry point rather than inferred from source shape.@v0 or keep the SHA fresh with Dependabot | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using GPT Sol | 𝕏
There was a problem hiding this comment.
ℹ️ The new chat-visibility restriction is sound; one stale project-memory claim remains inline.
Reviewed changes since the prior Pullfrog review, covering commit 24c277f and its six-file incremental diff.
- Chat visibility. Adds
isListedChatand applies the same summary-list inclusion policy to read, wait, send, and stop operations by id. - Non-enumeration coverage. Verifies assistant, design-project, and unknown chat ids all receive the same not-found result, and updates the user and threat-model docs.
- Prior findings. This commit does not touch the three findings raised against
0300151; they remain open.
@v0 or keep the SHA fresh with Dependabot | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using GPT Sol | 𝕏
…nd no usage data - aiden_chat_wait re-reads the run once its watch is attached, so a run that finishes in between wakes it at once, and it answers with the finished state it saw even if that run is later evicted. - A clientRequestId Aiden already recorded replays without counting against the rate limit or run cap, after the in-memory cache forgets it or a restart. - Chats and turns from an MCP app (an agent device) send no chat_created or chat_message_sent. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…analytics notes Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The app's token is tombstoned first; a BotCapabilityUnavailableError from removing its Bot notice audience (no Secret Service on Linux, say) is now logged instead of failing the revoke and leaving the app listed in Settings. Phone revokes still require it. Ported from W4b (#803). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
ℹ️ No critical issues — one documentation mismatch is noted inline.
Reviewed changes since the prior incremental head, covering the MCP revocation adjustment in be96c7b.
- Completed degraded revocation. Allowed an MCP app's already-tombstoned revocation to finish when Bot capability storage is unavailable.
- Preserved paired-device strictness. Kept Bot notice cleanup failures blocking for phone and desktop-device revocation while logging the MCP-only degraded case.
@v0 or keep the SHA fresh with Dependabot | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using GPT Sol | 𝕏
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`revokeBotNoticeAudience` in bot-capability-store-core.ts decides when a revoke may skip clearing Bot notices: only for an outside app, and only on BotCapabilityUnavailableError. It has its own behavioral test. Remote main now calls it, and the bots contract matches that call, which fixes the runtime-subagents failure from be96c7b. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes since the prior Pullfrog review at be96c7b, covering the two new commits and their integration with the complete PR.
- Documented degraded revocation. Added the content-free
revoke-bot-notices-unavailableevent to the MCP log inventory. - Shared Bot notice policy. Extracted MCP best-effort versus paired-device strict cleanup into
revokeBotNoticeAudience, added focused behavioral coverage, and updated the production wiring contract.
@v0 or keep the SHA fresh with Dependabot | View workflow run | Using GPT Sol | 𝕏
aidenMcpTokenEnvName gives every app its own AIDEN_MCP_TOKEN_<NAME>_<ID> variable, so the desktop Settings sheet and aiden apps connect can print the same setup commands and two apps in one shell profile keep separate tokens. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes since the prior Pullfrog review at 27e6113, covering the per-app token-variable update in b8ae294.
-
Added shared token naming. Introduced
aidenMcpTokenEnvNameto derive shell-safe, app-specific environment variable names from each app's name and random device id. -
Updated client setup commands. Switched the Claude Code and Codex examples to environment-backed bearer tokens using syntax supported by each client's saved MCP configuration.
-
Registered behavioral coverage. Added a real-shell test for valid, independent exports and included it in the Remote test suite and CI registry.
@v0 or keep the SHA fresh with Dependabot | View workflow run | Using GPT Sol | 𝕏
# Conflicts: # package.json
A turn an app starts follows the workspace's approval policy (Ask, Auto, Never ask and Allowed in this workspace grants) exactly like the person's own and a phone's. The guide, the threat model and aiden_chat_start's description now say what runs without a card in each mode, and that toolPermission is the phone tier (full whenever anything can run without a card).
There was a problem hiding this comment.
Important
The new approval-mode guidance overstates what toolPermission: "ask" guarantees, so a Supervised app can still run a tool unattended while following the documented recommendation.
Reviewed changes since the prior Pullfrog review at b8ae294, including the current-main merge and the approval-mode documentation update.
-
Clarified approval inheritance. Documented that MCP-started turns use the workspace's global or customized Ask, Auto, or Never ask policy and its Mac grants.
-
Updated tool disclosure. Expanded
aiden_chat_startto tell clients that the workspace policy governs which calls still require the person. -
Reconciled current main. Preserved MCP test registration while merging the latest base changes.
@v0 or keep the SHA fresh with Dependabot | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using GPT Sol | 𝕏
| - **Never ask:** only purchases, sharing the person's data and the first use of the computer wait for the person. Everything else runs unattended. | ||
| - **Chat only** workspaces cannot read or change their folder in any mode. | ||
|
|
||
| `aiden_workspace_list` reports each workspace's `toolPermission` as the same tier a phone sees (`legacyWorkspaceTier`): `none` for Chat only, `ask` for Ask with nothing allowed in the workspace, and `full` whenever something can run without a card (Auto, Never ask, or any grant). A well-behaved app that should not run tools unattended can start turns only where `toolPermission` is `ask`, but Aiden does not enforce that for it. |
There was a problem hiding this comment.
toolPermission: "ask" does not guarantee that every consequential action will show a card: an Always allow rule can run a non-Mac tool in Ask, while legacyWorkspaceTier considers only the mode and Mac grants. Please remove this safety guarantee or expose/enforce a signal that accounts for every unattended allow path.
Technical details
# Do not present the legacy tier as an unattended-execution boundary
## Affected sites
- `docs/aiden-mcp-server.md:71` — recommends `toolPermission: "ask"` to apps that must not run tools unattended.
- `renderer/shared/approval-mode.ts:272-278` — computes that tier from mode and Mac grants only.
- `main/services/approval-gate/workspace-tool-approval.test.ts:141-145` — proves an Always allow connector rule runs a send in Ask.
## Required outcome
- The MCP guidance must not imply that `toolPermission: "ask"` excludes every unattended tool path unless the implementation actually enforces that invariant.
Summary
Workstream W4a of the upstream week: the core of a local MCP server that lets other apps on the same computer (Claude Code, Codex, any MCP client) use Aiden's chats. Ported in spirit from T3 Code PR #33196. No code was copied.
@modelcontextprotocol/sdk1.32.1) on a dedicated127.0.0.1listener at/mcp.port_in_use.mcpServerhost capability (macOS and Linux desktop), and switched separately from Remote Access.Hostand same-originOriginchecks, refused with 403OPTIONSincludedagent.server:readandchat:read) or Supervised (addschat:write). That ceiling is re-applied on every state parse, soapproval:respond, files, Git, Bots, schedules and settings can never be granted./api/aiden/v1refuses agent tokens, and/mcprefuses phone and Mac tokens.aiden_prefixed):server_info,workspace_list,chat_list,chat_read,chat_waitchat_start,chat_send,chat_stopchat_waitis a bounded long-poll (55 s at most) that returnsrunning,waiting_for_approval,waiting_for_input,doneorfailed, says where to approve ("Aiden on "), and returns early when the app disconnects.clientRequestIdis required, and a retry returns the original chat and run.revokeAidenRemoteRuntimeDevice: it ends the app's waits, stops its runs and denies their approvals.startedBy {kind: "app", name}record is kept inaiden-mcp-chat-provenance.jsonand is never sent anywhere.aidenMcpServerStatus,setAidenMcpServerEnabled,issueAidenMcpApp,listAidenMcpAppsandrevokeAidenMcpApp. This PR has no Settings UI (W4b) and noaiden servewiring (W4c).Docs:
docs/aiden-mcp-server.md: threat model, tools, limits, and theclaude mcp addandcodex mcp addsnippetsdocs/security/aiden-remote-threat-model.md.memory/aiden-mcp-server.mdTests
New
main/services/aiden-mcp-server.test.tshas 13 behavioral tests. It uses a real registry, stream service and chat service over a real MCP client, with fakes only for storage and generation. It covers:/mcpchat_startThe state and router suites gain tests for the agent capability ceiling, a tampered state file, the quota, the saved switch and port, and agent tokens refused on
/api/aiden/v1. The new file is registered intest:aiden-remoteandscripts/ci-test-registry.json.Validation
npx tsx --test main/services/aiden-mcp-server.test.ts: 13/13 passed in 10 consecutive runs, after fixing a 413 race that showed up as an intermittent ECONNRESETnpm run test:aiden-remote: everything passes except 4 tests inscripts/aiden-remote-lan-transport-spike.test.mjs. This branch does not touch that file. Its certificate setup runsopenssl x509 -days 0 -copy_extensions, and neither openssl on this Mac accepts that: Homebrew OpenSSL 4.1 refuses-days 0, and macOS LibreSSL lacks-copy_extensions. CI's OpenSSL 3 should run it.npm run test:ci-policynpm run type-checknpx eslinton every touched filenpm run cli:buildFollow-ups
packages/clihas no@modelcontextprotocol/sdkdependency and no MCP host inaiden serveyetCI flakes
tests/e2e/design-mode.spec.ts:672"Aiden asks to open design mode on a card, then puts its work on the canvas; Not now leaves the chat as it was" failed on Electron E2E (4/4) at head b8ae294.Protocol error (Page.handleJavaScriptDialog): No dialog is showingon the first attempt and on retry Use catalog-driven runtime model limits #1. It then passed, so--fail-on-flaky-testsfailed the job.🤖 Generated with Claude Code
Flaky CI seen after merging main (2026-11-17)
On the run for 93b47c6 (Actions run 44030902768, attempt 1), two required jobs failed in code this PR does not touch. It changes no
ios/ordesign-canvasfile.Desktop tests (core-git)(job 133862466441):main/services/design-canvas/watch.test.tsfailed with "an event naming no file leaves a page that holds the canvas's own write, and reports the other pages". This is the same watcher race Read a call you stopped as "stopped", not as an issue #797 recorded, and Design canvas watcher: let go of a note when its window closes between two clock readings, and fix a timing-dependent test #828 fixes it.iOS build and simulator tests(job 133862466262):AidenBotSessionActivityTests.testADroppedStreamReadsReconnectingUntilTheNextConnectionfailed after 36.6 s andAidenBotSessionTests.testARefusedHandoffNoteWaitsUnderItsOwnMachinefailed after 21.7 s. Both are timeouts on parallel simulator clones.The failed jobs were rerun once, per AGENTS.md.