From a7526964393269a61e512c8e5b4f839e6bf869c6 Mon Sep 17 00:00:00 2001 From: Christopher Creighton Date: Wed, 5 Nov 2025 14:06:35 -0800 Subject: [PATCH 1/3] Partial fixes for SEP-1319 changes --- package.json | 2 +- src/spec.types.test.ts | 2 +- src/types.ts | 75 +++++++++++++++++++++--------------------- 3 files changed, 40 insertions(+), 39 deletions(-) diff --git a/package.json b/package.json index 36d9ddc98..ae74219fd 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,7 @@ "dist" ], "scripts": { - "fetch:spec-types": "curl -o spec.types.ts https://raw.githubusercontent.com/modelcontextprotocol/modelcontextprotocol/refs/heads/main/schema/draft/schema.ts", + "fetch:spec-types": "curl -o spec.types.ts https://raw.githubusercontent.com/ccreighton-apptio/modelcontextprotocol/refs/heads/fix/tool-call-arguments-regression/schema/draft/schema.ts", "build": "npm run build:esm && npm run build:cjs", "build:esm": "mkdir -p dist/esm && echo '{\"type\": \"module\"}' > dist/esm/package.json && tsc -p tsconfig.prod.json", "build:esm:w": "npm run build:esm -- -w", diff --git a/src/spec.types.test.ts b/src/spec.types.test.ts index 1f9083322..48f5af49f 100644 --- a/src/spec.types.test.ts +++ b/src/spec.types.test.ts @@ -470,7 +470,7 @@ describe('Spec Types', () => { it('should define some expected types', () => { expect(specTypes).toContain('JSONRPCNotification'); expect(specTypes).toContain('ElicitResult'); - expect(specTypes).toHaveLength(94); + expect(specTypes).toHaveLength(112); }); it('should have up to date list of missing sdk types', () => { diff --git a/src/types.ts b/src/types.ts index e6d3fe46e..6437b261e 100644 --- a/src/types.ts +++ b/src/types.ts @@ -27,30 +27,28 @@ const RequestMetaSchema = z }) .passthrough(); -const BaseRequestParamsSchema = z - .object({ - _meta: z.optional(RequestMetaSchema) - }) - .passthrough(); +const BaseRequestParamsSchema = z.object({ + _meta: z.optional(RequestMetaSchema) +}); export const RequestSchema = z.object({ method: z.string(), - params: z.optional(BaseRequestParamsSchema) + params: z.optional(z.record(z.any())) }); -const BaseNotificationParamsSchema = z - .object({ - /** - * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields) - * for notes on _meta usage. - */ - _meta: z.optional(z.object({}).passthrough()) - }) - .passthrough(); +const NotificationsMetaSchema = z.object({}).passthrough(); + +const BaseNotificationParamsSchema = z.object({ + /** + * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields) + * for notes on _meta usage. + */ + _meta: z.optional(NotificationsMetaSchema) +}); export const NotificationSchema = z.object({ method: z.string(), - params: z.optional(BaseNotificationParamsSchema) + params: z.optional(z.record(z.any())) }); export const ResultSchema = z @@ -395,7 +393,8 @@ export const InitializeResultSchema = ResultSchema.extend({ * This notification is sent from the client to the server after initialization has finished. */ export const InitializedNotificationSchema = NotificationSchema.extend({ - method: z.literal('notifications/initialized') + method: z.literal('notifications/initialized'), + params: z.optional(BaseNotificationParamsSchema) }); export const isInitializedNotification = (value: unknown): value is InitializedNotification => @@ -406,26 +405,25 @@ export const isInitializedNotification = (value: unknown): value is InitializedN * A ping, issued by either the server or the client, to check that the other party is still alive. The receiver must promptly respond, or else may be disconnected. */ export const PingRequestSchema = RequestSchema.extend({ - method: z.literal('ping') + method: z.literal('ping'), + params: z.optional(BaseRequestParamsSchema) }); /* Progress notifications */ -export const ProgressSchema = z - .object({ - /** - * The progress thus far. This should increase every time progress is made, even if the total is unknown. - */ - progress: z.number(), - /** - * Total number of items to process (or total progress required), if known. - */ - total: z.optional(z.number()), - /** - * An optional message describing the current progress. - */ - message: z.optional(z.string()) - }) - .passthrough(); +export const ProgressSchema = z.object({ + /** + * The progress thus far. This should increase every time progress is made, even if the total is unknown. + */ + progress: z.number(), + /** + * Total number of items to process (or total progress required), if known. + */ + total: z.optional(z.number()), + /** + * An optional message describing the current progress. + */ + message: z.optional(z.string()) +}); /** * An out-of-band notification used to inform the receiver of a progress update for a long-running request. @@ -622,7 +620,8 @@ export const ReadResourceResultSchema = ResultSchema.extend({ * An optional notification from the server to the client, informing it that the list of resources it can read from has changed. This may be issued by servers without any previous subscription from the client. */ export const ResourceListChangedNotificationSchema = NotificationSchema.extend({ - method: z.literal('notifications/resources/list_changed') + method: z.literal('notifications/resources/list_changed'), + params: z.optional(BaseNotificationParamsSchema) }); /** @@ -860,7 +859,8 @@ export const GetPromptResultSchema = ResultSchema.extend({ * An optional notification from the server to the client, informing it that the list of prompts it offers has changed. This may be issued by servers without any previous subscription from the client. */ export const PromptListChangedNotificationSchema = NotificationSchema.extend({ - method: z.literal('notifications/prompts/list_changed') + method: z.literal('notifications/prompts/list_changed'), + params: z.optional(BaseNotificationParamsSchema) }); /* Tools */ @@ -1037,7 +1037,8 @@ export const CallToolRequestSchema = RequestSchema.extend({ * An optional notification from the server to the client, informing it that the list of tools it offers has changed. This may be issued by servers without any previous subscription from the client. */ export const ToolListChangedNotificationSchema = NotificationSchema.extend({ - method: z.literal('notifications/tools/list_changed') + method: z.literal('notifications/tools/list_changed'), + params: z.optional(BaseNotificationParamsSchema) }); /* Logging */ From 50e3f3a874aafb6ec9721e55bd6bb3e1d4de219d Mon Sep 17 00:00:00 2001 From: Christopher Creighton Date: Wed, 5 Nov 2025 14:59:10 -0800 Subject: [PATCH 2/3] In the meantime, steal the list of param types from @ksinder --- src/spec.types.test.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/spec.types.test.ts b/src/spec.types.test.ts index 48f5af49f..3fa995f01 100644 --- a/src/spec.types.test.ts +++ b/src/spec.types.test.ts @@ -451,6 +451,26 @@ const MISSING_SDK_TYPES = [ 'Role', 'Error', // The inner error object of a JSONRPCError + // Params types are not exported as standalone types in the SDK (they're inferred from Zod schemas): + 'RequestParams', + 'NotificationParams', + 'CancelledNotificationParams', + 'InitializeRequestParams', + 'ProgressNotificationParams', + 'PaginatedRequestParams', + 'ResourceRequestParams', + 'ReadResourceRequestParams', + 'SubscribeRequestParams', + 'UnsubscribeRequestParams', + 'SetLevelRequestParams', + 'GetPromptRequestParams', + 'CompleteRequestParams', + 'CallToolRequestParams', + 'CreateMessageRequestParams', + 'LoggingMessageNotificationParams', + 'ResourceUpdatedNotificationParams', + 'ElicitRequestParams', + // These aren't supported by the SDK yet: // TODO: Add definitions to the SDK 'Annotations', From 7411b910c8a6e5742a5b35ab365db4ce3e40303b Mon Sep 17 00:00:00 2001 From: Paul Carleton Date: Fri, 7 Nov 2025 10:01:38 +0000 Subject: [PATCH 3/3] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ae74219fd..36d9ddc98 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,7 @@ "dist" ], "scripts": { - "fetch:spec-types": "curl -o spec.types.ts https://raw.githubusercontent.com/ccreighton-apptio/modelcontextprotocol/refs/heads/fix/tool-call-arguments-regression/schema/draft/schema.ts", + "fetch:spec-types": "curl -o spec.types.ts https://raw.githubusercontent.com/modelcontextprotocol/modelcontextprotocol/refs/heads/main/schema/draft/schema.ts", "build": "npm run build:esm && npm run build:cjs", "build:esm": "mkdir -p dist/esm && echo '{\"type\": \"module\"}' > dist/esm/package.json && tsc -p tsconfig.prod.json", "build:esm:w": "npm run build:esm -- -w",