Skip to content

Commit 05fb331

Browse files
committed
Rename elicitInput, split into form and URL methods
1 parent 469d804 commit 05fb331

File tree

7 files changed

+61
-54
lines changed

7 files changed

+61
-54
lines changed

src/examples/server/elicitationExample.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ mcpServer.registerTool(
3737
async () => {
3838
try {
3939
// Request user information through elicitation
40-
const result = await mcpServer.server.elicitInput({
41-
mode: 'form',
40+
const result = await mcpServer.server.elicitFormInput({
4241
message: 'Please provide your registration information:',
4342
requestedSchema: {
4443
type: 'object',
@@ -136,8 +135,7 @@ mcpServer.registerTool(
136135
async () => {
137136
try {
138137
// Step 1: Collect basic event information
139-
const basicInfo = await mcpServer.server.elicitInput({
140-
mode: 'form',
138+
const basicInfo = await mcpServer.server.elicitFormInput({
141139
message: 'Step 1: Enter basic event information',
142140
requestedSchema: {
143141
type: 'object',
@@ -165,8 +163,7 @@ mcpServer.registerTool(
165163
}
166164

167165
// Step 2: Collect date and time
168-
const dateTime = await mcpServer.server.elicitInput({
169-
mode: 'form',
166+
const dateTime = await mcpServer.server.elicitFormInput({
170167
message: 'Step 2: Enter date and time',
171168
requestedSchema: {
172169
type: 'object',
@@ -240,8 +237,7 @@ mcpServer.registerTool(
240237
},
241238
async () => {
242239
try {
243-
const result = await mcpServer.server.elicitInput({
244-
mode: 'form',
240+
const result = await mcpServer.server.elicitFormInput({
245241
message: 'Please provide your shipping address:',
246242
requestedSchema: {
247243
type: 'object',

src/examples/server/elicitationStreamableHttp.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ const mcpPostHandler = async (req: Request, res: Response) => {
625625
console.log(`Session initialized with ID: ${sessionId}`);
626626
transports[sessionId] = transport;
627627
sessionsNeedingElicitation[sessionId] = {
628-
elicitationSender: server.server.elicitInput.bind(server.server),
628+
elicitationSender: server.server.elicitUrl.bind(server.server),
629629
notificationSender: async (notification: ElicitationCompleteNotification) => {
630630
await server.server.notification(notification);
631631
}

src/examples/server/simpleStreamableHttp.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ const getServer = () => {
215215

216216
try {
217217
// Use the underlying server instance to elicit input from the client
218-
const result = await server.server.elicitInput({
218+
const result = await server.server.elicitFormInput({
219219
message,
220220
requestedSchema
221221
});

src/server/elicitation.test.ts

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
import { Client } from '../client/index.js';
1111
import { InMemoryTransport } from '../inMemory.js';
12-
import { ElicitRequestParams, ElicitRequestSchema } from '../types.js';
12+
import { ElicitRequestFormParams, ElicitRequestSchema } from '../types.js';
1313
import { AjvJsonSchemaValidator } from '../validation/ajv-provider.js';
1414
import { CfWorkerJsonSchemaValidator } from '../validation/cfworker-provider.js';
1515
import { Server } from './index.js';
@@ -69,7 +69,7 @@ function testElicitationFlow(validatorProvider: typeof ajvProvider | typeof cfWo
6969
content: { name: 'John Doe' }
7070
}));
7171

72-
const result = await server.elicitInput({
72+
const result = await server.elicitFormInput({
7373
message: 'What is your name?',
7474
requestedSchema: {
7575
type: 'object',
@@ -92,7 +92,7 @@ function testElicitationFlow(validatorProvider: typeof ajvProvider | typeof cfWo
9292
content: { age: 42 }
9393
}));
9494

95-
const result = await server.elicitInput({
95+
const result = await server.elicitFormInput({
9696
message: 'What is your age?',
9797
requestedSchema: {
9898
type: 'object',
@@ -115,7 +115,7 @@ function testElicitationFlow(validatorProvider: typeof ajvProvider | typeof cfWo
115115
content: { agree: true }
116116
}));
117117

118-
const result = await server.elicitInput({
118+
const result = await server.elicitFormInput({
119119
message: 'Do you agree?',
120120
requestedSchema: {
121121
type: 'object',
@@ -149,7 +149,7 @@ function testElicitationFlow(validatorProvider: typeof ajvProvider | typeof cfWo
149149
content: userData
150150
}));
151151

152-
const result = await server.elicitInput({
152+
const result = await server.elicitFormInput({
153153
message: 'Please provide your information',
154154
requestedSchema: {
155155
type: 'object',
@@ -184,7 +184,7 @@ function testElicitationFlow(validatorProvider: typeof ajvProvider | typeof cfWo
184184
}));
185185

186186
await expect(
187-
server.elicitInput({
187+
server.elicitFormInput({
188188
message: 'Please provide your information',
189189
requestedSchema: {
190190
type: 'object',
@@ -208,7 +208,7 @@ function testElicitationFlow(validatorProvider: typeof ajvProvider | typeof cfWo
208208
}));
209209

210210
await expect(
211-
server.elicitInput({
211+
server.elicitFormInput({
212212
message: 'Please provide your information',
213213
requestedSchema: {
214214
type: 'object',
@@ -229,7 +229,7 @@ function testElicitationFlow(validatorProvider: typeof ajvProvider | typeof cfWo
229229
}));
230230

231231
await expect(
232-
server.elicitInput({
232+
server.elicitFormInput({
233233
message: 'What is your name?',
234234
requestedSchema: {
235235
type: 'object',
@@ -249,7 +249,7 @@ function testElicitationFlow(validatorProvider: typeof ajvProvider | typeof cfWo
249249
}));
250250

251251
await expect(
252-
server.elicitInput({
252+
server.elicitFormInput({
253253
message: 'What is your age?',
254254
requestedSchema: {
255255
type: 'object',
@@ -269,7 +269,7 @@ function testElicitationFlow(validatorProvider: typeof ajvProvider | typeof cfWo
269269
}));
270270

271271
await expect(
272-
server.elicitInput({
272+
server.elicitFormInput({
273273
message: 'Enter a 5-digit zip code',
274274
requestedSchema: {
275275
type: 'object',
@@ -288,7 +288,7 @@ function testElicitationFlow(validatorProvider: typeof ajvProvider | typeof cfWo
288288
action: 'decline'
289289
}));
290290

291-
const result = await server.elicitInput({
291+
const result = await server.elicitFormInput({
292292
message: 'Please provide your information',
293293
requestedSchema: {
294294
type: 'object',
@@ -309,7 +309,7 @@ function testElicitationFlow(validatorProvider: typeof ajvProvider | typeof cfWo
309309
action: 'cancel'
310310
}));
311311

312-
const result = await server.elicitInput({
312+
const result = await server.elicitFormInput({
313313
message: 'Please provide your information',
314314
requestedSchema: {
315315
type: 'object',
@@ -339,7 +339,7 @@ function testElicitationFlow(validatorProvider: typeof ajvProvider | typeof cfWo
339339
return { action: 'decline' };
340340
});
341341

342-
const nameResult = await server.elicitInput({
342+
const nameResult = await server.elicitFormInput({
343343
message: 'What is your name?',
344344
requestedSchema: {
345345
type: 'object',
@@ -348,7 +348,7 @@ function testElicitationFlow(validatorProvider: typeof ajvProvider | typeof cfWo
348348
}
349349
});
350350

351-
const ageResult = await server.elicitInput({
351+
const ageResult = await server.elicitFormInput({
352352
message: 'What is your age?',
353353
requestedSchema: {
354354
type: 'object',
@@ -357,7 +357,7 @@ function testElicitationFlow(validatorProvider: typeof ajvProvider | typeof cfWo
357357
}
358358
});
359359

360-
const cityResult = await server.elicitInput({
360+
const cityResult = await server.elicitFormInput({
361361
message: 'What is your city?',
362362
requestedSchema: {
363363
type: 'object',
@@ -384,7 +384,7 @@ function testElicitationFlow(validatorProvider: typeof ajvProvider | typeof cfWo
384384
content: { name: 'John', nickname: 'Johnny' }
385385
}));
386386

387-
const result = await server.elicitInput({
387+
const result = await server.elicitFormInput({
388388
message: 'Enter your name',
389389
requestedSchema: {
390390
type: 'object',
@@ -408,7 +408,7 @@ function testElicitationFlow(validatorProvider: typeof ajvProvider | typeof cfWo
408408
content: { name: 'John' }
409409
}));
410410

411-
const result = await server.elicitInput({
411+
const result = await server.elicitFormInput({
412412
message: 'Enter your name',
413413
requestedSchema: {
414414
type: 'object',
@@ -432,7 +432,7 @@ function testElicitationFlow(validatorProvider: typeof ajvProvider | typeof cfWo
432432
content: { email: '[email protected]' }
433433
}));
434434

435-
const result = await server.elicitInput({
435+
const result = await server.elicitFormInput({
436436
message: 'Enter your email',
437437
requestedSchema: {
438438
type: 'object',
@@ -469,7 +469,7 @@ function testElicitationFlow(validatorProvider: typeof ajvProvider | typeof cfWo
469469
}
470470
);
471471

472-
const testSchemaProperties: ElicitRequestParams['requestedSchema'] = {
472+
const testSchemaProperties: ElicitRequestFormParams['requestedSchema'] = {
473473
type: 'object',
474474
properties: {
475475
subscribe: { type: 'boolean', default: true },
@@ -542,7 +542,8 @@ function testElicitationFlow(validatorProvider: typeof ajvProvider | typeof cfWo
542542

543543
// Client returns no values; SDK should apply defaults automatically (and validate)
544544
client.setRequestHandler(ElicitRequestSchema, request => {
545-
expect(request.params.requestedSchema).toEqual(testSchemaProperties);
545+
expect(request.params.mode).toEqual('form');
546+
expect((request.params as ElicitRequestFormParams).requestedSchema).toEqual(testSchemaProperties);
546547
return {
547548
action: 'accept',
548549
content: {}
@@ -552,7 +553,7 @@ function testElicitationFlow(validatorProvider: typeof ajvProvider | typeof cfWo
552553
const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();
553554
await Promise.all([client.connect(clientTransport), server.connect(serverTransport)]);
554555

555-
const result = await server.elicitInput({
556+
const result = await server.elicitFormInput({
556557
message: 'Provide your preferences',
557558
requestedSchema: testSchemaProperties
558559
});
@@ -581,7 +582,7 @@ function testElicitationFlow(validatorProvider: typeof ajvProvider | typeof cfWo
581582
}));
582583

583584
await expect(
584-
server.elicitInput({
585+
server.elicitFormInput({
585586
message: 'Enter your email',
586587
requestedSchema: {
587588
type: 'object',
@@ -607,7 +608,7 @@ function testElicitationFlow(validatorProvider: typeof ajvProvider | typeof cfWo
607608

608609
// Test with valid response
609610
await expect(
610-
server.elicitInput({
611+
server.elicitFormInput({
611612
message: 'Please provide your information',
612613
requestedSchema: {
613614
type: 'object',
@@ -642,7 +643,7 @@ function testElicitationFlow(validatorProvider: typeof ajvProvider | typeof cfWo
642643

643644
// Test with valid response
644645
await expect(
645-
server.elicitInput({
646+
server.elicitFormInput({
646647
message: 'Please provide your information',
647648
requestedSchema: {
648649
type: 'object',
@@ -681,7 +682,7 @@ function testElicitationFlow(validatorProvider: typeof ajvProvider | typeof cfWo
681682

682683
// Test with valid response
683684
await expect(
684-
server.elicitInput({
685+
server.elicitFormInput({
685686
message: 'Please provide your information',
686687
requestedSchema: {
687688
type: 'object',
@@ -719,7 +720,7 @@ function testElicitationFlow(validatorProvider: typeof ajvProvider | typeof cfWo
719720

720721
// Test with valid response
721722
await expect(
722-
server.elicitInput({
723+
server.elicitFormInput({
723724
message: 'Please provide your information',
724725
requestedSchema: {
725726
type: 'object',
@@ -758,7 +759,7 @@ function testElicitationFlow(validatorProvider: typeof ajvProvider | typeof cfWo
758759

759760
// Test with valid response
760761
await expect(
761-
server.elicitInput({
762+
server.elicitFormInput({
762763
message: 'Please provide your information',
763764
requestedSchema: {
764765
type: 'object',
@@ -802,7 +803,7 @@ function testElicitationFlow(validatorProvider: typeof ajvProvider | typeof cfWo
802803

803804
// Test with valid response
804805
await expect(
805-
server.elicitInput({
806+
server.elicitFormInput({
806807
message: 'Please provide your information',
807808
requestedSchema: {
808809
type: 'object',
@@ -832,7 +833,7 @@ function testElicitationFlow(validatorProvider: typeof ajvProvider | typeof cfWo
832833

833834
// Test with valid response
834835
await expect(
835-
server.elicitInput({
836+
server.elicitFormInput({
836837
message: 'Please provide your information',
837838
requestedSchema: {
838839
type: 'object',
@@ -866,7 +867,7 @@ function testElicitationFlow(validatorProvider: typeof ajvProvider | typeof cfWo
866867

867868
// Test with valid response
868869
await expect(
869-
server.elicitInput({
870+
server.elicitFormInput({
870871
message: 'Please provide your information',
871872
requestedSchema: {
872873
type: 'object',
@@ -899,7 +900,7 @@ function testElicitationFlow(validatorProvider: typeof ajvProvider | typeof cfWo
899900

900901
// Test with valid response
901902
await expect(
902-
server.elicitInput({
903+
server.elicitFormInput({
903904
message: 'Please provide your information',
904905
requestedSchema: {
905906
type: 'object',
@@ -933,7 +934,7 @@ function testElicitationFlow(validatorProvider: typeof ajvProvider | typeof cfWo
933934

934935
// Test with valid response
935936
await expect(
936-
server.elicitInput({
937+
server.elicitFormInput({
937938
message: 'Please provide your information',
938939
requestedSchema: {
939940
type: 'object',

src/server/index.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ test('should respect client elicitation capabilities', async () => {
308308

309309
// This should work because elicitation is supported by the client
310310
await expect(
311-
server.elicitInput({
311+
server.elicitFormInput({
312312
message: 'Please provide your username',
313313
requestedSchema: {
314314
type: 'object',
@@ -390,7 +390,7 @@ test('should validate elicitation response against requested schema', async () =
390390

391391
// Test with valid response
392392
await expect(
393-
server.elicitInput({
393+
server.elicitFormInput({
394394
message: 'Please provide your information',
395395
requestedSchema: {
396396
type: 'object',
@@ -466,7 +466,7 @@ test('should reject elicitation response with invalid data', async () => {
466466

467467
// Test with invalid response
468468
await expect(
469-
server.elicitInput({
469+
server.elicitFormInput({
470470
message: 'Please provide your information',
471471
requestedSchema: {
472472
type: 'object',
@@ -544,7 +544,7 @@ test('should allow elicitation reject and cancel without validation', async () =
544544

545545
// Test reject - should not validate
546546
await expect(
547-
server.elicitInput({
547+
server.elicitFormInput({
548548
message: 'Please provide your name',
549549
requestedSchema: schema
550550
})
@@ -554,7 +554,7 @@ test('should allow elicitation reject and cancel without validation', async () =
554554

555555
// Test cancel - should not validate
556556
await expect(
557-
server.elicitInput({
557+
server.elicitFormInput({
558558
message: 'Please provide your name',
559559
requestedSchema: schema
560560
})

0 commit comments

Comments
 (0)