Skip to content

Commit 3462cb2

Browse files
authored
mcp: fix concurrent samplin/elicit requests not working (microsoft#256062)
Closes microsoft#255957
1 parent b510d53 commit 3462cb2

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

src/vs/workbench/api/common/extHostMcp.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -215,19 +215,25 @@ class McpHTTPHandle extends Disposable {
215215

216216
async send(message: string) {
217217
try {
218-
await this._requestSequencer.queue(() => {
219-
if (this._mode.value === HttpMode.SSE) {
220-
return this._sendLegacySSE(this._mode.endpoint, message);
221-
} else {
222-
return this._sendStreamableHttp(message, this._mode.value === HttpMode.Http ? this._mode.sessionId : undefined);
223-
}
224-
});
218+
if (this._mode.value === HttpMode.Unknown) {
219+
await this._requestSequencer.queue(() => this._send(message));
220+
} else {
221+
await this._send(message);
222+
}
225223
} catch (err) {
226224
const msg = `Error sending message to ${this._launch.uri}: ${String(err)}`;
227225
this._proxy.$onDidChangeState(this._id, { state: McpConnectionState.Kind.Error, message: msg });
228226
}
229227
}
230228

229+
_send(message: string) {
230+
if (this._mode.value === HttpMode.SSE) {
231+
return this._sendLegacySSE(this._mode.endpoint, message);
232+
} else {
233+
return this._sendStreamableHttp(message, this._mode.value === HttpMode.Http ? this._mode.sessionId : undefined);
234+
}
235+
}
236+
231237
/**
232238
* Sends a streamable-HTTP request.
233239
* 1. Posts to the endpoint
@@ -297,8 +303,7 @@ class McpHTTPHandle extends Disposable {
297303
this._attachStreamableBackchannel();
298304
}
299305

300-
// Not awaited, we don't need to block the sequencer while we read the response
301-
this._handleSuccessfulStreamableHttp(res, message);
306+
await this._handleSuccessfulStreamableHttp(res, message);
302307
}
303308

304309
private async _sseFallbackWithMessage(message: string) {

0 commit comments

Comments
 (0)