Skip to content

sketch: refactor lowlevel server to handler pattern#1968

Closed
maxisbey wants to merge 17 commits into
mainfrom
sketch/lowlevel-server-v2
Closed

sketch: refactor lowlevel server to handler pattern#1968
maxisbey wants to merge 17 commits into
mainfrom
sketch/lowlevel-server-v2

Conversation

@maxisbey
Copy link
Copy Markdown
Contributor

Replaces decorator-based handler registration with RequestHandler/NotificationHandler classes.

Changes

  • New files: request_handler.py and notification_handler.py with typed overloaded constructors
  • Server dispatch: type(req)req.method (string-based dispatch)
  • Handler dicts: dict[type, Callable]dict[str, RequestHandler] / dict[str, NotificationHandler]
  • Registration: Decorator methods → constructor handlers list + add_handler() method
  • Context: RequestContext built and passed directly to handlers; request_ctx contextvar removed
  • Removed: All 12 decorator methods, tool cache, _make_error_result, _get_cached_tool_definition, new_server.py sketch

Known breakages

  • MCPServer._setup_handlers() — calls removed decorator methods
  • ExperimentalHandlers — writes to handler dicts with type keys
  • All lowlevel server tests — use decorator pattern
  • All examples — use decorator pattern

Loading
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