Skip to content

Commit b739add

Browse files
committed
feat: add json-schema-2020-12 client conformance handler
Adds handler for the json-schema-2020-12 scenario that tests preservation of JSON Schema 2020-12 fields ($schema, $defs, additionalProperties) per SEP-1613.
1 parent 8856303 commit b739add

1 file changed

Lines changed: 49 additions & 0 deletions

File tree

src/conformance/everything-client.ts

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,55 @@ async function runToolsCallClient(serverUrl: string): Promise<void> {
134134
registerScenario('initialize', runBasicClient);
135135
registerScenario('tools_call', runToolsCallClient);
136136

137+
// ============================================================================
138+
// JSON Schema 2020-12 scenario (SEP-1613)
139+
// ============================================================================
140+
141+
/**
142+
* Tests that the client preserves JSON Schema 2020-12 fields ($schema, $defs, additionalProperties)
143+
* when receiving tool definitions from a server.
144+
*/
145+
async function runJsonSchema2020_12Client(serverUrl: string): Promise<void> {
146+
const client = new Client(
147+
{ name: 'json-schema-2020-12-test-client', version: '1.0.0' },
148+
{ capabilities: {} }
149+
);
150+
151+
const transport = new StreamableHTTPClientTransport(new URL(serverUrl));
152+
153+
await client.connect(transport);
154+
logger.debug('Successfully connected to MCP server');
155+
156+
const tools = await client.listTools();
157+
logger.debug('Successfully listed tools');
158+
159+
// Find the JSON Schema 2020-12 test tool
160+
const jsonSchemaTool = tools.tools.find(
161+
(t) => t.name === 'json_schema_2020_12_tool'
162+
);
163+
if (!jsonSchemaTool) {
164+
throw new Error('Test tool not found: json_schema_2020_12_tool');
165+
}
166+
167+
logger.debug(
168+
'Found json_schema_2020_12_tool with inputSchema:',
169+
JSON.stringify(jsonSchemaTool.inputSchema, null, 2)
170+
);
171+
172+
// Echo back the inputSchema we received to verify it was preserved
173+
const result = await client.callTool({
174+
name: 'echo_schema',
175+
arguments: { receivedSchema: jsonSchemaTool.inputSchema }
176+
});
177+
178+
logger.debug('Echo result:', JSON.stringify(result, null, 2));
179+
180+
await transport.close();
181+
logger.debug('Connection closed successfully');
182+
}
183+
184+
registerScenario('json-schema-2020-12', runJsonSchema2020_12Client);
185+
137186
// ============================================================================
138187
// Auth scenarios - well-behaved client
139188
// ============================================================================

0 commit comments

Comments
 (0)