Skip to content

Conversation

@maxisbey
Copy link
Contributor

@maxisbey maxisbey commented Feb 2, 2026

Replaces the RequestHandler/NotificationHandler wrapper classes with direct on_* keyword arguments on the lowlevel Server constructor.

Changes

  • Delete handler.pyHandler, RequestHandler, NotificationHandler classes removed entirely
  • Server constructor takes on_list_tools, on_call_tool, etc. instead of handlers: Sequence[Handler]. Handlers are raw callables with (ctx, params) -> result signature
  • _add_request_handler / _add_notification_handler for post-construction registration (used by ExperimentalHandlers and MCPServer completion decorator)
  • Remove RequestT generic from Server — the request context type is transport-specific and not known at construction time, so it was never properly bound as a generic
  • Type ServerMessageMetadata.request_context as Any — transport-agnostic
  • Update ExperimentalHandlers to use RequestContext[ServerSession, Any, Any] and the new callback-based registration
  • Update MCPServer to pass on_* kwargs via _create_handler_kwargs()
  • Delete dead func_inspection.py — no longer imported after decorator removal
  • Update migration docs and docstrings throughout

Not included

Tests, examples, and README updates — these were already broken on the base branch before these changes.

Replace the RequestHandler/NotificationHandler wrapper classes with direct
on_* keyword arguments on the Server constructor. Handlers are now raw
callables stored in internal dicts keyed by method string.

- Delete handler.py (Handler, RequestHandler, NotificationHandler)
- Server constructor takes on_list_tools, on_call_tool, etc. instead of
  handlers: Sequence[Handler]
- Add _add_request_handler / _add_notification_handler for post-construction
  registration (used by ExperimentalHandlers and MCPServer completion)
- Remove RequestT generic from Server — the request context type is
  transport-specific and not known at construction time
- Type ServerMessageMetadata.request_context as Any (transport-agnostic)
- Update ExperimentalHandlers to use RequestContext[ServerSession, Any, Any]
- Update MCPServer to pass on_* kwargs via _create_handler_kwargs()
… removal

- Remove func_inspection.py which is no longer imported after decorator removal
- Add migration note about jsonschema input/output validation being removed
  from the lowlevel Server's call_tool handler with no built-in replacement
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