fix(server-stateless): requiredCapabilities is a ClientCapabilities object, not an array (#376)

The sep-2575-server-rejects-undeclared-capability check required
error.data.requiredCapabilities to be an array containing 'sampling'. The
schema's MissingRequiredClientCapabilityError defines it as a
ClientCapabilities object ({ "sampling": {} }), as do this repo's own
spec-types and the tasks/required-task-error scenario, so a spec-correct
server could not pass the check. It shipped because the positive -32021
branch had no self-test.

- stateless.ts: accept the object shape; each capability value must itself
  be an object ({ "sampling": null } fails). State the shape in the
  scenario's implementer-facing description.
- examples/servers/typescript/everything-server.ts: emit the object.
- stateless.test.ts: self-tests for object-passes / array-fails /
  null-value-fails, sharing one capability-probe mock helper.
This commit is contained in:
Felix Weinberger 2026-07-01 17:46:14 +01:00 • committed by GitHub
commit 9524edcf41
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1663,7 +1663,9 @@ app.post('/mcp', async (req, res) => {
error: {
code: -32021,
message: 'MissingRequiredClientCapabilityError',
data: { requiredCapabilities: ['sampling'] }
// Per the schema, requiredCapabilities is a ClientCapabilities
// object keyed by the missing capability, not an array of names.
data: { requiredCapabilities: { sampling: {} } }
}
});
}