Skip to content

fix: Ensure the correct capability is checked for completion/complete #268

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/client/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,19 @@ test("should respect server capabilities", async () => {
await expect(client.listResources()).resolves.not.toThrow();
await expect(client.listTools()).resolves.not.toThrow();

// This should throw because prompts are not supported
// These should throw because prompts, logging, and completions are not supported
await expect(client.listPrompts()).rejects.toThrow(
"Server does not support prompts",
);
await expect(client.setLoggingLevel("error")).rejects.toThrow(
"Server does not support logging",
);
await expect(
client.complete({
ref: { type: "ref/prompt", name: "test" },
argument: { name: "test", value: "test" },
}),
).rejects.toThrow("Server does not support completions");
});

test("should respect client notification capabilities", async () => {
Expand Down
4 changes: 2 additions & 2 deletions src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,9 @@ export class Client<
break;

case "completion/complete":
if (!this._serverCapabilities?.prompts) {
if (!this._serverCapabilities?.completions) {
throw new Error(
`Server does not support prompts (required for ${method})`,
`Server does not support completions (required for ${method})`,
);
}
break;
Expand Down