Skip to content

Commit 934f6e5

Browse files
docs(mcpServer): document _outbound singleton multi-connect limitation
connect() overwrites _outbound on each call. Inbound dispatch works for all concurrent connections (each has its own onrequest/StreamDriver), but instance-level outbound (createMessage, send*ListChanged) reaches only the most-recently-connected transport. Matches v1 Protocol.connect semantics. Per the simplification review, documenting rather than redesigning.
1 parent 6c439da commit 934f6e5

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

packages/server/src/server/mcpServer.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,12 @@ export class McpServer extends Dispatcher<ServerContext> implements RegistriesHo
275275
* optional `notify`/`request` methods.
276276
* - For {@linkcode ChannelTransport} (stdio/WebSocket/InMemory): wraps it in a
277277
* {@linkcode StreamDriver} via {@linkcode attachChannelTransport}.
278+
*
279+
* **Known limitation:** `_outbound` is a singleton — each `connect()` call overwrites
280+
* it. Multiple concurrent connections (the v1 stateful-SHTTP `Map<sessionId, transport>`
281+
* pattern) work for *inbound* dispatch, but instance-level *outbound* methods
282+
* ({@linkcode createMessage}, {@linkcode sendToolListChanged}, etc.) reach only the
283+
* most-recently-connected transport. This matches v1 `Protocol.connect()` semantics.
278284
*/
279285
async connect(transport: ChannelTransport | RequestTransport): Promise<void> {
280286
let outbound: Outbound | undefined;

0 commit comments

Comments
 (0)