-
Notifications
You must be signed in to change notification settings - Fork 508
feat(McpAsyncClient): Handle ping request #203
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
Closed
Closed
+34
−0
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
`getRequestURI()` → full request path (without query). `getPathInfo()` → extra path after the servlet's mapping, or null if none. So if I am configuring my Servlet to be mapped on `/somePath` and initiating the Servlet: ``` new HttpServletSseServerTransport(new ObjectMapper(), "/somePath/message", "/somePath/sse") ``` it will work and won't fail. `getPathInfo` will return "/message" and "/sse". while `getRequestURI` will return "/somePath/message" and "/somePath/sse" and will not fail on the validation.
# Conflicts: # mcp/src/main/java/io/modelcontextprotocol/server/transport/HttpServletSseServerTransportProvider.java
tzolov
pushed a commit
that referenced
this pull request
Jun 27, 2025
- Add ping request handler that responds with empty Map instead of null - Ensure compliance with MCP protocol requirement for ping responses - Add test for ping message request handling Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
@OrGivati , thank you for catching this. We've overlooked the client ping requirements. |
Rebased, cherry-picked, squashed, (minor cleaning) and merged at ebb9764 |
tzolov
added a commit
that referenced
this pull request
Jun 28, 2025
- Add ping() method to McpAsyncServerExchange that sends ping requests to clients - Add ping() method to McpSyncServerExchange as synchronous wrapper - Add OBJECT_TYPE_REF constant for ping response type handling - Create McpSyncServerExchangeTests.java with full test coverage - Add ping integration tests across WebFlux, WebMVC, and HttpServlet transports Follow up of #203 Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
9 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add an handler for ping request in MCP client
Motivation and Context
According to the spec, the client and server must respond to
ping
with an empty map.The server already handles
ping
requests.I noticed this behavior is missing when I tested local running FastMCP server against the spring-ai MCP module.
The application failed to load with this error:
Note:
According to the spec, ping should be handled even when the server didn't send initialized message or the client didn't got initialize request.
From that reason, by default I am always adding the ping handler to the client.
How Has This Been Tested?
Unit test added
Breaking Changes
No breaking changes.
Types of changes
Checklist
Additional context
Closes #246