Update client and server convenience methods

This commit is contained in:
Justin Spahr-Summers 2024-11-06 11:46:55 +00:00
commit 099c2e2be3
No known key found for this signature in database
2 changed files with 30 additions and 0 deletions

View file

@ -29,6 +29,8 @@ import {
ListToolsResultSchema,
EmptyResultSchema,
LoggingLevel,
ListResourceTemplatesRequest,
ListResourceTemplatesResultSchema,
} from "../types.js";
/**
@ -177,6 +179,17 @@ export class Client<
);
}
async listResourceTemplates(
params?: ListResourceTemplatesRequest["params"],
onprogress?: ProgressCallback,
) {
return this.request(
{ method: "resources/templates/list", params },
ListResourceTemplatesResultSchema,
onprogress,
);
}
async readResource(
params: ReadResourceRequest["params"],
onprogress?: ProgressCallback,
@ -223,4 +236,8 @@ export class Client<
onprogress,
);
}
async sendRootsListChanged() {
return this.notification({ method: "notifications/roots/list_changed" });
}
}

View file

@ -23,6 +23,8 @@ import {
EmptyResultSchema,
LoggingMessageNotification,
ResourceUpdatedNotification,
ListRootsRequest,
ListRootsResultSchema,
} from "../types.js";
/**
@ -154,6 +156,17 @@ export class Server<
);
}
async listRoots(
params?: ListRootsRequest["params"],
onprogress?: ProgressCallback,
) {
return this.request(
{ method: "roots/list", params },
ListRootsResultSchema,
onprogress,
);
}
async sendLoggingMessage(params: LoggingMessageNotification["params"]) {
return this.notification({ method: "notifications/message", params });
}