Skip to content

Conversation

@A-afflatus
Copy link
Contributor

@A-afflatus A-afflatus commented May 20, 2025

Motivation and Context

  • ​​Problem​​: When using the typescript-sdk's StreamableHttp server (from src/examples/server/simpleStreamableHttp.ts), requests from rust-sdk clients would return 406 errors, making the service unusable for these clients.
    ​​- Root Cause​​: The server's Accept header validation was too strict, rejecting valid requests from certain SDK implementations.
    ​​- Solution​​: By merging and properly handling Accept headers, we maintain compatibility across different SDK implementations while preserving the expected behavior.

How Has This Been Tested?

  • Modified the typescript-sdk and verified using the rust-sdk client example (examples/clients/src/streamable_http.rs)
  • Confirmed that:
    • 406 errors no longer occur for valid requests
    • Standard JSON requests (Accept: application/json) continue to work as expected
    • The service remains stable with different Accept header variations

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

issue:

image

after repair:

image

@4t145
Copy link
Collaborator

4t145 commented May 20, 2025

Thanks a lot! Could you fix the clippy and fmt failure?

cargo clippy --fix --all-targets --all-features
cargo +nightly fmt --all

@A-afflatus A-afflatus changed the title fix: resolve the server 406 error in API calls (406 is an HTTP "Not A… fix: resolve the server 406 error in API calls May 21, 2025
@A-afflatus
Copy link
Contributor Author

@4t145 done

@4t145 4t145 merged commit 8222e18 into modelcontextprotocol:main May 21, 2025
9 checks passed
@github-actions github-actions bot mentioned this pull request Jul 2, 2025
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.

2 participants