| 125 | let total = 0 |
| 126 | |
| 127 | const add = (info: { |
| 128 | transport: McpServerDescriptor['transport'] |
| 129 | prefix: string | undefined |
| 130 | }) => { |
| 131 | const descriptor: McpServerDescriptor = { |
| 132 | transport: info.transport, |
| 133 | prefix: info.prefix, |
| 134 | } |
| 135 | total += 1 |
| 136 | const key = info.prefix |
| 137 | if (key === undefined || key === '') { |
| 138 | if (fallback !== null) { |
| 139 | throw new Error( |
| 140 | 'createMcpAppCallHandler: multiple clients without a prefix; serverId routing is ambiguous', |
| 141 | ) |
| 142 | } |
| 143 | fallback = descriptor |
| 144 | return |
| 145 | } |
| 146 | if (key in byServerId) { |
| 147 | throw new Error(`createMcpAppCallHandler: duplicate serverId "${key}"`) |
| 148 | } |
| 149 | byServerId[key] = descriptor |
| 150 | } |
| 151 | |
| 152 | for (const entry of entries) { |
| 153 | if (isPool(entry)) { |