Critical Flow: MCP Server Connection, Tool Call, And Result Handling
MCP is one of the most dynamic parts of the client. A junior engineer should understand both how server configs are assembled and how an MCP tool call becomes a model-visible result.
Flow Overview
- Gather config from all MCP sources.
- Filter and deduplicate config.
- Connect transports and discover tools, resources, and prompts.
- Expose MCP tools, commands, and resources to the model and UI.
- Execute MCP tool calls, including auth, elicitation, and large-result handling.
Every Hop
1. Config assembly
services/mcp/config.ts merges MCP config from:
--mcp-configCLI input.