Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/server/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ test("should accept latest protocol version", async () => {
name: "test server",
version: "1.0",
},
instructions: "Test instructions",
});
sendPromiseResolve(undefined);
}
Expand All @@ -57,6 +58,7 @@ test("should accept latest protocol version", async () => {
tools: {},
logging: {},
},
instructions: "Test instructions",
},
);

Expand Down
12 changes: 12 additions & 0 deletions src/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

/**
Expand Down Expand Up @@ -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).
Expand All @@ -87,6 +93,7 @@ export class Server<
) {
super(options);
this._capabilities = options.capabilities;
this._instructions = options.instructions;

this.setRequestHandler(InitializeRequestSchema, (request) =>
this._oninitialize(request),
Expand Down Expand Up @@ -234,6 +241,7 @@ export class Server<
: LATEST_PROTOCOL_VERSION,
capabilities: this.getCapabilities(),
serverInfo: this._serverInfo,
...(this.getInstructions() && { instructions: this.getInstructions() }),
};
}

Expand All @@ -255,6 +263,10 @@ export class Server<
return this._capabilities;
}

private getInstructions(): string | undefined {
return this._instructions;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we please remove this? I don't think there's any benefit to a private getter in this case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, removed and updated!


async ping() {
return this.request({ method: "ping" }, EmptyResultSchema);
}
Expand Down