diff --git a/.changeset/fix-capability-error.md b/.changeset/fix-capability-error.md new file mode 100644 index 000000000..48db14a66 --- /dev/null +++ b/.changeset/fix-capability-error.md @@ -0,0 +1,5 @@ +--- +"@modelcontextprotocol/sdk": patch +--- + +fix: throw SdkError for unsupported capabilities in assertCapability() diff --git a/test/integration/test/client/client.test.ts b/test/integration/test/client/client.test.ts index 52d151bdd..ee71fd10a 100644 --- a/test/integration/test/client/client.test.ts +++ b/test/integration/test/client/client.test.ts @@ -470,6 +470,12 @@ test('should respect server capabilities', async () => { argument: { name: 'test', value: 'test' } }) ).rejects.toThrow('Server does not support completions'); + + // Verify that unsupported capability errors are SdkError with CapabilityNotSupported code + await expect(client.listPrompts()).rejects.toThrow(SdkError); + await expect(client.listPrompts()).rejects.toMatchObject({ + code: SdkErrorCode.CapabilityNotSupported + }); }); /***