Don't double-add completion handler

This commit is contained in:
Justin Spahr-Summers 2025-01-22 11:40:26 +00:00
commit dbf560f24a
No known key found for this signature in database

View file

@ -175,7 +175,13 @@ export class McpServer {
this._toolHandlersInitialized = true;
}
private _completionHandlerInitialized = false;
private setCompletionRequestHandler() {
if (this._completionHandlerInitialized) {
return;
}
this.server.assertCanSetRequestHandler(
CompleteRequestSchema.shape.method.value,
);
@ -198,6 +204,8 @@ export class McpServer {
}
},
);
this._completionHandlerInitialized = true;
}
private async handlePromptCompletion(