add server capabilities derivation

This commit is contained in:
Ashwin Bhat 2024-10-15 17:08:08 -07:00
commit bcb4b219ee
No known key found for this signature in database

15
dist/server/index.js generated vendored
View file

@ -1,5 +1,5 @@
import { Protocol } from "../shared/protocol.js";
import { InitializedNotificationSchema, InitializeRequestSchema, PROTOCOL_VERSION, } from "../types.js";
import { InitializedNotificationSchema, InitializeRequestSchema, PROTOCOL_VERSION, ListResourcesRequestSchema, ListToolsRequestSchema, ListPromptsRequestSchema, SetLevelRequestSchema, } from "../types.js";
/**
* An MCP server on top of a pluggable transport.
*
@ -23,7 +23,7 @@ export class Server extends Protocol {
this._clientVersion = request.params.clientInfo;
return {
protocolVersion: PROTOCOL_VERSION,
capabilities: {},
capabilities: this.getCapabilities(),
serverInfo: this._serverInfo,
};
}
@ -39,5 +39,16 @@ export class Server extends Protocol {
getClientVersion() {
return this._clientVersion;
}
getCapability(reqType) {
return this._requestHandlers.has(reqType) ? {} : undefined;
}
getCapabilities() {
return {
prompts: this.getCapability(ListPromptsRequestSchema.shape.method.value),
resources: this.getCapability(ListResourcesRequestSchema.shape.method.value),
tools: this.getCapability(ListToolsRequestSchema.shape.method.value),
logging: this.getCapability(SetLevelRequestSchema.shape.method.value),
};
}
}
//# sourceMappingURL=index.js.map