Title: fix: improve compatibility with non-compliant MCP servers by tzolov · Pull Request #413 · modelcontextprotocol/java-sdk · GitHub
Open Graph Title: fix: improve compatibility with non-compliant MCP servers by tzolov · Pull Request #413 · modelcontextprotocol/java-sdk
X Title: fix: improve compatibility with non-compliant MCP servers by tzolov · Pull Request #413 · modelcontextprotocol/java-sdk
Description: Addresses issues with servers like Shopify that violate MCP/HTTP specs: Prioritize application/json in Accept headers to fix content-type issues Handle empty notification bodies ({}) that should be bodiless per spec Add status code validation and null safety improvements Resolves #406 Improves HTTP transport robustness to handle non-compliant MCP servers that violate MCP and HTTP specifications. Motivation and Context This change addresses compatibility issues with real-world MCP servers that don't strictly follow MCP and HTTP specifications. Specifically, the Shopify MCP server exhibits two problematic behaviors: Incorrect content-type negotiation: Returns text/streamable content-type when the Accept header prioritizes text/stream over application/json, but correctly returns application/json when the latter is first MCP spec violation: Sends empty JSON bodies ({}) for notification messages that should be bodiless according to the MCP specification These violations cause the Java SDK to fail when communicating with such servers, limiting its real-world applicability. How Has This Been Tested? Tested against the Shopify MCP server that exhibits the problematic behaviors Verified that existing compliant servers continue to work correctly Tested both WebFlux and standard HTTP client transport implementations Validated proper handling of empty responses and status code validation Breaking Changes No breaking changes. This is a backward-compatible improvement that maintains existing API contracts while adding robustness. 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
Open Graph Description: Addresses issues with servers like Shopify that violate MCP/HTTP specs: Prioritize application/json in Accept headers to fix content-type issues Handle empty notification bodies ({}) that should b...
X Description: Addresses issues with servers like Shopify that violate MCP/HTTP specs: Prioritize application/json in Accept headers to fix content-type issues Handle empty notification bodies ({}) that should b...
Opengraph URL: https://github.com/modelcontextprotocol/java-sdk/pull/413
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:84212863-2e5a-2235-d221-88111e0245cb |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 828A:3068F7:10ECAE:17CB99:6A5F0D3F |
| html-safe-nonce | 47cbacacc68c5b5630cdd39e7cff6b8ca6490fde046f7bcbe0f43a5ffa937b34 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MjhBOjMwNjhGNzoxMEVDQUU6MTdDQjk5OjZBNUYwRDNGIiwidmlzaXRvcl9pZCI6IjY0NTM3ODI3OTE3OTMzNDc5MDMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | a98dee7103dc80bcd4d9bcf8cd5f740c39a79f310d35a77b427b594695d022bd |
| hovercard-subject-tag | pull_request:2677168112 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/modelcontextprotocol/java-sdk/pull/413/files |
| twitter:image | https://avatars.githubusercontent.com/u/1351573?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/1351573?s=400&v=4 |
| og:image:alt | Addresses issues with servers like Shopify that violate MCP/HTTP specs: Prioritize application/json in Accept headers to fix content-type issues Handle empty notification bodies ({}) that should b... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | bf8fa4b42b6d150def6175efb9b0f1ec8e9628d7229ee2bdf6e850e7bdad923e |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/modelcontextprotocol/java-sdk git https://github.com/modelcontextprotocol/java-sdk.git |
| octolytics-dimension-user_id | 182288589 |
| octolytics-dimension-user_login | modelcontextprotocol |
| octolytics-dimension-repository_id | 919609219 |
| octolytics-dimension-repository_nwo | modelcontextprotocol/java-sdk |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 919609219 |
| octolytics-dimension-repository_network_root_nwo | modelcontextprotocol/java-sdk |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 7debc3c6cd5de09c6e22b47a1b9982acb2aabb7b |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width