Skip to content

Commit dbf560f

Browse files
committed
Don't double-add completion handler
1 parent eba6461 commit dbf560f

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/server/mcp.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,13 @@ export class McpServer {
175175
this._toolHandlersInitialized = true;
176176
}
177177

178+
private _completionHandlerInitialized = false;
179+
178180
private setCompletionRequestHandler() {
181+
if (this._completionHandlerInitialized) {
182+
return;
183+
}
184+
179185
this.server.assertCanSetRequestHandler(
180186
CompleteRequestSchema.shape.method.value,
181187
);
@@ -198,6 +204,8 @@ export class McpServer {
198204
}
199205
},
200206
);
207+
208+
this._completionHandlerInitialized = true;
201209
}
202210

203211
private async handlePromptCompletion(

0 commit comments

Comments
 (0)