([name, config]: [
string,
ScopedMcpServerConfig,
])
| 2292 | } |
| 2293 | |
| 2294 | const processServer = async ([name, config]: [ |
| 2295 | string, |
| 2296 | ScopedMcpServerConfig, |
| 2297 | ]): Promise<void> => { |
| 2298 | try { |
| 2299 | // Check if server is disabled - if so, just add it to state without connecting |
| 2300 | if (isMcpServerDisabled(name)) { |
| 2301 | onConnectionAttempt({ |
| 2302 | client: { |
| 2303 | name, |
| 2304 | type: 'disabled', |
| 2305 | config, |
| 2306 | }, |
| 2307 | tools: [], |
| 2308 | commands: [], |
| 2309 | }) |
| 2310 | return |
| 2311 | } |
| 2312 | |
| 2313 | // Skip connection for servers that recently returned 401 (15min TTL), |
| 2314 | // or that we have probed before but hold no token for. The second |
| 2315 | // check closes the gap the TTL leaves open: without it, every 15min |
| 2316 | // we re-probe servers that cannot succeed until the user runs /mcp. |
| 2317 | // Each probe is a network round-trip for connect-401 plus OAuth |
| 2318 | // discovery, and print mode awaits the whole batch (main.tsx:3503). |
| 2319 | if ( |
| 2320 | (config.type === 'claudeai-proxy' || |
| 2321 | config.type === 'http' || |
| 2322 | config.type === 'sse') && |
| 2323 | ((await isMcpAuthCached(name)) || |
| 2324 | ((config.type === 'http' || config.type === 'sse') && |
| 2325 | hasMcpDiscoveryButNoToken(name, config))) |
| 2326 | ) { |
| 2327 | logMCPDebug(name, `Skipping connection (cached needs-auth)`) |
| 2328 | onConnectionAttempt({ |
| 2329 | client: { name, type: 'needs-auth' as const, config }, |
| 2330 | tools: [createMcpAuthTool(name, config)], |
| 2331 | commands: [], |
| 2332 | }) |
| 2333 | return |
| 2334 | } |
| 2335 | |
| 2336 | const client = await connectToServer(name, config, serverStats) |
| 2337 | |
| 2338 | if (client.type !== 'connected') { |
| 2339 | onConnectionAttempt({ |
| 2340 | client, |
| 2341 | tools: |
| 2342 | client.type === 'needs-auth' |
| 2343 | ? [createMcpAuthTool(name, config)] |
| 2344 | : [], |
| 2345 | commands: [], |
| 2346 | }) |
| 2347 | return |
| 2348 | } |
| 2349 | |
| 2350 | if (config.type === 'claudeai-proxy') { |
| 2351 | markClaudeAiMcpConnected(name) |
nothing calls this directly
no test coverage detected