Skip to content

Commit

Permalink
Merge pull request #32 from modelcontextprotocol/justin/fix-params-types
Browse files Browse the repository at this point in the history
Fix `params` being required on paginated requests
  • Loading branch information
jspahrsummers authored Nov 4, 2024
2 parents 9b4c949 + bcf9862 commit bfb6ffc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -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" }, ListResourcesResultSchema);

await client.close();
console.log("Closed.");
}
Expand Down
4 changes: 2 additions & 2 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}),
});

Expand All @@ -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({
Expand Down

0 comments on commit bfb6ffc

Please sign in to comment.