Implementation:1mcp app Agent AsyncLoadingOrchestrator
| Knowledge Sources | |
|---|---|
| Domains | Concurrency, MCP_Protocol |
| Last Updated | 2026-10-29 00:00 GMT |
Overview
Concrete event-driven orchestrator that coordinates capability aggregation and client notifications after MCP server loading completes, wiring LoadingManager events to CapabilityAggregator and NotificationManager.
Description
The AsyncLoadingOrchestrator class bridges the loading manager's state transitions to the capability aggregation and notification pipeline. When the loading manager emits `LoadingComplete`, the orchestrator triggers a capability snapshot update via the CapabilityAggregator. If capabilities changed, it publishes the snapshot and sends `listChanged` notifications to connected clients. The orchestrator also initializes the internal capabilities provider and supports per-connection notification manager setup. It respects the `asyncLoading.enabled` feature flag and a `cooperative-activation` startup policy.
Usage
Import this class when you need to:
- Wire loading completion to capability aggregation at server startup
- Send `listChanged` notifications to clients when backends become ready
- Force-refresh capabilities after a backend availability change
- Initialize per-connection notification managers when inbound connections arrive
Code Reference
Source Location
- Repository: 1MCP Agent
- File: src/core/capabilities/asyncLoadingOrchestrator.ts (L37-360)
Signature
export type BackendStartupPolicy = 'configured' | 'cooperative-activation';
export class AsyncLoadingOrchestrator extends EventEmitter {
constructor(
outboundConnections: OutboundConnections,
serverManager: ServerManager,
loadingManager: McpLoadingManager,
);
public async initialize(startupPolicy?: BackendStartupPolicy): Promise<void>;
public initializeNotifications(inboundConnection: InboundConnection): void;
public async refreshCapabilities(): Promise<CapabilityRefreshResult>;
public getCapabilityAggregator(): CapabilityAggregator;
public getNotificationManager(): NotificationManager | null;
public isReady(): boolean;
public getStatusSummary(): string;
public updateConfig(): void;
public shutdown(): void;
}
Import
import { AsyncLoadingOrchestrator, BackendStartupPolicy } from '@src/core/capabilities/asyncLoadingOrchestrator.js';
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| outboundConnections | OutboundConnections | Yes | Connected MCP backends |
| serverManager | ServerManager | Yes | Server manager facade |
| loadingManager | McpLoadingManager | Yes | Loading manager to observe |
| startupPolicy | BackendStartupPolicy | No | 'configured' or 'cooperative-activation' |
Outputs
| Name | Type | Description |
|---|---|---|
| refreshCapabilities | CapabilityRefreshResult | { changed, shouldNotifyListChanged } |
| AsyncLoadingOrchestratorEvent | enum | OrchestratorReady, CapabilitySnapshotPublished, NotificationsSent |
Usage Examples
Wiring at Startup
import { AsyncLoadingOrchestrator } from '@src/core/capabilities/asyncLoadingOrchestrator.js';
const asyncOrchestrator = new AsyncLoadingOrchestrator(clients, serverManager, loadingManager);
await asyncOrchestrator.initialize('configured');
// Later, when an inbound connection arrives:
asyncOrchestrator.initializeNotifications(inboundConnection);
Manual Capability Refresh
const result = await asyncOrchestrator.refreshCapabilities();
if (result.changed) {
console.log('Capabilities updated, listChanged sent to clients');
}