@@ -21,6 +21,7 @@ import {
2121 CompleteRequestSchema ,
2222 ElicitResultSchema ,
2323 isInitializeRequest ,
24+ ListToolsRequestSchema ,
2425 SetLevelRequestSchema ,
2526 McpServer ,
2627 ResourceTemplate ,
@@ -80,6 +81,29 @@ const TEST_IMAGE_BASE64 =
8081// Sample base64 encoded minimal WAV file for testing
8182const TEST_AUDIO_BASE64 = 'UklGRiYAAABXQVZFZm10IBAAAAABAAEAQB8AAAB9AAACABAAZGF0YQIAAAA=' ;
8283
84+ // SEP-1613: Raw JSON Schema 2020-12 definition for conformance testing
85+ // This schema includes $schema, $defs, and additionalProperties to test
86+ // that SDKs correctly preserve these fields when listing tools
87+ const JSON_SCHEMA_2020_12_TOOL_NAME = 'json_schema_2020_12_tool' ;
88+ const JSON_SCHEMA_2020_12_INPUT_SCHEMA = {
89+ $schema : 'https://json-schema.org/draft/2020-12/schema' ,
90+ type : 'object' as const ,
91+ $defs : {
92+ address : {
93+ type : 'object' ,
94+ properties : {
95+ street : { type : 'string' } ,
96+ city : { type : 'string' }
97+ }
98+ }
99+ } ,
100+ properties : {
101+ name : { type : 'string' } ,
102+ address : { $ref : '#/$defs/address' }
103+ } ,
104+ additionalProperties : false
105+ } ;
106+
83107// Function to create a new MCP server instance (one per session)
84108function createMcpServer ( sessionId ? : string ) {
85109 const mcpServer = new McpServer (
@@ -627,8 +651,9 @@ function createMcpServer(sessionId?: string) {
627651 );
628652
629653 // SEP-1613: JSON Schema 2020-12 conformance test tool
654+ // Register with Zod for call handling, but we'll override the inputSchema in ListTools
630655 mcpServer.registerTool(
631- 'json_schema_2020_12_tool' ,
656+ JSON_SCHEMA_2020_12_TOOL_NAME ,
632657 {
633658 description: 'Tool with JSON Schema 2020-12 features for conformance testing (SEP-1613)',
634659 inputSchema: {
@@ -653,6 +678,22 @@ function createMcpServer(sessionId?: string) {
653678 }
654679 );
655680
681+ // Override ListToolsRequestSchema to inject raw JSON Schema 2020-12 for SEP-1613 test
682+ // This is necessary because McpServer's registerTool converts Zod to JSON Schema,
683+ // which strips $schema, $defs, and additionalProperties fields
684+ const originalListToolsHandler = mcpServer.server['_requestHandlers'].get('tools/list');
685+ if (originalListToolsHandler) {
686+ mcpServer.server.setRequestHandler(ListToolsRequestSchema, async (request, extra) => {
687+ const result = (await originalListToolsHandler(request, extra)) as { tools: Array<{ name: string; inputSchema: unknown }> };
688+ // Replace the inputSchema for our SEP-1613 test tool
689+ const tool = result.tools.find(t => t.name === JSON_SCHEMA_2020_12_TOOL_NAME);
690+ if (tool) {
691+ tool.inputSchema = JSON_SCHEMA_2020_12_INPUT_SCHEMA;
692+ }
693+ return result;
694+ });
695+ }
696+
656697 // ===== RESOURCES =====
657698
658699 // Static text resource
0 commit comments