361
d = autorun(reader => {
362
if (ranOnce) {
364
>
}
365
366
const connection = server.connection.read(reader);
367
if (!connection) {
368
>
// No live connection: the server may be blocked by policy (its connection is torn
mcpServer.ts
369
>
// down while blocked) or stopped. Surface the terminal state instead of waiting forever.
370
>
const state = server.connectionState.read(reader);
371
>
if (state.state === McpConnectionState.Kind.Error) {
372
>
reject(new McpConnectionFailedError(`MCP server could not be started: ${state.message}`));
373
>
} else if (state.state === McpConnectionState.Kind.Stopped) {
374
>
reject(new McpConnectionFailedError('MCP server has stopped'));
375
>
}
376
>
return;
377
>
}
378
379
const handler = connection.handler.read(reader);