(configs: Record<string, ScopedMcpServerConfig>, label: string)
| 2689 | // pending-check at ToolSearchTool.ts:334 sees them), then replace with |
| 2690 | // connected/failed as each server settles. |
| 2691 | const connectMcpBatch = (configs: Record<string, ScopedMcpServerConfig>, label: string): Promise<void> => { |
| 2692 | if (Object.keys(configs).length === 0) return Promise.resolve(); |
| 2693 | headlessStore.setState(prev => ({ |
| 2694 | ...prev, |
| 2695 | mcp: { |
| 2696 | ...prev.mcp, |
| 2697 | clients: [...prev.mcp.clients, ...Object.entries(configs).map(([name, config]) => ({ |
| 2698 | name, |
| 2699 | type: 'pending' as const, |
| 2700 | config |
| 2701 | }))] |
| 2702 | } |
| 2703 | })); |
| 2704 | return getMcpToolsCommandsAndResources(({ |
| 2705 | client, |
| 2706 | tools, |
| 2707 | commands |
| 2708 | }) => { |
| 2709 | headlessStore.setState(prev => ({ |
| 2710 | ...prev, |
| 2711 | mcp: { |
| 2712 | ...prev.mcp, |
| 2713 | clients: prev.mcp.clients.some(c => c.name === client.name) ? prev.mcp.clients.map(c => c.name === client.name ? client : c) : [...prev.mcp.clients, client], |
| 2714 | tools: uniqBy([...prev.mcp.tools, ...tools], 'name'), |
| 2715 | commands: uniqBy([...prev.mcp.commands, ...commands], 'name') |
| 2716 | } |
| 2717 | })); |
| 2718 | }, configs).catch(err => logForDebugging(`[MCP] ${label} connect error: ${err}`)); |
| 2719 | }; |
| 2720 | // Await all MCP configs — print mode is often single-turn, so |
| 2721 | // "late-connecting servers visible next turn" doesn't help. SDK init |
| 2722 | // message and turn-1 tool list both need configured MCP tools present. |
no test coverage detected