feat: add optional instructions field to server _oninitialize
This commit is contained in:
parent
29d08ff801
commit
54472d2ae1
1 changed files with 14 additions and 0 deletions
|
|
@ -33,6 +33,11 @@ export type ServerOptions = ProtocolOptions & {
|
|||
* Capabilities to advertise as being supported by this server.
|
||||
*/
|
||||
capabilities: ServerCapabilities;
|
||||
|
||||
/**
|
||||
* Optional instructions describing how to use the server and its features.
|
||||
*/
|
||||
instructions?: string;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -72,6 +77,7 @@ export class Server<
|
|||
private _clientCapabilities?: ClientCapabilities;
|
||||
private _clientVersion?: Implementation;
|
||||
private _capabilities: ServerCapabilities;
|
||||
private _instructions?: string;
|
||||
|
||||
/**
|
||||
* Callback for when initialization has fully completed (i.e., the client has sent an `initialized` notification).
|
||||
|
|
@ -87,6 +93,7 @@ export class Server<
|
|||
) {
|
||||
super(options);
|
||||
this._capabilities = options.capabilities;
|
||||
this._instructions = options.instructions;
|
||||
|
||||
this.setRequestHandler(InitializeRequestSchema, (request) =>
|
||||
this._oninitialize(request),
|
||||
|
|
@ -234,6 +241,7 @@ export class Server<
|
|||
: LATEST_PROTOCOL_VERSION,
|
||||
capabilities: this.getCapabilities(),
|
||||
serverInfo: this._serverInfo,
|
||||
...(this.getInstructions() && { instructions: this.getInstructions() }),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -255,6 +263,10 @@ export class Server<
|
|||
return this._capabilities;
|
||||
}
|
||||
|
||||
private getInstructions(): string | undefined {
|
||||
return this._instructions;
|
||||
}
|
||||
|
||||
async ping() {
|
||||
return this.request({ method: "ping" }, EmptyResultSchema);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue