Skip to content

Commit a752696

Browse files
Partial fixes for SEP-1319 changes
1 parent 9757ace commit a752696

File tree

3 files changed

+40
-39
lines changed

3 files changed

+40
-39
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
"dist"
6060
],
6161
"scripts": {
62-
"fetch:spec-types": "curl -o spec.types.ts https://raw.githubusercontent.com/modelcontextprotocol/modelcontextprotocol/refs/heads/main/schema/draft/schema.ts",
62+
"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",
6363
"build": "npm run build:esm && npm run build:cjs",
6464
"build:esm": "mkdir -p dist/esm && echo '{\"type\": \"module\"}' > dist/esm/package.json && tsc -p tsconfig.prod.json",
6565
"build:esm:w": "npm run build:esm -- -w",

src/spec.types.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ describe('Spec Types', () => {
470470
it('should define some expected types', () => {
471471
expect(specTypes).toContain('JSONRPCNotification');
472472
expect(specTypes).toContain('ElicitResult');
473-
expect(specTypes).toHaveLength(94);
473+
expect(specTypes).toHaveLength(112);
474474
});
475475

476476
it('should have up to date list of missing sdk types', () => {

src/types.ts

Lines changed: 38 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -27,30 +27,28 @@ const RequestMetaSchema = z
2727
})
2828
.passthrough();
2929

30-
const BaseRequestParamsSchema = z
31-
.object({
32-
_meta: z.optional(RequestMetaSchema)
33-
})
34-
.passthrough();
30+
const BaseRequestParamsSchema = z.object({
31+
_meta: z.optional(RequestMetaSchema)
32+
});
3533

3634
export const RequestSchema = z.object({
3735
method: z.string(),
38-
params: z.optional(BaseRequestParamsSchema)
36+
params: z.optional(z.record(z.any()))
3937
});
4038

41-
const BaseNotificationParamsSchema = z
42-
.object({
43-
/**
44-
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
45-
* for notes on _meta usage.
46-
*/
47-
_meta: z.optional(z.object({}).passthrough())
48-
})
49-
.passthrough();
39+
const NotificationsMetaSchema = z.object({}).passthrough();
40+
41+
const BaseNotificationParamsSchema = z.object({
42+
/**
43+
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
44+
* for notes on _meta usage.
45+
*/
46+
_meta: z.optional(NotificationsMetaSchema)
47+
});
5048

5149
export const NotificationSchema = z.object({
5250
method: z.string(),
53-
params: z.optional(BaseNotificationParamsSchema)
51+
params: z.optional(z.record(z.any()))
5452
});
5553

5654
export const ResultSchema = z
@@ -395,7 +393,8 @@ export const InitializeResultSchema = ResultSchema.extend({
395393
* This notification is sent from the client to the server after initialization has finished.
396394
*/
397395
export const InitializedNotificationSchema = NotificationSchema.extend({
398-
method: z.literal('notifications/initialized')
396+
method: z.literal('notifications/initialized'),
397+
params: z.optional(BaseNotificationParamsSchema)
399398
});
400399

401400
export const isInitializedNotification = (value: unknown): value is InitializedNotification =>
@@ -406,26 +405,25 @@ export const isInitializedNotification = (value: unknown): value is InitializedN
406405
* 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.
407406
*/
408407
export const PingRequestSchema = RequestSchema.extend({
409-
method: z.literal('ping')
408+
method: z.literal('ping'),
409+
params: z.optional(BaseRequestParamsSchema)
410410
});
411411

412412
/* Progress notifications */
413-
export const ProgressSchema = z
414-
.object({
415-
/**
416-
* The progress thus far. This should increase every time progress is made, even if the total is unknown.
417-
*/
418-
progress: z.number(),
419-
/**
420-
* Total number of items to process (or total progress required), if known.
421-
*/
422-
total: z.optional(z.number()),
423-
/**
424-
* An optional message describing the current progress.
425-
*/
426-
message: z.optional(z.string())
427-
})
428-
.passthrough();
413+
export const ProgressSchema = z.object({
414+
/**
415+
* The progress thus far. This should increase every time progress is made, even if the total is unknown.
416+
*/
417+
progress: z.number(),
418+
/**
419+
* Total number of items to process (or total progress required), if known.
420+
*/
421+
total: z.optional(z.number()),
422+
/**
423+
* An optional message describing the current progress.
424+
*/
425+
message: z.optional(z.string())
426+
});
429427

430428
/**
431429
* 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({
622620
* 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.
623621
*/
624622
export const ResourceListChangedNotificationSchema = NotificationSchema.extend({
625-
method: z.literal('notifications/resources/list_changed')
623+
method: z.literal('notifications/resources/list_changed'),
624+
params: z.optional(BaseNotificationParamsSchema)
626625
});
627626

628627
/**
@@ -860,7 +859,8 @@ export const GetPromptResultSchema = ResultSchema.extend({
860859
* 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.
861860
*/
862861
export const PromptListChangedNotificationSchema = NotificationSchema.extend({
863-
method: z.literal('notifications/prompts/list_changed')
862+
method: z.literal('notifications/prompts/list_changed'),
863+
params: z.optional(BaseNotificationParamsSchema)
864864
});
865865

866866
/* Tools */
@@ -1037,7 +1037,8 @@ export const CallToolRequestSchema = RequestSchema.extend({
10371037
* 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.
10381038
*/
10391039
export const ToolListChangedNotificationSchema = NotificationSchema.extend({
1040-
method: z.literal('notifications/tools/list_changed')
1040+
method: z.literal('notifications/tools/list_changed'),
1041+
params: z.optional(BaseNotificationParamsSchema)
10411042
});
10421043

10431044
/* Logging */

0 commit comments

Comments
 (0)