Commit bf8dc6d
feat(core): add extensions field to ClientCapabilities and ServerCapabilities (#678)
<!-- Provide a brief summary of your changes -->
Add support for MCP extension negotiation during the initialize
handshake, as defined in the MCP extensions specification. Clients and
servers can now advertise supported extensions via a new `extensions:
Map<String, JsonObject>?` field on their respective capabilities
objects.
## Motivation and Context
<!-- Why is this change needed? What problem does it solve? -->
Extensions are supported part of the [MCP spec
](https://modelcontextprotocol.io/extensions/overview) and are available
in other language libraries e.g. [Golang
](https://github.com/modelcontextprotocol/go-sdk/blob/862d78a265cb1f1b9692ff49cfb8bfd109b6ebc9/mcp/protocol.go#L215).
## How Has This Been Tested?
Existing and added unit tests
## Breaking Changes
<!-- Will users need to update their code or configurations? -->
Adding a new field to existing ClientCapabilities and ServerCapabilities
fields will break already compiled clients. They will need to recompile
on upgrading.
## 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
-->
Co-authored-by: Pavel Gorgulov <devcrocod@gmail.com>1 parent f6ad332 commit bf8dc6d
6 files changed
Lines changed: 217 additions & 8 deletions
File tree
- kotlin-sdk-core
- api
- src
- commonMain/kotlin/io/modelcontextprotocol/kotlin/sdk/types
- commonTest/kotlin/io/modelcontextprotocol/kotlin/sdk/types
- dsl
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
606 | 606 | | |
607 | 607 | | |
608 | 608 | | |
609 | | - | |
610 | | - | |
| 609 | + | |
| 610 | + | |
611 | 611 | | |
612 | 612 | | |
613 | 613 | | |
614 | 614 | | |
615 | | - | |
616 | | - | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
617 | 618 | | |
618 | 619 | | |
619 | 620 | | |
| 621 | + | |
620 | 622 | | |
621 | 623 | | |
622 | 624 | | |
| |||
676 | 678 | | |
677 | 679 | | |
678 | 680 | | |
| 681 | + | |
679 | 682 | | |
680 | 683 | | |
681 | 684 | | |
| |||
4245 | 4248 | | |
4246 | 4249 | | |
4247 | 4250 | | |
4248 | | - | |
4249 | | - | |
| 4251 | + | |
| 4252 | + | |
4250 | 4253 | | |
4251 | 4254 | | |
4252 | 4255 | | |
4253 | 4256 | | |
4254 | 4257 | | |
4255 | 4258 | | |
4256 | | - | |
4257 | | - | |
| 4259 | + | |
| 4260 | + | |
| 4261 | + | |
4258 | 4262 | | |
4259 | 4263 | | |
4260 | 4264 | | |
| 4265 | + | |
4261 | 4266 | | |
4262 | 4267 | | |
4263 | 4268 | | |
| |||
kotlin-sdk-core/src/commonMain/kotlin/io/modelcontextprotocol/kotlin/sdk/types/capabilities.dsl.kt
Lines changed: 26 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| 42 | + | |
42 | 43 | | |
43 | 44 | | |
44 | 45 | | |
| |||
132 | 133 | | |
133 | 134 | | |
134 | 135 | | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
135 | 160 | | |
136 | 161 | | |
137 | 162 | | |
| |||
177 | 202 | | |
178 | 203 | | |
179 | 204 | | |
| 205 | + | |
180 | 206 | | |
181 | 207 | | |
182 | 208 | | |
Lines changed: 8 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
48 | 51 | | |
49 | 52 | | |
50 | 53 | | |
51 | 54 | | |
52 | 55 | | |
53 | 56 | | |
54 | 57 | | |
| 58 | + | |
55 | 59 | | |
56 | 60 | | |
57 | 61 | | |
| |||
93 | 97 | | |
94 | 98 | | |
95 | 99 | | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
96 | 103 | | |
97 | 104 | | |
98 | 105 | | |
| |||
102 | 109 | | |
103 | 110 | | |
104 | 111 | | |
| 112 | + | |
105 | 113 | | |
106 | 114 | | |
107 | 115 | | |
| |||
kotlin-sdk-core/src/commonTest/kotlin/io/modelcontextprotocol/kotlin/sdk/types/CapabilitiesTest.kt
Lines changed: 97 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
182 | 182 | | |
183 | 183 | | |
184 | 184 | | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
185 | 232 | | |
186 | 233 | | |
187 | 234 | | |
| |||
215 | 262 | | |
216 | 263 | | |
217 | 264 | | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
218 | 268 | | |
219 | 269 | | |
220 | 270 | | |
221 | 271 | | |
222 | 272 | | |
| 273 | + | |
223 | 274 | | |
224 | 275 | | |
225 | 276 | | |
| |||
235 | 286 | | |
236 | 287 | | |
237 | 288 | | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
238 | 292 | | |
239 | 293 | | |
240 | 294 | | |
| |||
270 | 324 | | |
271 | 325 | | |
272 | 326 | | |
| 327 | + | |
273 | 328 | | |
274 | 329 | | |
275 | 330 | | |
| |||
278 | 333 | | |
279 | 334 | | |
280 | 335 | | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
281 | 341 | | |
282 | 342 | | |
283 | 343 | | |
| |||
466 | 526 | | |
467 | 527 | | |
468 | 528 | | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
469 | 555 | | |
470 | 556 | | |
471 | 557 | | |
| |||
499 | 585 | | |
500 | 586 | | |
501 | 587 | | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
502 | 591 | | |
503 | 592 | | |
504 | 593 | | |
| |||
509 | 598 | | |
510 | 599 | | |
511 | 600 | | |
| 601 | + | |
512 | 602 | | |
513 | 603 | | |
514 | 604 | | |
| |||
531 | 621 | | |
532 | 622 | | |
533 | 623 | | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
534 | 627 | | |
535 | 628 | | |
536 | 629 | | |
| |||
578 | 671 | | |
579 | 672 | | |
580 | 673 | | |
| 674 | + | |
581 | 675 | | |
582 | 676 | | |
583 | 677 | | |
| |||
590 | 684 | | |
591 | 685 | | |
592 | 686 | | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
593 | 690 | | |
594 | 691 | | |
595 | 692 | | |
| |||
0 commit comments