feat: implement generic SendNotification method for Issue #745#844
Open
ajuijas wants to merge 1 commit intomodelcontextprotocol:mainfrom
Open
feat: implement generic SendNotification method for Issue #745#844ajuijas wants to merge 1 commit intomodelcontextprotocol:mainfrom
ajuijas wants to merge 1 commit intomodelcontextprotocol:mainfrom
Conversation
The SDK's middleware stack currently validates outbound notifications against a known set of MCP spec notifications, preventing protocol extensions (e.g., 'ide/diffAccepted') from being sent successfully. This change allows arbitrary JSON-RPC notifications to bypass the strict method checks by internally intercepting an 'x-notifications/' prefix. The SendNotification method is now exposed on both ServerSession and ClientSession to wrap and serialize user-provided parameters. Fixes modelcontextprotocol#745 Signed-off-by: Ijas Ahammed <ijas.ahmd.ap@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The Model Context Protocol (MCP) Go SDK's middleware stack currently validates outbound notifications against a predefined set of protocol methods. This behavior prevents protocol extensions (such as
ide/diffAcceptedor other custom vendor-specific notifications) from being sent successfully, as they are rejected by the internal method validation logic.This change modifies the
mcppackage to support sending arbitrary JSON-RPC notifications by exposing a generic SendNotification method on both ServerSession and ClientSession.Proposed Changes:
x-notifications/prefix, allowing custom methods to bypass strict validation checks while still utilizing the SDK's underlying connection and middleware flow.anypayload types, ensuring they satisfy the internal Params interface and serialize correctly to JSON.Fixes #745