Skip to content

Commit f8e5faf

Browse files
Merge pull request #120 from kalvinnchau/instruction-support
feat: add optional instructions field to server _oninitialize
2 parents 29d08ff + 1bb51d0 commit f8e5faf

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

Diff for: src/server/index.test.ts

+2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ test("should accept latest protocol version", async () => {
3838
name: "test server",
3939
version: "1.0",
4040
},
41+
instructions: "Test instructions",
4142
});
4243
sendPromiseResolve(undefined);
4344
}
@@ -57,6 +58,7 @@ test("should accept latest protocol version", async () => {
5758
tools: {},
5859
logging: {},
5960
},
61+
instructions: "Test instructions",
6062
},
6163
);
6264

Diff for: src/server/index.ts

+8
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ export type ServerOptions = ProtocolOptions & {
3333
* Capabilities to advertise as being supported by this server.
3434
*/
3535
capabilities: ServerCapabilities;
36+
37+
/**
38+
* Optional instructions describing how to use the server and its features.
39+
*/
40+
instructions?: string;
3641
};
3742

3843
/**
@@ -72,6 +77,7 @@ export class Server<
7277
private _clientCapabilities?: ClientCapabilities;
7378
private _clientVersion?: Implementation;
7479
private _capabilities: ServerCapabilities;
80+
private _instructions?: string;
7581

7682
/**
7783
* Callback for when initialization has fully completed (i.e., the client has sent an `initialized` notification).
@@ -87,6 +93,7 @@ export class Server<
8793
) {
8894
super(options);
8995
this._capabilities = options.capabilities;
96+
this._instructions = options.instructions;
9097

9198
this.setRequestHandler(InitializeRequestSchema, (request) =>
9299
this._oninitialize(request),
@@ -234,6 +241,7 @@ export class Server<
234241
: LATEST_PROTOCOL_VERSION,
235242
capabilities: this.getCapabilities(),
236243
serverInfo: this._serverInfo,
244+
...(this._instructions && { instructions: this._instructions }),
237245
};
238246
}
239247

0 commit comments

Comments
 (0)