Principle:1mcp app Agent Async MCP Loading
| Knowledge Sources | |
|---|---|
| Domains | Concurrency, Reliability |
| Last Updated | 2026-10-29 00:00 GMT |
Overview
Pattern that coordinates parallel MCP server initialization with concurrency limits, retry with exponential backoff, OAuth-aware error handling, and background retry for failed servers.
Description
Async MCP Loading manages the non-blocking initialization of multiple MCP backends. It uses a parallel executor with a configurable concurrency limit to avoid overwhelming the system, tracks per-server loading state (pending, loading, ready, failed, awaiting-oauth, cancelled), and retries failed connections with exponential backoff. After the initial loading wave completes, a background retry timer periodically attempts to reconnect servers that remain in a failed state. The loading manager emits events at each state transition, enabling the async loading orchestrator to publish capability snapshots and notify clients.
Usage
Use this principle when:
- Multiple MCP backends must connect in parallel without blocking the HTTP server
- Failed backends should be retried with backoff rather than abandoned
- OAuth-required errors must be handled distinctly from connection failures
- Background retry should periodically attempt recovery of persistently failed servers
- Loading operations must be cancellable for hot-reload (add/remove) without race conditions
Theoretical Basis
The loading wave uses bounded parallel execution:
Retry follows exponential backoff:
Background retry is an idempotent interval:
// Abstract algorithm (NOT real implementation)
setInterval(() => {
failed = stateTracker.getByState('failed')
.filter(s => !(s.error instanceof NonRetryableError));
retry(failed.slice(0, maxPerCycle));
}, backgroundRetryIntervalMs);
Practical Guide
- Track loading state per server with a state tracker that emits progress events
- Use per-server abort controllers to cancel loading operations during hot-reload
- Distinguish OAuth-required errors from retryable connection errors
- Cap background retry attempts per cycle to avoid overwhelming slow backends
- Reset the retry attempt counter after a stable period to allow transient failures to recover
Related Pages
Implemented By
- Implementation:1mcp_app_Agent_McpLoadingManager
- Implementation:1mcp_app_Agent_AsyncLoadingOrchestrator