Commit 4645ebf
authored
Server feature list changed and resource updated notifications (#441)
<!-- Provide a brief summary of your changes -->
## Motivation and Context
<!-- Why is this change needed? What problem does it solve? -->
Implemented thread-safe notification service following eventual
consistency principle.
Fixes #249
Contracts:
* If the client connection and feature update happened in the same
thread, the timestamps of the events will be consequent
```
server.connect(client)
server.add(feature)
// client will receive the notification
```
```
server.add(feature)
server.connect(client)
// client will NOT receive the notification
```
* If the client connection and feature update happened in the different
threads, both options can be possible
The flow of the notification is explained in the diagram:
<img width="663" height="413" alt="image"
src="https://github.com/user-attachments/assets/e2c4c108-53dd-408d-97ef-97110ce5c979"
/>
Documentation references:
https://modelcontextprotocol.io/specification/2025-06-18/server/prompts#list-changed-notification
https://modelcontextprotocol.io/specification/2025-06-18/server/tools#list-changed-notification
https://modelcontextprotocol.io/specification/2025-06-18/server/resources#list-changed-notification
https://modelcontextprotocol.io/specification/2025-06-18/server/resources#subscriptions
Questions:
* I haven't found the subscription confirmed response message content
docs, how it should look like?
## How Has This Been Tested?
<!-- Have you tested this in a real application? Which scenarios were
tested? -->
Multiple tests with various notification scenarios were added
## Breaking Changes
<!-- Will users need to update their code or configurations? -->
## Types of changes
<!-- What types of changes does your code introduce? Put an `x` in all
the boxes that apply: -->
- [ ] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)
- [ ] Documentation update
## Checklist
<!-- Go over all the following points, and put an `x` in all the boxes
that apply. -->
- [x] I have read the [MCP
Documentation](https://modelcontextprotocol.io)
- [x] My code follows the repository's style guidelines
- [x] New and existing tests pass locally
- [x] I have added appropriate error handling
- [x] I have added or updated documentation as needed
## Additional context
<!-- Add any other context, implementation notes, or design decisions
-->1 parent cc9b50f commit 4645ebf
File tree
13 files changed
+1307
-60
lines changed- kotlin-sdk-server
- api
- src/commonMain/kotlin/io/modelcontextprotocol/kotlin/sdk/server
- kotlin-sdk-test/src
- commonTest/kotlin/io/modelcontextprotocol/kotlin/sdk/integration
- jvmTest/kotlin/io/modelcontextprotocol/kotlin/sdk/server
13 files changed
+1307
-60
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
| 85 | + | |
| 86 | + | |
85 | 87 | | |
86 | 88 | | |
87 | 89 | | |
| |||
93 | 95 | | |
94 | 96 | | |
95 | 97 | | |
| 98 | + | |
| 99 | + | |
96 | 100 | | |
97 | 101 | | |
98 | 102 | | |
| |||
Lines changed: 373 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 63 additions & 23 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
11 | 19 | | |
12 | 20 | | |
13 | 21 | | |
| |||
33 | 41 | | |
34 | 42 | | |
35 | 43 | | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
36 | 54 | | |
37 | 55 | | |
38 | 56 | | |
39 | 57 | | |
40 | 58 | | |
41 | 59 | | |
42 | 60 | | |
43 | | - | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
44 | 64 | | |
| 65 | + | |
45 | 66 | | |
46 | 67 | | |
47 | 68 | | |
| |||
52 | 73 | | |
53 | 74 | | |
54 | 75 | | |
55 | | - | |
| 76 | + | |
| 77 | + | |
56 | 78 | | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
57 | 83 | | |
58 | 84 | | |
59 | 85 | | |
| |||
66 | 92 | | |
67 | 93 | | |
68 | 94 | | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
76 | 103 | | |
77 | | - | |
| 104 | + | |
| 105 | + | |
78 | 106 | | |
79 | 107 | | |
80 | 108 | | |
| |||
87 | 115 | | |
88 | 116 | | |
89 | 117 | | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
97 | 128 | | |
98 | 129 | | |
99 | 130 | | |
| |||
108 | 139 | | |
109 | 140 | | |
110 | 141 | | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
117 | 146 | | |
| 147 | + | |
118 | 148 | | |
119 | 149 | | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
120 | 160 | | |
Lines changed: 114 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
| 37 | + | |
36 | 38 | | |
37 | 39 | | |
38 | 40 | | |
39 | 41 | | |
| 42 | + | |
40 | 43 | | |
| 44 | + | |
41 | 45 | | |
| 46 | + | |
42 | 47 | | |
43 | 48 | | |
44 | 49 | | |
| |||
58 | 63 | | |
59 | 64 | | |
60 | 65 | | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
61 | 71 | | |
62 | 72 | | |
63 | 73 | | |
| |||
86 | 96 | | |
87 | 97 | | |
88 | 98 | | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | 99 | | |
98 | 100 | | |
99 | 101 | | |
| |||
103 | 105 | | |
104 | 106 | | |
105 | 107 | | |
106 | | - | |
107 | | - | |
108 | | - | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
109 | 112 | | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
110 | 141 | | |
111 | 142 | | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
112 | 147 | | |
113 | 148 | | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
114 | 153 | | |
115 | 154 | | |
116 | 155 | | |
| |||
120 | 159 | | |
121 | 160 | | |
122 | 161 | | |
| 162 | + | |
123 | 163 | | |
124 | 164 | | |
125 | 165 | | |
| |||
182 | 222 | | |
183 | 223 | | |
184 | 224 | | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
185 | 237 | | |
186 | 238 | | |
187 | 239 | | |
188 | 240 | | |
189 | 241 | | |
| 242 | + | |
190 | 243 | | |
191 | 244 | | |
| 245 | + | |
192 | 246 | | |
193 | 247 | | |
194 | 248 | | |
195 | 249 | | |
| 250 | + | |
196 | 251 | | |
197 | 252 | | |
198 | 253 | | |
| |||
484 | 539 | | |
485 | 540 | | |
486 | 541 | | |
487 | | - | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
488 | 561 | | |
489 | 562 | | |
490 | 563 | | |
| |||
518 | 591 | | |
519 | 592 | | |
520 | 593 | | |
521 | | - | |
| 594 | + | |
522 | 595 | | |
523 | 596 | | |
524 | 597 | | |
| |||
534 | 607 | | |
535 | 608 | | |
536 | 609 | | |
537 | | - | |
| 610 | + | |
538 | 611 | | |
539 | 612 | | |
540 | 613 | | |
| |||
550 | 623 | | |
551 | 624 | | |
552 | 625 | | |
553 | | - | |
| 626 | + | |
554 | 627 | | |
555 | 628 | | |
556 | 629 | | |
| |||
675 | 748 | | |
676 | 749 | | |
677 | 750 | | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
678 | 777 | | |
0 commit comments