Skip to content

Loopback MCP tool bridge for installed ACP agents - #385

Merged
d41sys merged 1 commit into
mainfrom
issue-378-mcp-bridge
Dec 4, 2026
Merged

d41sys merged 1 commit into
mainfrom
issue-378-mcp-bridge

Conversation

@d41sys

@d41sys d41sys commented Dec 4, 2026

Copy link
Copy Markdown
Owner

Summary

Closes #378.

Exposes Bate's per-bot capabilities (memory notes, isolated Chrome browser with model-blind Secrets, Apple apps, desktop helper, project Surfaces, and bot-to-bot mail) to installed ACP agents over a per-bot loopback-only MCP endpoint so bots running on installed agents are first-class citizens in Bate:

  • Per-bot loopback MCP server (appd/src/mcp_bridge.rs):
    • Binds strictly to 127.0.0.1:<ephemeral-port> with a fresh random 32-byte per-session bearer token verified in constant time (fixed-length SHA-256 digest XOR comparison), never logged and never persisted.
    • Speaks MCP JSON-RPC 2.0 over HTTP (initialize, notifications/initialized, ping, tools/list, tools/call) on background threads off Core::run.
    • Shuts down immediately and releases the port when dropped (engine stop or bot deletion).
  • Automatic ACP wiring & Seatbelt support (appd/src/core.rs, appd/src/limit.rs):
    • Starts a BridgeHandle automatically whenever start_engine launches an installed ACP agent (agent.is_some()), adds its ephemeral port to the bot's Seatbelt BRIDGE allow rule if network-limited, and injects the synthetic bate HTTP MCP server into Op::Connectors without mutating any global agent configuration files.
  • Full Core enforcement (appd/src/core.rs):
    • Every tools/call runs through Core's pause check, token_stop limit check, decide_alone permission check, Needs you approval cards (Approve, Deny, Always, Conversation, still always asking for Apple app sends/changes), and tool_start/tool_end transcript audit trail.
    • Inline channel approval callbacks can also answer mcpBridge cards with Allow once / Deny.

Evidence

  • cd window/ui && npm ci && npm run build && npm test: 142/142 passed.
  • cargo fmt --all --check: clean.
  • cargo clippy --workspace --all-targets --locked -- -D warnings: clean.
  • cargo test --workspace --locked: all crates passed, including:
    • appd unit test: mcp_bridge::tests::enforces_bearer_token_serves_mcp_and_shuts_down_on_drop.
    • appd --test service: loopback_mcp_bridge_authenticates_enforces_approvals_and_shuts_down verifying automatic ACP connector injection, token secrecy (never in logs or list_connectors), 401 on missing/wrong tokens, Needs you approval card + Approve/Deny enforcement, never permission refusal, pause refusal, transcript audit trail, and port shutdown on delete_bot.

Merge Danger

Low. The loopback bridge only starts for bots configured with an installed ACP agent, binds exclusively to 127.0.0.1, requires a per-session bearer token, and routes all actions through Bate's existing permission and audit code paths.

Device decision

  • No new window commands were added; existing answer over LAN continues to follow its documented rules (Approve, Deny, Always, Conversation, respecting always_asks).
  • The loopback MCP endpoint binds strictly to 127.0.0.1 and is never exposed over LAN or Tailscale. Documented in PROTOCOL.md.

@d41sys
d41sys merged commit 2306c9e into main Dec 4, 2026
5 checks passed
@d41sys
d41sys deleted the issue-378-mcp-bridge branch December 4, 2026 19:14
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.

Loopback MCP tool bridge so installed agents can use Bate's tools, Apple apps, browser, memory, and approvals

1 participant