Skip to content

fix: improve MCP version mismatch detection and error messages#360

Closed
zemaj wants to merge 1 commit into
mainfrom
code-claude-sonnet-4-5-implement-292-mcp
Closed

fix: improve MCP version mismatch detection and error messages#360
zemaj wants to merge 1 commit into
mainfrom
code-claude-sonnet-4-5-implement-292-mcp

Conversation

@zemaj

@zemaj zemaj commented Oct 28, 2025

Copy link
Copy Markdown

Summary

This PR addresses issue #292 by improving MCP version mismatch detection and error messages in the rmcp-client handshake process.

Changes

  • Enhanced error messages: All handshake errors now include the expected MCP protocol version (MCP_SCHEMA_VERSION) to help users quickly identify version compatibility issues
  • Explicit version validation: After successful handshake conversion, the client now explicitly compares the server's protocol version with the expected version
  • Clear mismatch error: When versions don't match, users receive a clear, actionable error message explaining the mismatch and suggesting they ensure compatibility
  • Test coverage: Added a unit test to verify MCP_SCHEMA_VERSION is accessible and properly formatted

Technical Details

Modified code-rs/rmcp-client/src/rmcp_client.rs:

  • Import MCP_SCHEMA_VERSION from mcp_types
  • Update handshake error messages to include expected protocol version
  • Add explicit version comparison after handshake (lines 169-176)
  • Add type annotation to initialize_result for proper type inference
  • Add test module with version constant validation

Testing

  • ./build-fast.sh passes
  • ✅ Added unit test for MCP_SCHEMA_VERSION format validation

Risk Assessment

Low risk: Changes are minimal and defensive:

  • Only affects error messages and adds a new validation check
  • Does not modify existing behavior for successful handshakes with matching versions
  • Early failure (explicit version check) is better than silent mismatch
  • Type annotation fix is a compile-time improvement

Related Issue

Fixes #292

🤖 Generated with Claude Code

Addresses #292 by enhancing error reporting and validation in the MCP
handshake process:

- Add MCP_SCHEMA_VERSION to handshake error messages to help users
  identify version compatibility issues
- Implement explicit protocol version comparison after successful
  handshake conversion to detect version mismatches
- Add clear, actionable error message when server and client versions
  don't match
- Include test to verify MCP_SCHEMA_VERSION constant is accessible

This helps prevent confusion when MCP servers and clients are running
incompatible protocol versions.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@zemaj zemaj force-pushed the main branch 2 times, most recently from 804b5ad to b7927a2 Compare October 28, 2025 23:57
@zemaj

zemaj commented Oct 29, 2025

Copy link
Copy Markdown
Author

Closing in favor of PR #361, which supersedes these changes and includes the schema-format test from this branch.

@zemaj zemaj closed this Oct 29, 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.

Latest release: 0.2.174 → 0.42.0 Incorrectly matched Codex version

1 participant