fix: React to upstream RC schema changes for form mode elicitation requests (#1164)

Co-authored-by: Nate Barbettini <nate@arcade.dev>
This commit is contained in:
Felix Weinberger 2025-11-25 11:21:07 +00:00 • committed by GitHub
commit b59a2bde7d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -14,6 +14,7 @@ import {
CallToolRequestSchema,
CreateMessageRequestSchema,
ElicitRequestSchema,
ElicitResultSchema,
ListRootsRequestSchema,
ErrorCode
} from '../types.js';
@ -917,6 +918,64 @@ test('should reject form-mode elicitation when client only supports URL mode', a
await client.close();
});
test('should reject missing-mode elicitation when client only supports URL mode', async () => {
const server = new Server(
{
name: 'test server',
version: '1.0'
},
{
capabilities: {}
}
);
const client = new Client(
{
name: 'test client',
version: '1.0'
},
{
capabilities: {
elicitation: {
url: {}
}
}
}
);
const handler = vi.fn().mockResolvedValue({
action: 'cancel'
});
client.setRequestHandler(ElicitRequestSchema, handler);
const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();
await Promise.all([client.connect(clientTransport), server.connect(serverTransport)]);
await expect(
server.request(
{
method: 'elicitation/create',
params: {
message: 'Please provide data',
requestedSchema: {
type: 'object',
properties: {
username: {
type: 'string'
}
}
}
}
},
ElicitResultSchema
)
).rejects.toThrow('Client does not support form-mode elicitation requests');
expect(handler).not.toHaveBeenCalled();
await Promise.all([client.close(), server.close()]);
});
test('should reject URL-mode elicitation when client only supports form mode', async () => {
const client = new Client(
{