Commit 10766c8
committed
refactor: replace Handler objects with on_* constructor kwargs
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()1 parent f10995e commit 10766c8
File tree
8 files changed
+199
-357
lines changed- docs
- src/mcp
- server
- experimental
- lowlevel
- mcpserver
8 files changed
+199
-357
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
426 | 426 | | |
427 | 427 | | |
428 | 428 | | |
429 | | - | |
| 429 | + | |
430 | 430 | | |
431 | | - | |
| 431 | + | |
432 | 432 | | |
433 | 433 | | |
434 | 434 | | |
| |||
449 | 449 | | |
450 | 450 | | |
451 | 451 | | |
452 | | - | |
| 452 | + | |
453 | 453 | | |
454 | 454 | | |
455 | 455 | | |
| |||
477 | 477 | | |
478 | 478 | | |
479 | 479 | | |
480 | | - | |
481 | | - | |
482 | | - | |
483 | | - | |
| 480 | + | |
| 481 | + | |
484 | 482 | | |
485 | 483 | | |
486 | 484 | | |
487 | 485 | | |
488 | 486 | | |
489 | 487 | | |
490 | 488 | | |
491 | | - | |
492 | 489 | | |
493 | 490 | | |
494 | 491 | | |
495 | 492 | | |
496 | | - | |
| 493 | + | |
497 | 494 | | |
498 | 495 | | |
499 | 496 | | |
| |||
504 | 501 | | |
505 | 502 | | |
506 | 503 | | |
507 | | - | |
508 | | - | |
509 | | - | |
| 504 | + | |
510 | 505 | | |
511 | 506 | | |
512 | 507 | | |
| |||
555 | 550 | | |
556 | 551 | | |
557 | 552 | | |
558 | | - | |
| 553 | + | |
559 | 554 | | |
560 | 555 | | |
561 | 556 | | |
| |||
573 | 568 | | |
574 | 569 | | |
575 | 570 | | |
576 | | - | |
| 571 | + | |
577 | 572 | | |
578 | 573 | | |
579 | | - | |
580 | | - | |
581 | | - | |
582 | | - | |
583 | | - | |
584 | | - | |
585 | | - | |
586 | | - | |
587 | | - | |
| 574 | + | |
588 | 575 | | |
| 576 | + | |
| 577 | + | |
589 | 578 | | |
590 | 579 | | |
591 | 580 | | |
| |||
623 | 612 | | |
624 | 613 | | |
625 | 614 | | |
626 | | - | |
| 615 | + | |
627 | 616 | | |
628 | 617 | | |
629 | 618 | | |
| |||
634 | 623 | | |
635 | 624 | | |
636 | 625 | | |
637 | | - | |
638 | | - | |
639 | | - | |
| 626 | + | |
640 | 627 | | |
641 | 628 | | |
642 | 629 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | | - | |
56 | | - | |
57 | | - | |
| 55 | + | |
58 | 56 | | |
59 | 57 | | |
60 | 58 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | 1 | | |
3 | 2 | | |
4 | | - | |
| 3 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
51 | | - | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
52 | 54 | | |
53 | 55 | | |
54 | | - | |
| 56 | + | |
55 | 57 | | |
56 | 58 | | |
57 | 59 | | |
| |||
124 | 126 | | |
125 | 127 | | |
126 | 128 | | |
127 | | - | |
| 129 | + | |
128 | 130 | | |
129 | 131 | | |
130 | 132 | | |
| |||
139 | 141 | | |
140 | 142 | | |
141 | 143 | | |
142 | | - | |
| 144 | + | |
143 | 145 | | |
144 | 146 | | |
145 | 147 | | |
146 | 148 | | |
147 | | - | |
| 149 | + | |
148 | 150 | | |
149 | 151 | | |
150 | 152 | | |
151 | 153 | | |
152 | 154 | | |
153 | 155 | | |
154 | | - | |
| 156 | + | |
155 | 157 | | |
156 | 158 | | |
157 | 159 | | |
158 | 160 | | |
159 | | - | |
| 161 | + | |
160 | 162 | | |
161 | 163 | | |
162 | 164 | | |
163 | 165 | | |
164 | 166 | | |
165 | | - | |
| 167 | + | |
166 | 168 | | |
167 | 169 | | |
168 | 170 | | |
169 | 171 | | |
170 | | - | |
| 172 | + | |
171 | 173 | | |
172 | 174 | | |
173 | 175 | | |
174 | 176 | | |
175 | | - | |
| 177 | + | |
0 commit comments