Skip to content

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

OrGivati
Copy link
Contributor

@OrGivati OrGivati commented Apr 25, 2025

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:

Error [ERR_UNHANDLED_ERROR]: Unhandled error. ({
Message received:   error: McpError: MCP error -32601: Method not found: ping

How Has This Been Tested?

Unit test added

Breaking Changes

No breaking changes.

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

Additional context

`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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant