mcp-integration-planelisted
Install: claude install-skill Beidou1507/code-claw
# MCP Integration Plane
## Overview
Treat MCP as an external capability bus, not as a thin RPC wrapper. It has to manage connection types, auth, discovery, timeouts, progress, oversized output, session expiry, and user elicitation without destabilizing the main agent loop.
## Source Anchors
- `src/services/mcp/client.ts`
- `src/services/mcp/config.ts`
- `src/services/mcp/elicitationHandler.ts`
## Workflow
1. Normalize server configuration first and distinguish stdio, SSE, HTTP, WebSocket, IDE, and proxy-style transports.
2. Build the correct auth provider, headers, proxy behavior, and timeout strategy for each transport type.
3. Convert remote auth failures into explicit `needs-auth` state instead of generic connection errors.
4. Memoize connections and cache tool, resource, and command discovery with bounded LRU behavior.
5. Sanitize Unicode, trim oversized descriptions, and preserve tool annotations such as read-only and destructive hints during discovery.
6. Run MCP tool calls with progress reporting, hard timeouts, preserved `_meta`, and large-result persistence.
7. Let hooks or users resolve URL elicitations and retry the tool call only after the elicitation has completed.
8. Handle 401, 404, and session-expired paths with targeted recovery such as cache clearing, reconnection, or token refresh.
9. In cleanup, close transports, stop process monitoring, and unregister all cleanup handlers.
## Design Rules
- Create a fresh timeout for each request instead of reusin