From d474c570e4f346b8fa7f2f42dbcee6b9496f95fa Mon Sep 17 00:00:00 2001 From: Justin Spahr-Summers Date: Mon, 4 Nov 2024 20:45:52 +0000 Subject: [PATCH 1/3] Add basic exercise of `params` typing --- src/cli.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/cli.ts b/src/cli.ts index 8031fcb..f7bc15a 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -9,11 +9,12 @@ import WebSocket from "ws"; import express from "express"; import { Client } from "./client/index.js"; import { SSEClientTransport } from "./client/sse.js"; +import { StdioClientTransport } from "./client/stdio.js"; +import { WebSocketClientTransport } from "./client/websocket.js"; import { Server } from "./server/index.js"; import { SSEServerTransport } from "./server/sse.js"; -import { WebSocketClientTransport } from "./client/websocket.js"; -import { StdioClientTransport } from "./client/stdio.js"; import { StdioServerTransport } from "./server/stdio.js"; +import { ListResourcesResultSchema } from "./types.js"; async function runClient(url_or_command: string, args: string[]) { const client = new Client({ @@ -46,6 +47,8 @@ async function runClient(url_or_command: string, args: string[]) { await client.connect(clientTransport); console.log("Initialized."); + await client.request({ method: "resources/list", params: {} }, ListResourcesResultSchema); + await client.close(); console.log("Closed."); } From f02952aa819297277e42db013a352b616b475615 Mon Sep 17 00:00:00 2001 From: Justin Spahr-Summers Date: Mon, 4 Nov 2024 20:50:01 +0000 Subject: [PATCH 2/3] Fix paginated requests requiring `params` Resolves #21. --- src/cli.ts | 2 +- src/types.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cli.ts b/src/cli.ts index f7bc15a..2713d77 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -47,7 +47,7 @@ async function runClient(url_or_command: string, args: string[]) { await client.connect(clientTransport); console.log("Initialized."); - await client.request({ method: "resources/list", params: {} }, ListResourcesResultSchema); + await client.request({ method: "resources/list" }, ListResourcesResultSchema); await client.close(); console.log("Closed."); diff --git a/src/types.ts b/src/types.ts index 2cdbf9b..aa2c697 100644 --- a/src/types.ts +++ b/src/types.ts @@ -350,7 +350,7 @@ export const PaginatedRequestSchema = RequestSchema.extend({ * If provided, the server should return results starting after this cursor. */ cursor: z.optional(CursorSchema), - }), + }).optional(), }); export const PaginatedResultSchema = ResultSchema.extend({ From bcf9862937aceed28cbb59eff143d4a0224aa203 Mon Sep 17 00:00:00 2001 From: Justin Spahr-Summers Date: Mon, 4 Nov 2024 20:50:12 +0000 Subject: [PATCH 3/3] `progressToken` should be required in progress notifications --- src/types.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/types.ts b/src/types.ts index aa2c697..8fd4786 100644 --- a/src/types.ts +++ b/src/types.ts @@ -338,7 +338,7 @@ export const ProgressNotificationSchema = NotificationSchema.extend({ /** * The progress token which was given in the initial request, used to associate this notification with the request that is proceeding. */ - progressToken: z.optional(ProgressTokenSchema), + progressToken: ProgressTokenSchema, }), });