Skip to content

Report failed session notifications through the server configuration - #631

Open
koic wants to merge 1 commit into
modelcontextprotocol:mainfrom
koic:report_failed_session_notifications_through_the_server_configuration
Open

koic wants to merge 1 commit into
modelcontextprotocol:mainfrom
koic:report_failed_session_notifications_through_the_server_configuration

Conversation

@koic

@koic koic commented Oct 24, 2026

Copy link
Copy Markdown
Member

Motivation and Context

ServerSession#notify_progress, #notify_log_message, #notify_resources_updated and #notify_elicitation_complete rescue a transport failure and pass it to @server.report_exception, which is private, so the rescue itself raised NoMethodError. The failure meant to be reported and swallowed reached the caller instead, typically a tool reporting progress or logging, whose call then answered Internal error.

The rescues now call exception_reporter of the server's configuration, which is what Server#report_exception does, without making that method public.

How Has This Been Tested?

test/mcp/server_notification_test.rb. Against the previous library the new test fails with NoMethodError: private method 'report_exception' called for an instance of MCP::Server.

Breaking Changes

None.

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

## Motivation and Context

`ServerSession#notify_progress`, `#notify_log_message`, `#notify_resources_updated` and
`#notify_elicitation_complete` rescue a transport failure and pass it to `@server.report_exception`, which is
private, so the rescue itself raised `NoMethodError`. The failure meant to be reported and swallowed reached
the caller instead, typically a tool reporting progress or logging, whose call then answered Internal error.

The rescues now call `exception_reporter` of the server's configuration, which is what
`Server#report_exception` does, without making that method public.

## How Has This Been Tested?

`test/mcp/server_notification_test.rb`. Against the previous library the new test fails with
`NoMethodError: private method 'report_exception' called for an instance of MCP::Server`.

## Breaking Changes

None.

This branch has not been deployed

No deployments
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