Remove explicit constants of method names, factor out ProgressSchema

This commit is contained in:
Justin Spahr-Summers 2024-10-02 14:47:55 +01:00
commit 4be31d0f08
No known key found for this signature in database
GPG key ID: E78498BF3C053CA7

View file

@ -8,10 +8,10 @@ import {
McpError,
METHOD_NOT_FOUND,
Notification,
PING_REQUEST_METHOD,
PingRequestSchema,
Progress,
PROGRESS_NOTIFICATION_METHOD,
ProgressNotification,
ProgressNotificationSchema,
Request,
Result,
} from "../types.js";
@ -78,14 +78,14 @@ export class Protocol<
constructor() {
this.setNotificationHandler(
PROGRESS_NOTIFICATION_METHOD,
ProgressNotificationSchema.shape.method.value,
(notification) => {
this._onprogress(notification as unknown as ProgressNotification);
},
);
this.setRequestHandler(
PING_REQUEST_METHOD,
PingRequestSchema.shape.method.value,
// Automatic pong by default.
(_request) => ({}) as SendResultT,
);