feat: add MCP server support for Electric Agents#4165
Conversation
Design for @electric-ax/agents-mcp package — MCP client integration for Electric Agents entities. Covers stdio + Streamable HTTP transports, OAuth 2.1 auth flow, connection pooling, tool/resource bridging, and Horton-based config management. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Design for running coding agents (Claude Code, Codex) inside isolated sandbox environments with full session streaming via durable streams and agent-session-protocol parsing. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Adds env var expansion, arbitrary headers, startup/tool timeouts, output size limits, mcp__ tool namespacing, SDK OAuthClientProvider integration, server instructions, exponential backoff reconnection, graceful stdio shutdown, and enabled toggle. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
15-task plan covering package scaffolding, types, config/token stores, env var expansion, OAuth provider, MCP client/pool, tool/resource bridges, config management tools, integration factory, and Horton wiring. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Introduces McpServerConfig, McpConfig, McpOverrides, McpIntegration, McpServerState, McpDiscoveredTool, McpDiscoveredResource, McpServerStatus, and MCP_DEFAULTS constants. Re-exports all from src/index.ts. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds expandEnvVars (supports \${VAR} and \${VAR:-default} syntax) and
expandConfigValues (recursively expands strings in any config object),
with full test coverage via vitest.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…s/mcp.json Supports loading with optional env-var expansion, saving with auto-created .gitignore, and addServer/removeServer helpers. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…fiers Stores access/refresh tokens, PKCE code verifiers, and client info in .electric-agents/mcp-auth.json (which is gitignored by ConfigStore). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Implements the MCP SDK's OAuthClientProvider interface with persistent credential storage via TokenStore. Handles the authorization code flow by spinning up a temporary local HTTP server for the OAuth redirect callback, with a 5-minute timeout. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Wraps the MCP SDK Client with transport creation (StdioClientTransport for command-based servers, StreamableHTTPClientTransport for URL-based servers), auth wiring (OAuth, Bearer token, custom headers), automatic tool/resource discovery, and listChanged notification handling. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
… interface Bridges MCP discovered tools into the AgentTool interface with mcp__ prefix namespacing, output formatting, and truncation support. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ources Creates AgentTool wrappers for mcp__list_resources and mcp__read_resource that interact with connected MCP servers. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Manages McpClient instances with lazy connect, idle timeout, and acquire/release semantics. Bridges tools and resources via the bridge modules and supports dynamic server add/remove and per-call overrides. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…server management Implements mcp__manage__add_server, mcp__manage__remove_server, mcp__manage__list_servers, and mcp__manage__list_tools as AgentTools, with full test coverage. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Provides a unified entry point that wires ConfigStore, McpClientPool, and config tools together, exposing getTools, getServerInstructions, getServerSummary, and close via the McpIntegration interface. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds exports for createMcpIntegration, McpClient, TokenStore, bridgeMcpTools, createResourceTools, createConfigTools, and env-expand utilities so consumers have a single import surface. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add @electric-ax/agents-mcp workspace dependency - Create MCP integration in bootstrap, pass to Horton - Inject MCP config tools + bridged tools into Horton's tool set - Add MCP server summary section to system prompt - MCP is fully optional — existing code works without it Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…mocked McpClient Covers tool bridging, config management tools, server summary generation, and override-based server exclusion in an end-to-end flow. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…d server name through onAuthUrl - Write auth token file with mode 0o600 instead of default 0644 - Remove unused zod dependency from package.json - Change onAuthUrl signature to (serverName, url) throughout pool and integration Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Code Review Follow-up ItemsThe following issues were identified during the final code review. Items 1-3 are deferred to a follow-up PR; items 4-7 are minor and can be addressed as needed. Should address (follow-up PR)1. Exponential backoff reconnection
2. stdio process crash detection
3. Truncation uses per-block limit instead of running budget
Minor / acceptable for v14. 5. No config validation on load 6. OAuth redirect port mismatch when 7. |
Summary
@electric-ax/agents-mcppackage that bridges the official MCP TypeScript SDK into the existingAgentToolinterfacemcp__server__tool) following Claude Code conventionsmcp__list_resources,mcp__read_resource)mcp__manage__add_server, etc.).electric-agents/mcp.jsonwith${VAR}env var expansion.electric-agents/mcp-auth.json(gitignored, mode 0600)Architecture
New package
@electric-ax/agents-mcpplugs intoagents-runtimevia the existingAgentToolinterface. The runtime stays MCP-agnostic; MCP is opt-in. Theagentspackage wires MCP into Horton at bootstrap time.Design docs
docs/superpowers/specs/2026-04-24-mcp-server-support-design.mddocs/superpowers/plans/2026-04-24-mcp-server-support.mdTest plan
@modelcontextprotocol/server-github)🤖 Generated with Claude Code