Skip to content

aiden serve: host the loopback /mcp endpoint, managed with aiden apps - #802

Merged
sambitcreate merged 17 commits into
mainfrom
claude/aiden-mcp-serve
Nov 18, 2026
Merged

sambitcreate merged 17 commits into
mainfrom
claude/aiden-mcp-serve

Conversation

@sambitcreate

@sambitcreate sambitcreate commented Nov 11, 2026 •

Copy link
Copy Markdown
Owner

Stacked on #800 (W4a, the MCP server core). Base: claude/aiden-mcp-server-core.

What this does

aiden serve now hosts the same loopback /mcp endpoint as the desktop. Outside apps such as Claude Code, Codex or any MCP client on the same computer can list the server's workspaces and chats and read them. With Supervised access they can also start and follow turns. The new admin command aiden apps manages it.

aiden apps connect "Claude Code" [--access read|supervised]   # shows the token once
aiden apps list                                                # server status + connected apps
aiden apps revoke <app-id>
aiden apps on | off

It reuses W4a's AidenMcpHost, AidenMcpToolRunner and provenance log, imported from main/services. Nothing is vendored. @modelcontextprotocol/sdk is pinned at 1.32.1, the desktop's pin.

Design calls

  • Port. Loopback ports 49500–49507. This is 100 above the desktop's 49400, mirroring Remote's 49220 → 49320, so a desktop and a server on one computer never collide.
    • The first port that binds is saved in remote.json.
    • A busy saved port reports port_in_use and the server does not move to another port, as on the desktop.
  • Off by default. The listener opens only after the first aiden apps connect or an explicit aiden apps on, and the choice is saved.
    • connect checks its arguments first.
    • It then turns the server on, and only then issues the token, so a failure to start never loses a token that was just shown.
    • Default access is Read.
  • Connect output.
    • On a terminal it prints the token once, with claude mcp add --scope user --transport http aiden <url> --header 'Authorization: Bearer ${AIDEN_MCP_TOKEN}' and codex mcp add aiden --url <url> --bearer-token-env-var AIDEN_MCP_TOKEN. Neither stores the token in the app's config, and both match the desktop Settings snippets.
    • Piped, it prints JSON and warns on stderr that the output holds the token, the same way pairing does.
  • Admin over the daemon socket. aiden apps reaches the running server through the existing private control socket, like aiden remote.
    • The admin client loads only a light display module (apps-display.ts, type-only imports), never the MCP SDK.
    • The CLI stays serve-only; there is no TUI.
  • Lives inside the Remote runtime. App records and the chat services are already there.
    • It shares the chat runtime through one memoized loader. MCP gets its own cached workspace service, so it never rebuilds Remote's host feed.
    • There is one shared revoke path for remote revoke and apps revoke. A phone's or Mac's id is refused by apps revoke.
    • aiden serve --no-remote has no MCP server, and aiden apps says to restart without the flag.
  • Analytics. Admin commands send nothing. The server's chat service now passes deviceReportsAnalytics, false for agent devices, so app chats and turns send no chat_created / chat_message_sent, matching the desktop.
  • Network posture. The listener is loopback-only and is never joined to Remote's LAN or Tailscale listener. It makes no outbound requests.
  • Docker. Container loopback is unreachable from the host. This is documented, with the advice to run aiden serve on the host for outside apps.

Tests

New file: packages/cli/tests/mcp-apps.test.mjs. It is added to the CLI test script, which the CI registry runs through test:cli. It has 4 tests and no source-grep:

  1. Spawned aiden serve, end to end over real MCP HTTP.
    • The server is off by default.
    • connect's piped JSON comes with a stderr warning.
    • A missing or wrong token gets 401.
    • A Read app's tools/list lacks the write tools; a bad --access value exits non-zero.
    • A real chat through a fake OpenAI-compatible provider is started, waited on until done and read back.
    • The provenance file records the app.
    • After revoke that token gets 401 while the other app keeps working.
    • off refuses connections and on returns the same URL, which also survives a server restart.
  2. In-process createCliRemote. Bad names, access values, flags and ids are refused without enabling anything. A paired phone's id is refused by apps revoke, and the phone stays paired.
  3. --no-remote. aiden apps fails with the restart hint.
  4. Connect output. The Claude and Codex commands never contain the token. A server that could not start shows the token once and aiden apps on, with no commands.

Run locally:

Check Result
npm --prefix packages/cli test 314 tests: 311 pass, 3 skipped, 0 fail
mcp-apps.test.mjs alone 4/4
npm run cli:build ok
CLI tsc --noEmit clean
root tsc --noEmit clean
eslint on changed files clean
npm run test:ci-policy 80/80
main/services/aiden-mcp-server.test.ts 15/15
npm run test:aiden-remote 1206/1206 and peer hosts 176/176

The only local failures are 4 in scripts/aiden-remote-lan-transport-spike.test.mjs, a known host openssl issue that does not reproduce in CI.

Docs

  • packages/cli/README.md: a new "Outside apps (MCP server)" section, plus command reference, state files and privacy rows.
  • docs/aiden-mcp-server.md: the status line no longer says the headless server is still to come, and a new "Headless server" section is added.
  • docs/security/aiden-remote-threat-model.md §10: a headless note.
  • .memory/aiden-mcp-server.md: the W4c design notes.

No W4a bugs were found.

CI flakes

🤖 Generated with Claude Code

sambitcreate and others added 3 commits November 11, 2026 15:48
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The headless server now runs the same AidenMcpHost and tool runner as the
desktop, inside its Remote runtime, on loopback ports 49500-49507 so it never
takes a desktop's port. It stays off until the first `aiden apps connect` or
`aiden apps on`.

`aiden apps list|connect|revoke|on|off` reach the running server over its
control socket. Connect shows the token once, with Claude Code and Codex
commands that read it from AIDEN_MCP_TOKEN. Revoke shares the Remote
revocation path and refuses a phone's id. Admin commands send no analytics,
and app chats and turns send no usage events, as on the desktop.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ Two narrow correctness gaps worth fixing inline.

Reviewed changes across all 15 files, covering the headless MCP host wiring, daemon administration, shared Remote runtime integration, dependency/bundle impact, documentation, and behavioral tests.

  • MCP host lifecycle — Adds the loopback host to aiden serve, with persisted enablement/port state, shared chat services, and ordered startup/shutdown.
  • App administration — Adds aiden apps list|connect|revoke|on|off over the private daemon socket, one-time credentials, Read/Supervised access, and shared revocation cleanup.
  • Privacy and distribution — Suppresses app-originated chat analytics, keeps the admin client light, pins the MCP SDK, and documents the headless security/network posture.
  • Behavioral coverage — Exercises the real daemon and Streamable HTTP endpoint, authentication, tool access, chat generation, provenance, revocation, restart persistence, invalid input, and --no-remote behavior.

Pullfrog  | ⚠️ this action is pinned to a commit SHA, which freezes the cleanup step — switch to @v0 or keep the SHA fresh with Dependabot | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using GPT Sol | 𝕏

Comment thread packages/cli/src/apps.ts Resolved
Comment thread packages/cli/README.md Resolved
sambitcreate and others added 3 commits November 11, 2026 16:11
The MCP host revokes with the desktop's when-available mode: the token is
tombstoned first, so a BotCapabilityUnavailableError while clearing Bot
notices is reported on stderr instead of failing the revoke. aiden remote
revoke keeps requiring the notice cleanup.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found in the incremental changes.

Reviewed changes since the prior Pullfrog review, covering the repair-tolerant app revocation path and its regression coverage.

  • Hardened app revocation — Allowed an already-tombstoned outside app to remain disconnected when Bot notice storage requires repair, while preserving strict failures for paired devices and unrelated errors.
  • Added behavioral coverage — Exercised revocation against damaged Bot capability state and verified both token rejection and the persisted revoked projection.
  • Synchronized the stacked base — Merged the latest MCP server core changes without adding another net behavioral delta to this PR.

Pullfrog  | ⚠️ this action is pinned to a commit SHA, which freezes the cleanup step — switch to @v0 or keep the SHA fresh with Dependabot | Fix it ➔ | View workflow run | Using GPT Sol | 𝕏

sambitcreate and others added 3 commits November 11, 2026 16:33
… fallback

An app name's 80-character limit counted UTF-16 units, so 41 emoji were
refused. It now counts code points, like the other names Aiden keeps.

The docs said the server only ever uses 49500 and the next seven ports;
on first start with all eight busy, the shared host lets the system pick
a free loopback port and saves it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ No new issues in the incremental changes. The earlier port-documentation finding remains partially addressed because the threat model still presents 49500–49507 as exhaustive.

Reviewed changes since the prior Pullfrog review, covering the Unicode app-name fix, its behavioral coverage, and the corrected first-run port documentation.

  • Aligned app-name validation — Counted Unicode code points for the 80-character limit, matching the shared Remote state registry.

  • Added boundary coverage — Verified that 80 emoji are accepted unchanged and 81 emoji are rejected.

  • Corrected port guidance — Documented the arbitrary free loopback-port fallback in the MCP guide and CLI README when all eight preferred ports are busy on first start.

Pullfrog  | ⚠️ this action is pinned to a commit SHA, which freezes the cleanup step — switch to @v0 or keep the SHA fresh with Dependabot | Fix it ➔ | View workflow run | Using GPT Sol | 𝕏

sambitcreate and others added 2 commits November 11, 2026 17:01
The CLI's setup commands now use core's aidenMcpTokenEnvName, the same
per-app AIDEN_MCP_TOKEN_<NAME>_<ID> the desktop Settings sheet prints, so
connecting a second app in one shell profile no longer replaces the first
app's token. A real-shell test checks each app's commands send its own token.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes since the prior Pullfrog review, covering the shared revocation-policy integration and per-app MCP token variables.

  • Shared revocation policy — Replaced the CLI’s local repair handling with the tested Bot-notice revoke helper while preserving strict paired-device cleanup.
  • Isolated app credentials — Generated each app’s setup commands from the shared aidenMcpTokenEnvName helper so multiple shell-profile tokens do not overwrite one another.
  • Added behavioral coverage — Exercised the generated Claude Code and Codex commands in a real shell and verified each sends its own token.
  • Synchronized the stacked base — Merged the latest MCP server core changes needed by both shared helpers.

Pullfrog  | ⚠️ this action is pinned to a commit SHA, which freezes the cleanup step — switch to @v0 or keep the SHA fresh with Dependabot | View workflow run | Using GPT Sol | 𝕏

…tens

Match #818: server text about the computer it runs on names it with
localComputerNoun, so macOS says 'this Mac only' and Linux 'this
computer only'.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes since the prior Pullfrog review, covering the platform-specific MCP listener copy and stacked-base synchronization.

  • Adapted local-host wording — Used the shared localComputerNoun helper so MCP setup and daemon output say “this Mac only” on macOS and “this computer only” elsewhere.
  • Synchronized the stacked base — Merged the latest MCP server core without adding another net behavioral change to this PR.

Pullfrog  | ⚠️ this action is pinned to a commit SHA, which freezes the cleanup step — switch to @v0 or keep the SHA fresh with Dependabot | View workflow run | Using GPT Sol | 𝕏

Base automatically changed from claude/aiden-mcp-server-core to main November 17, 2026 17:14

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes since the prior Pullfrog review, covering the three main merges and their conflict resolutions.

  • Synchronized CLI dependencies — Updated the standalone CLI to the shared Pi 1.5.2 line while preserving the MCP SDK dependency and MCP app test registration.
  • Preserved merged documentation — Kept the outside-apps MCP guidance alongside the new workspace-tool, generation-limit, and OAuth-refresh documentation from main.
  • Validated the merged runtime — Confirmed the CLI bundle builds, type-checks, and passes all 6 focused MCP app integration tests.

Pullfrog  | ⚠️ this action is pinned to a commit SHA, which freezes the cleanup step — switch to @v0 or keep the SHA fresh with Dependabot | View workflow run | Using GPT Sol | 𝕏

# Conflicts:
#	packages/cli/package.json
@sambitcreate
sambitcreate merged commit c26f29e into main Nov 18, 2026
28 checks passed
@sambitcreate
sambitcreate deleted the claude/aiden-mcp-serve branch November 18, 2026 06:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant