(
servers: MCPServerMap,
runtime: Runtime,
projectPath: string,
workspacePath: string,
projectSecrets: Record<string, string> | undefined,
onActivity: () => void
)
| 1479 | } |
| 1480 | |
| 1481 | private async startServers( |
| 1482 | servers: MCPServerMap, |
| 1483 | runtime: Runtime, |
| 1484 | projectPath: string, |
| 1485 | workspacePath: string, |
| 1486 | projectSecrets: Record<string, string> | undefined, |
| 1487 | onActivity: () => void |
| 1488 | ): Promise<{ |
| 1489 | instances: Map<string, MCPServerInstance>; |
| 1490 | failedServerNames: string[]; |
| 1491 | timedOutServerNames: string[]; |
| 1492 | }> { |
| 1493 | const instances = new Map<string, MCPServerInstance>(); |
| 1494 | const failedServerNames: string[] = []; |
| 1495 | const timedOutServerNames: string[] = []; |
| 1496 | const entries = Object.entries(servers); |
| 1497 | |
| 1498 | for (const [name, info] of entries) { |
| 1499 | try { |
| 1500 | const instance = await this.startSingleServer( |
| 1501 | name, |
| 1502 | info, |
| 1503 | runtime, |
| 1504 | projectPath, |
| 1505 | workspacePath, |
| 1506 | projectSecrets, |
| 1507 | onActivity |
| 1508 | ); |
| 1509 | if (instance) { |
| 1510 | instances.set(name, instance); |
| 1511 | } |
| 1512 | } catch (error) { |
| 1513 | const message = getErrorMessage(error); |
| 1514 | log.error("Failed to start MCP server", { name, error: message }); |
| 1515 | failedServerNames.push(name); |
| 1516 | if (isMCPStartupTimeoutError(error)) { |
| 1517 | timedOutServerNames.push(name); |
| 1518 | } |
| 1519 | } |
| 1520 | } |
| 1521 | |
| 1522 | return { instances, failedServerNames, timedOutServerNames }; |
| 1523 | } |
| 1524 | |
| 1525 | private async startSingleServer( |
| 1526 | name: string, |
no test coverage detected