Skip to content

feat(mcp): add built-in MCP host - #162

Merged
Juliusolsson05 merged 1 commit into
mainfrom
feat/built-in-mcp-foundation
May 16, 2026
Merged

Juliusolsson05 merged 1 commit into
mainfrom
feat/built-in-mcp-foundation

Conversation

@Juliusolsson05

@Juliusolsson05 Juliusolsson05 commented May 16, 2026 •

Copy link
Copy Markdown
Owner

Summary

Closes #155.

Adds Agent Code's built-in MCP host: a loopback Streamable HTTP MCP server owned by the main process, plus session launch wiring so Claude/Codex agents can be started with scoped Agent Code MCP access.

This PR only adds the foundation and the ping domain. It does not add orchestration tools; those live in the stacked orchestration PR.

Behavior

  • Main starts one local MCP HTTP host on 127.0.0.1.
  • Each session that asks for built-in MCP domains gets a per-session bearer token and MCP server config.
  • Providers receive concrete launch config only:
    • Claude gets --mcp-config JSON.
    • Codex gets --config mcp_servers.* flags.
  • Closing/stopping a session revokes its token.
  • The first built-in domain is ping, exposing agent_code_ping so a launched agent can confirm its scoped session id, cwd, and domains.

Design

The host lives in Electron main instead of a separate stdio helper process. That avoids packaged-app problems where Agent Code would need to locate a separate Node binary just to run its own MCP server, and it gives future built-in domains direct access to app services through typed dependencies rather than rediscovery.

The session metadata remains the policy source (builtInMcpDomains). Providers only receive the minted URL/header config for the current process, so a provider runtime does not need to know about long-lived domain policy.

Files

  • src/mcp/shared/types.ts — built-in domain/config types and domain normalization.
  • src/mcp/runtime/BuiltInMcpHttpHost.ts — loopback HTTP host, token registry, request authentication, per-request McpServer lifecycle.
  • src/mcp/runtime/createBuiltInMcpServer.ts — builds the scoped MCP server and registers agent_code_ping.
  • src/main/sessionManager.ts — registers/revokes built-in MCP configs during session spawn/stop.
  • src/providers/claude/runtime/claudeSession.ts and src/providers/codex/runtime/codexSession.ts — inject provider-specific MCP launch flags.
  • src/renderer/src/workspace/types.ts, src/shared/types/session.ts, preload/session API wiring — carries builtInMcpDomains / builtInMcpServers through the existing spawn path.

Verification

  • agent_code_ping was live-exercised from an MCP-enabled agent during development and returned the expected scoped session/cwd/domain payload.
  • tsc -b was attempted on the branch. The MCP files typecheck, but the repo still reports unrelated pre-existing errors from submodule type resolution and BlockRow.tsx/mergedEntries.ts issues already present outside this PR.
  • No test files added, per repo policy.

Test Plan

  • Spawn a Claude session with builtInMcpDomains: ['ping']; confirm agent_code_ping is available and returns the current session id/cwd.
  • Spawn a Codex session with builtInMcpDomains: ['ping']; confirm the same.
  • Close the session and confirm the old MCP URL/token returns 401.
  • Spawn a normal session with no built-in domains; confirm no Agent Code MCP config is injected.

Follow-Up

The stacked orchestration PR builds on this foundation by adding an orchestration domain and the tools that create/list/prompt child agents. The AI Workspace work in #157 should also build on this host, but this PR leaves #157 for a separate implementation.

Merge MCP bootstrap and session injection foundation from PR #158.
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.

Build built-in MCP groundwork and on-demand server injection bridge

1 participant