Skip to content

Commit d4df402

Browse files
committed
feat(server): add ability to retrieve server instructions
1 parent 2acab9b commit d4df402

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

mcp/src/main/java/io/modelcontextprotocol/server/McpAsyncServer.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import org.slf4j.LoggerFactory;
3636
import reactor.core.publisher.Flux;
3737
import reactor.core.publisher.Mono;
38+
import reactor.util.annotation.Nullable;
3839

3940
/**
4041
* The Model Context Protocol (MCP) server implementation that provides asynchronous
@@ -236,6 +237,15 @@ public McpSchema.Implementation getServerInfo() {
236237
return this.serverInfo;
237238
}
238239

240+
/**
241+
* Get the server instructions if available
242+
* @return The preset instructions for communication with the server
243+
*/
244+
@Nullable
245+
public String getInstructions() {
246+
return this.instructions;
247+
}
248+
239249
/**
240250
* Gracefully closes the server, allowing any in-progress operations to complete.
241251
* @return A Mono that completes when the server has been closed

mcp/src/main/java/io/modelcontextprotocol/server/McpSyncServer.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import io.modelcontextprotocol.spec.McpSchema;
88
import io.modelcontextprotocol.spec.McpSchema.LoggingMessageNotification;
99
import io.modelcontextprotocol.util.Assert;
10+
import reactor.util.annotation.Nullable;
1011

1112
/**
1213
* A synchronous implementation of the Model Context Protocol (MCP) server that wraps
@@ -134,6 +135,15 @@ public McpSchema.Implementation getServerInfo() {
134135
return this.asyncServer.getServerInfo();
135136
}
136137

138+
/**
139+
* Get the server instructions if available
140+
* @return The preset instructions for communication with the server
141+
*/
142+
@Nullable
143+
public String getInstructions() {
144+
return this.getAsyncServer().getInstructions();
145+
}
146+
137147
/**
138148
* Notify clients that the list of available resources has changed.
139149
*/

0 commit comments

Comments
 (0)