Convenience methods for Server
This commit is contained in:
parent
3d32ce69df
commit
a9b6ae6679
1 changed files with 41 additions and 0 deletions
|
|
@ -18,6 +18,11 @@ import {
|
|||
ListToolsRequestSchema,
|
||||
ListPromptsRequestSchema,
|
||||
SetLevelRequestSchema,
|
||||
CreateMessageRequest,
|
||||
CreateMessageResultSchema,
|
||||
EmptyResultSchema,
|
||||
LoggingMessageNotification,
|
||||
ResourceUpdatedNotification,
|
||||
} from "../types.js";
|
||||
|
||||
/**
|
||||
|
|
@ -133,4 +138,40 @@ export class Server<
|
|||
: undefined,
|
||||
};
|
||||
}
|
||||
|
||||
async ping() {
|
||||
return this.request({ method: "ping" }, EmptyResultSchema);
|
||||
}
|
||||
|
||||
async createMessage(params: CreateMessageRequest["params"]) {
|
||||
return this.request(
|
||||
{ method: "sampling/createMessage", params },
|
||||
CreateMessageResultSchema,
|
||||
);
|
||||
}
|
||||
|
||||
async sendLoggingMessage(params: LoggingMessageNotification["params"]) {
|
||||
return this.notification({ method: "notifications/message", params });
|
||||
}
|
||||
|
||||
async sendResourceUpdated(params: ResourceUpdatedNotification["params"]) {
|
||||
return this.notification({
|
||||
method: "notifications/resources/updated",
|
||||
params,
|
||||
});
|
||||
}
|
||||
|
||||
async sendResourceListChanged() {
|
||||
return this.notification({
|
||||
method: "notifications/resources/list_changed",
|
||||
});
|
||||
}
|
||||
|
||||
async sendToolListChanged() {
|
||||
return this.notification({ method: "notifications/tools/list_changed" });
|
||||
}
|
||||
|
||||
async sendPromptListChanged() {
|
||||
return this.notification({ method: "notifications/prompts/list_changed" });
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue