fix: resolve compatibility issues with servers sending LSP notifications #413
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.
Resolves connection closed errors during initialization with mixed-protocol servers.
Motivation and Context
Certain MCP servers (like 21Magic) send LSP (Language Server Protocol) notifications such as
window/logMessagefor IDE integration purposes. These messages, while valid JSON-RPC 2.0, are not part of the MCP specification and cause the Rust SDK to fail parsing, resulting in connection termination.This change implements graceful handling of non-MCP notifications while maintaining strict parsing for actual MCP messages, ensuring compatibility with servers that send mixed protocol messages for enhanced IDE integration.
How Has This Been Tested?
Breaking Changes
None. This is a backward-compatible fix that only affects error handling paths. All existing MCP servers continue to work without any changes required.
Types of changes
Checklist
Additional context
Implementation Details:
is_standard_method()function based on MCP specification 2025-06-18should_ignore_notification()helper for compatibility checkstry_parse_with_compatibility()to handle mixed-protocol scenariostracelevel logging for ignored messages to avoid log pollutionDesign Decisions:
idfield) are subject to lenient parsingmatches!macro for consistencyThis fix enables broader MCP ecosystem compatibility, particularly with servers that integrate with IDEs through LSP messages while maintaining full protocol compliance for standard MCP operations.