| 2346 | } |
| 2347 | |
| 2348 | const protocolForInternalTag = ( |
| 2349 | registry: McpProtocolRegistry.ProtocolRegistry<McpProtocol.ProtocolAdapter>, |
| 2350 | tag: string |
| 2351 | ): McpProtocol.ProtocolAdapter => { |
| 2352 | for (const protocol of registry.protocols) { |
| 2353 | const routed = registry.routeClientRequest(protocol, { |
| 2354 | _tag: "Request", |
| 2355 | id: 0, |
| 2356 | tag: "", |
| 2357 | payload: undefined, |
| 2358 | headers: [] |
| 2359 | }) |
| 2360 | if (tag.startsWith(routed.tag)) { |
| 2361 | return protocol |
| 2362 | } |
| 2363 | } |
| 2364 | return registry.protocols[0] |
| 2365 | } |
| 2366 | |
| 2367 | const getProtocolForClient = ( |
| 2368 | clientProtocols: Map<number, McpProtocol.ProtocolAdapter>, |