Commit 236c072
committed
feat(core): make Protocol concrete and exported with ProtocolSpec generic
Replaces the setCustom*/sendCustom* API with overloads on setRequestHandler /
setNotificationHandler / request / notification:
- Two-arg spec-method form (existing): handler receives the full request object,
validated by the SDK. Used by Client/Server overrides.
- Three-arg form (new): (method: string, paramsSchema, handler-receives-params).
Accepts any method string; params validated against caller-supplied schema.
Protocol is no longer abstract:
- 5 assert*Capability methods become no-op virtuals; Client/Server override.
- buildContext gets a default implementation returning the BaseContext as-is.
- Protocol<S extends ProtocolSpec, ContextT> — S declares the request/notification
vocabulary (autocomplete reserved for follow-up; runtime path complete).
- McpSpec derived from RequestTypeMap/ResultTypeMap/NotificationTypeMap;
Client/Server extend Protocol<McpSpec, ...>.
This lets MCP-dialect protocols (ext-apps) subclass Protocol directly with no
role enforcement, no wire renames, no setCustom* split — restoring the v1 model
with a cleaner generic shape.
Exports Protocol, ProtocolSpec, McpSpec and InMemoryTransport from core/public.
Tests: customMethods.test.ts rewritten (13 tests covering concrete instantiation,
3-arg overloads, ProtocolSpec, non-Zod StandardSchemaV1). protocol.test.ts and
protocolTransportHandling.test.ts adapted to the new generic position.
Examples: customMethodExample.ts (server + client) rewritten to use the 3-arg
overloads on stock Client/Server. customMethodExtAppsExample.ts rewritten as
class App extends Protocol<AppSpec> mixing ui/* and tools/call on one object.
Docs: migration.md and migration-SKILL.md custom-methods sections updated.1 parent e4cb1a9 commit 236c072
14 files changed
Lines changed: 634 additions & 731 deletions
File tree
- docs
- examples
- client/src
- server/src
- packages
- client/src
- client
- validators
- core
- src
- exports/public
- server/src
- server
- validators
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
377 | 377 | | |
378 | 378 | | |
379 | 379 | | |
380 | | - | |
| 380 | + | |
381 | 381 | | |
382 | 382 | | |
383 | 383 | | |
384 | | - | |
385 | | - | |
386 | | - | |
387 | | - | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
388 | 388 | | |
389 | 389 | | |
390 | 390 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
384 | 384 | | |
385 | 385 | | |
386 | 386 | | |
387 | | - | |
388 | | - | |
| 387 | + | |
389 | 388 | | |
390 | | - | |
| 389 | + | |
391 | 390 | | |
392 | 391 | | |
393 | 392 | | |
394 | 393 | | |
395 | 394 | | |
396 | 395 | | |
397 | | - | |
398 | | - | |
399 | | - | |
400 | | - | |
401 | | - | |
402 | 396 | | |
403 | 397 | | |
404 | 398 | | |
| |||
413 | 407 | | |
414 | 408 | | |
415 | 409 | | |
416 | | - | |
| 410 | + | |
417 | 411 | | |
418 | | - | |
419 | | - | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
420 | 415 | | |
421 | | - | |
| 416 | + | |
422 | 417 | | |
423 | | - | |
424 | | - | |
| 418 | + | |
| 419 | + | |
425 | 420 | | |
426 | 421 | | |
427 | | - | |
| 422 | + | |
428 | 423 | | |
429 | 424 | | |
430 | 425 | | |
431 | 426 | | |
432 | | - | |
433 | | - | |
| 427 | + | |
434 | 428 | | |
435 | | - | |
| 429 | + | |
436 | 430 | | |
437 | 431 | | |
438 | 432 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
13 | 11 | | |
14 | 12 | | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
33 | 16 | | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
40 | 34 | | |
41 | 35 | | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
57 | 39 | | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
| 40 | + | |
| 41 | + | |
70 | 42 | | |
71 | | - | |
| 43 | + | |
| 44 | + | |
72 | 45 | | |
73 | 46 | | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
| 47 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
19 | 9 | | |
20 | 10 | | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
25 | 14 | | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
| 15 | + | |
32 | 16 | | |
33 | 17 | | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
52 | 21 | | |
53 | 22 | | |
54 | | - | |
55 | | - | |
56 | | - | |
| 23 | + | |
| 24 | + | |
57 | 25 | | |
58 | 26 | | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
| 27 | + | |
65 | 28 | | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
97 | 36 | | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
| 37 | + | |
| 38 | + | |
106 | 39 | | |
107 | | - | |
108 | | - | |
| 40 | + | |
| 41 | + | |
109 | 42 | | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
119 | 46 | | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
| 47 | + | |
0 commit comments