Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add support to set server instructions #99

Merged

Conversation

codezjx
Copy link
Contributor

@codezjx codezjx commented Apr 1, 2025

Motivation and Context

Fix #98 , we need to provide a method to set server instructions, which needs to be the same as the python sdk

How Has This Been Tested?

Already tested on sync and async server:

McpSyncServer server = McpServer.sync(transport)
    .serverInfo("stdio-server-example", "1.0.0")
    .instructions("This is a simple MCP server example that provides two tools: xxxx.")
    .tool(xxx)
    .build();

The server can return instructions normally:

20:53:05.009 [pool-1-thread-1] INFO i.m.client.McpAsyncClient - Server response with Protocol: 2024-11-05, Capabilities: ServerCapabilities[experimental=null, logging=LoggingCapabilities[], prompts=null, resources=null, tools=ToolCapabilities[listChanged=false]], Info: Implementation[name=stdio-server-async-example, version=1.0.0] and Instructions This is a simple MCP server example that provides two tools: xxxx.

And the build was success:

[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for Java SDK MCP Parent 0.9.0-SNAPSHOT:
[INFO]
[INFO] Java SDK MCP Parent ................................ SUCCESS [ 0.410 s]
[INFO] Java SDK MCP BOM ................................... SUCCESS [ 0.016 s]
[INFO] Java MCP SDK ....................................... SUCCESS [ 4.308 s]
[INFO] Tests for the Java MCP SDK ......................... SUCCESS [ 0.310 s]
[INFO] WebFlux implementation of the Java MCP SSE transport SUCCESS [ 1.222 s]
[INFO] Spring Web MVC implementation of the Java MCP SSE transport SUCCESS [ 1.101 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.432 s
[INFO] Finished at: 2025-04-01T20:59:09+08:00
[INFO] ------------------------------------------------------------------------

Breaking Changes

Users do not need to modify their original code if they do not need to set instructions

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

@codezjx codezjx changed the title fix: add support to set instructions as mentioned in #98 fix: add support to set server instructions Apr 1, 2025
Copy link
Contributor

@tzolov tzolov left a comment

Choose a reason for hiding this comment

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

LGTM

@tzolov
Copy link
Contributor

tzolov commented Apr 5, 2025

Thank you @codezjx
Nice catch and proper fix.

@tzolov tzolov merged commit 15a55b6 into modelcontextprotocol:main Apr 5, 2025
1 check passed
@tzolov tzolov added the server label Apr 5, 2025
@tzolov tzolov added this to the 0.9.0 milestone Apr 5, 2025
@codezjx
Copy link
Contributor Author

codezjx commented Apr 7, 2025

@tzolov Happy to contribute! Thanks for the quick merge 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to set server instructions, always null
2 participants