Skip to content

mcp: add ErrorHandler to ServerOptions#865

Open
ravyg wants to merge 1 commit intomodelcontextprotocol:mainfrom
ravyg:feat/218-error-handler
Open

mcp: add ErrorHandler to ServerOptions#865
ravyg wants to merge 1 commit intomodelcontextprotocol:mainfrom
ravyg:feat/218-error-handler

Conversation

@ravyg
Copy link
Copy Markdown

@ravyg ravyg commented Mar 27, 2026

Add an optional ErrorHandler callback to ServerOptions for receiving
out-of-band errors that occur during server operation but are not
associated with a specific request.

Error sources wired to the handler:

  • Keepalive ping failures (previously silently dropped)
  • Notification delivery errors (previously logged as warnings)
  • Internal JSON-RPC protocol errors (previously printed via log.Printf)

When ErrorHandler is nil, existing behavior is preserved — errors are
logged at the appropriate level.

Thanks to @findleyr and @jba for the design discussion on this issue.

Fixes #218

Add an optional ErrorHandler callback to ServerOptions for receiving
out-of-band errors that occur during server operation. These include
keepalive ping failures, notification delivery errors, and internal
JSON-RPC protocol errors.

When ErrorHandler is nil, errors continue to be logged at the
appropriate level using the configured Logger.

Fixes modelcontextprotocol#218
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.

Proposal: add ErrorHandler to ServerOptions

1 participant