feat: add ignorable JSON-RPC methods support for both client and server #417
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.
This feature allows both MCP clients and servers to gracefully handle unknown or unwanted JSON-RPC methods without generating errors, improving compatibility with various implementations and reducing log noise.
Resolves #416, #377
Related to #130 It provides a workaround until the
notification/cancelled
is supposed.Motivation and Context
This change addresses the need for more robust MCP communication by allowing clients and servers to ignore specific JSON-RPC methods rather than generating error responses. This is particularly useful for:
How Has This Been Tested?
AbstractMcpAsyncClientTests
,AbstractMcpSyncClientTests
)AbstractMcpAsyncServerTests
,AbstractMcpSyncServerTests
)McpClientSessionTests
,McpServerSessionTests
)Breaking Changes
This is a non-breaking change. All existing APIs remain unchanged, and the new functionality is opt-in through builder methods. Default behavior is preserved with a predefined list of commonly ignorable methods.
Types of changes
Checklist
Additional context
Implementation Details:
Utils.DEFAULT_IGNORABLE_JSON_RPC_METHODS
constant with default methods: "notifications/cancelled" and "notifications/stderr"