MCPcopy Create free account
hub / github.com/modelcontextprotocol/typescript-sdk / testElicitationFlow

Function testElicitationFlow

test/server/elicitation.test.ts:65–988  ·  view source on GitHub ↗
(validatorProvider: typeof ajvProvider | typeof cfWorkerProvider, validatorName: string)

Source from the content-addressed store, hash-verified

63});
64
65function testElicitationFlow(validatorProvider: typeof ajvProvider | typeof cfWorkerProvider, validatorName: string) {
66 test(`${validatorName}: should elicit simple object with string field`, async () => {
67 client.setRequestHandler(ElicitRequestSchema, _request => ({
68 action: 'accept',
69 content: { name: 'John Doe' }
70 }));
71
72 const result = await server.elicitInput({
73 mode: 'form',
74 message: 'What is your name?',
75 requestedSchema: {
76 type: 'object',
77 properties: {
78 name: { type: 'string', minLength: 1 }
79 },
80 required: ['name']
81 }
82 });
83
84 expect(result).toEqual({
85 action: 'accept',
86 content: { name: 'John Doe' }
87 });
88 });
89
90 test(`${validatorName}: should elicit object with integer field`, async () => {
91 client.setRequestHandler(ElicitRequestSchema, _request => ({
92 action: 'accept',
93 content: { age: 42 }
94 }));
95
96 const result = await server.elicitInput({
97 mode: 'form',
98 message: 'What is your age?',
99 requestedSchema: {
100 type: 'object',
101 properties: {
102 age: { type: 'integer', minimum: 0, maximum: 150 }
103 },
104 required: ['age']
105 }
106 });
107
108 expect(result).toEqual({
109 action: 'accept',
110 content: { age: 42 }
111 });
112 });
113
114 test(`${validatorName}: should elicit object with boolean field`, async () => {
115 client.setRequestHandler(ElicitRequestSchema, _request => ({
116 action: 'accept',
117 content: { agree: true }
118 }));
119
120 const result = await server.elicitInput({
121 mode: 'form',
122 message: 'Do you agree?',

Callers 1

Calls 4

setRequestHandlerMethod · 0.95
elicitInputMethod · 0.95
connectMethod · 0.95
createLinkedPairMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…