Skip to content

Commit a76b263

Browse files
Merge pull request #268 from morinokami/patch-2
fix: Ensure the correct capability is checked for `completion/complete`
2 parents 4d5ce8f + 6807345 commit a76b263

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

Diff for: src/client/index.test.ts

+10-1
Original file line numberDiff line numberDiff line change
@@ -227,10 +227,19 @@ test("should respect server capabilities", async () => {
227227
await expect(client.listResources()).resolves.not.toThrow();
228228
await expect(client.listTools()).resolves.not.toThrow();
229229

230-
// This should throw because prompts are not supported
230+
// These should throw because prompts, logging, and completions are not supported
231231
await expect(client.listPrompts()).rejects.toThrow(
232232
"Server does not support prompts",
233233
);
234+
await expect(client.setLoggingLevel("error")).rejects.toThrow(
235+
"Server does not support logging",
236+
);
237+
await expect(
238+
client.complete({
239+
ref: { type: "ref/prompt", name: "test" },
240+
argument: { name: "test", value: "test" },
241+
}),
242+
).rejects.toThrow("Server does not support completions");
234243
});
235244

236245
test("should respect client notification capabilities", async () => {

Diff for: src/client/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,9 @@ export class Client<
237237
break;
238238

239239
case "completion/complete":
240-
if (!this._serverCapabilities?.prompts) {
240+
if (!this._serverCapabilities?.completions) {
241241
throw new Error(
242-
`Server does not support prompts (required for ${method})`,
242+
`Server does not support completions (required for ${method})`,
243243
);
244244
}
245245
break;

0 commit comments

Comments
 (0)