Skip to content

Commit 6c33d31

Browse files
refactor: use server.request() instead of elicitInput() for client-side defaults test
Ensures conformance test validates true client-side default application rather than server-side validation behavior.
1 parent 2048c36 commit 6c33d31

File tree

1 file changed

+52
-45
lines changed

1 file changed

+52
-45
lines changed

src/scenarios/client/elicitation-defaults.ts

Lines changed: 52 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
/**
22
* SEP-1034: Elicitation defaults test
3-
* Validates that servers properly apply default values for omitted fields
4-
* in elicitation responses using the elicitInput() helper
3+
* Validates that clients properly apply default values for omitted fields
4+
* in elicitation responses before sending them to the server
55
*/
66

77
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
88
import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
99
import {
1010
CallToolRequestSchema,
11-
ListToolsRequestSchema
11+
ListToolsRequestSchema,
12+
ElicitResultSchema
1213
} from '@modelcontextprotocol/sdk/types.js';
1314
import type { Scenario, ConformanceCheck } from '../../types.js';
1415
import express, { Request, Response } from 'express';
@@ -70,43 +71,49 @@ function createServer(checks: ConformanceCheck[]): {
7071
if (request.params.name === 'test_client_elicitation_defaults') {
7172
try {
7273
// Request elicitation with all optional fields having defaults
73-
// Using elicitInput() which validates and applies defaults on server side
74-
const elicitResult = await server.elicitInput({
75-
message:
76-
'Test client default value handling - please accept with defaults',
77-
requestedSchema: {
78-
type: 'object',
79-
properties: {
80-
name: {
81-
type: 'string',
82-
description: 'User name',
83-
default: 'John Doe'
84-
},
85-
age: {
86-
type: 'integer',
87-
description: 'User age',
88-
default: 30
89-
},
90-
score: {
91-
type: 'number',
92-
description: 'User score',
93-
default: 95.5
94-
},
95-
status: {
96-
type: 'string',
97-
description: 'User status',
98-
enum: ['active', 'inactive', 'pending'],
99-
default: 'active'
100-
},
101-
verified: {
102-
type: 'boolean',
103-
description: 'Verification status',
104-
default: true
74+
// Using raw server.request() to verify client applies defaults before sending response
75+
const elicitResult = await server.request(
76+
{
77+
method: 'elicitation/create',
78+
params: {
79+
message:
80+
'Test client default value handling - please accept with defaults',
81+
requestedSchema: {
82+
type: 'object',
83+
properties: {
84+
name: {
85+
type: 'string',
86+
description: 'User name',
87+
default: 'John Doe'
88+
},
89+
age: {
90+
type: 'integer',
91+
description: 'User age',
92+
default: 30
93+
},
94+
score: {
95+
type: 'number',
96+
description: 'User score',
97+
default: 95.5
98+
},
99+
status: {
100+
type: 'string',
101+
description: 'User status',
102+
enum: ['active', 'inactive', 'pending'],
103+
default: 'active'
104+
},
105+
verified: {
106+
type: 'boolean',
107+
description: 'Verification status',
108+
default: true
109+
}
110+
},
111+
required: [] // All fields optional, so defaults should apply
105112
}
106-
},
107-
required: [] // All fields optional, so defaults should apply
108-
}
109-
});
113+
}
114+
},
115+
ElicitResultSchema
116+
);
110117

111118
// Check if elicitation was accepted
112119
if (elicitResult.action !== 'accept') {
@@ -146,7 +153,7 @@ function createServer(checks: ConformanceCheck[]): {
146153
checks.push({
147154
id: 'client-elicitation-sep1034-string-default',
148155
name: 'ClientElicitationSEP1034StringDefault',
149-
description: 'Server applies string default value for elicitation',
156+
description: 'Client applies string default value for elicitation',
150157
status: stringErrors.length === 0 ? 'SUCCESS' : 'FAILURE',
151158
timestamp: new Date().toISOString(),
152159
errorMessage:
@@ -177,7 +184,7 @@ function createServer(checks: ConformanceCheck[]): {
177184
checks.push({
178185
id: 'client-elicitation-sep1034-integer-default',
179186
name: 'ClientElicitationSEP1034IntegerDefault',
180-
description: 'Server applies integer default value for elicitation',
187+
description: 'Client applies integer default value for elicitation',
181188
status: integerErrors.length === 0 ? 'SUCCESS' : 'FAILURE',
182189
timestamp: new Date().toISOString(),
183190
errorMessage:
@@ -210,7 +217,7 @@ function createServer(checks: ConformanceCheck[]): {
210217
checks.push({
211218
id: 'client-elicitation-sep1034-number-default',
212219
name: 'ClientElicitationSEP1034NumberDefault',
213-
description: 'Server applies number default value for elicitation',
220+
description: 'Client applies number default value for elicitation',
214221
status: numberErrors.length === 0 ? 'SUCCESS' : 'FAILURE',
215222
timestamp: new Date().toISOString(),
216223
errorMessage:
@@ -249,7 +256,7 @@ function createServer(checks: ConformanceCheck[]): {
249256
checks.push({
250257
id: 'client-elicitation-sep1034-enum-default',
251258
name: 'ClientElicitationSEP1034EnumDefault',
252-
description: 'Server applies enum default value for elicitation',
259+
description: 'Client applies enum default value for elicitation',
253260
status: enumErrors.length === 0 ? 'SUCCESS' : 'FAILURE',
254261
timestamp: new Date().toISOString(),
255262
errorMessage:
@@ -282,7 +289,7 @@ function createServer(checks: ConformanceCheck[]): {
282289
checks.push({
283290
id: 'client-elicitation-sep1034-boolean-default',
284291
name: 'ClientElicitationSEP1034BooleanDefault',
285-
description: 'Server applies boolean default value for elicitation',
292+
description: 'Client applies boolean default value for elicitation',
286293
status: booleanErrors.length === 0 ? 'SUCCESS' : 'FAILURE',
287294
timestamp: new Date().toISOString(),
288295
errorMessage:
@@ -468,7 +475,7 @@ function createServer(checks: ConformanceCheck[]): {
468475
export class ElicitationClientDefaultsScenario implements Scenario {
469476
name = 'elicitation-sep1034-client-defaults';
470477
description =
471-
'Tests server applies default values for omitted elicitation fields (SEP-1034)';
478+
'Tests client applies default values for omitted elicitation fields (SEP-1034)';
472479
private app: express.Application | null = null;
473480
private httpServer: any = null;
474481
private checks: ConformanceCheck[] = [];

0 commit comments

Comments
 (0)