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