| 1 | /** |
| 2 | * Supported non-Task MCP v2025-11-25 wire schemas. |
| 3 | * |
| 4 | * This module is a dated delta from v2025-06-18. Experimental Tasks are not |
| 5 | * part of the supported vocabulary for this adapter. |
| 6 | * |
| 7 | * @internal |
| 8 | */ |
| 9 | import * as Rpc from "../../../rpc/Rpc.ts" |
| 10 | import * as RpcGroup from "../../../rpc/RpcGroup.ts" |
| 11 | import * as Schema from "../../../Schema.ts" |
| 12 | import * as Previous from "./v2025_06_18.ts" |
| 13 | |
| 14 | export * from "./v2025_06_18.ts" |
| 15 | |
| 16 | /** |
| 17 | * @internal |
| 18 | */ |
| 19 | export const protocolVersion = "2025-11-25" |
| 20 | |
| 21 | const optional = Previous.optional |
| 22 | const JsonObject = Schema.JsonObject |
| 23 | const Meta = optional(JsonObject) |
| 24 | |
| 25 | /** |
| 26 | * @internal |
| 27 | */ |
| 28 | export const Icon = Schema.Struct({ |
| 29 | src: Schema.String, |
| 30 | mimeType: optional(Schema.String), |
| 31 | sizes: optional(Schema.Array(Schema.String)), |
| 32 | theme: optional(Schema.Literals(["light", "dark"])) |
| 33 | }) |
| 34 | |
| 35 | /** |
| 36 | * @internal |
| 37 | */ |
| 38 | export const Implementation = Schema.Struct({ |
| 39 | ...Previous.Implementation.fields, |
| 40 | description: optional(Schema.String), |
| 41 | websiteUrl: optional(Schema.String), |
| 42 | icons: optional(Schema.Array(Icon)) |
| 43 | }) |
| 44 | |
| 45 | /** |
| 46 | * @internal |
| 47 | */ |
| 48 | export const ClientCapabilities = Schema.Struct({ |
| 49 | ...Previous.ClientCapabilities.fields, |
| 50 | sampling: optional(Schema.Struct({ |
| 51 | context: optional(JsonObject), |
| 52 | tools: optional(JsonObject) |
| 53 | })), |
| 54 | elicitation: optional(Schema.Struct({ |
| 55 | form: optional(JsonObject), |
| 56 | url: optional(JsonObject) |
| 57 | })) |
| 58 | }) |
| 59 | |
| 60 | /** |
| 61 | * @internal |
| 62 | */ |
| 63 | export const Annotations = Schema.Struct({ |
| 64 | ...Previous.Annotations.fields, |
| 65 | lastModified: optional(Schema.String) |
| 66 | }) |
| 67 | |
| 68 | /** |
| 69 | * @internal |
| 70 | */ |
| 71 | export const Resource = Schema.Struct({ |
| 72 | ...Previous.Resource.fields, |
| 73 | annotations: optional(Annotations), |
| 74 | icons: optional(Schema.Array(Icon)) |
| 75 | }) |
| 76 | |
| 77 | /** |
| 78 | * @internal |
| 79 | */ |
| 80 | export const ResourceTemplate = Schema.Struct({ |
| 81 | ...Previous.ResourceTemplate.fields, |
| 82 | annotations: optional(Annotations), |
| 83 | icons: optional(Schema.Array(Icon)) |
| 84 | }) |
| 85 | |
| 86 | /** |
| 87 | * @internal |
| 88 | */ |
| 89 | export const Prompt = Schema.Struct({ |
| 90 | ...Previous.Prompt.fields, |
| 91 | icons: optional(Schema.Array(Icon)) |
| 92 | }) |
| 93 | |
| 94 | /** |
| 95 | * @internal |
| 96 | */ |
| 97 | export const TextContent = Schema.Struct({ |
| 98 | ...Previous.TextContent.fields, |
| 99 | annotations: optional(Annotations) |
| 100 | }) |
| 101 | |
| 102 | /** |
| 103 | * @internal |
| 104 | */ |
| 105 | export const ImageContent = Schema.Struct({ |
| 106 | ...Previous.ImageContent.fields, |
| 107 | annotations: optional(Annotations) |
| 108 | }) |
| 109 | |
| 110 | /** |
| 111 | * @internal |
| 112 | */ |
| 113 | export const AudioContent = Schema.Struct({ |
| 114 | ...Previous.AudioContent.fields, |
| 115 | annotations: optional(Annotations) |
| 116 | }) |
| 117 | |
| 118 | /** |
| 119 | * @internal |
| 120 | */ |
| 121 | export const EmbeddedResource = Schema.Struct({ |
| 122 | ...Previous.EmbeddedResource.fields, |
| 123 | annotations: optional(Annotations) |
| 124 | }) |
| 125 | |
| 126 | /** |
| 127 | * @internal |
| 128 | */ |
| 129 | export const ResourceLink = Schema.Struct({ |
| 130 | ...Resource.fields, |
| 131 | type: Schema.Literal("resource_link") |
| 132 | }) |
| 133 | |
| 134 | /** |
| 135 | * @internal |
| 136 | */ |
| 137 | export const ContentBlock = Schema.Union([ |
| 138 | TextContent, |
| 139 | ImageContent, |
| 140 | AudioContent, |
| 141 | ResourceLink, |
| 142 | EmbeddedResource |
| 143 | ]) |
| 144 | |
| 145 | /** |
| 146 | * @internal |
| 147 | */ |
| 148 | export const PromptMessage = Schema.Struct({ |
| 149 | role: Previous.Role, |
| 150 | content: ContentBlock |
| 151 | }) |
| 152 | |
| 153 | /** |
| 154 | * @internal |
| 155 | */ |
| 156 | export const Tool = Schema.Struct({ |
| 157 | ...Previous.Tool.fields, |
| 158 | icons: optional(Schema.Array(Icon)) |
| 159 | }) |
| 160 | |
| 161 | /** |
| 162 | * @internal |
| 163 | */ |
| 164 | export const CallToolResult = Schema.Struct({ |
| 165 | ...Previous.CallToolResult.fields, |
| 166 | content: Schema.Array(ContentBlock) |
| 167 | }) |
| 168 | |
| 169 | /** |
| 170 | * @internal |
| 171 | */ |
| 172 | export class CallTool extends Rpc.make("tools/call", { |
| 173 | success: CallToolResult, |
| 174 | error: Previous.McpError, |
| 175 | payload: Previous.CallTool.payloadSchema |
| 176 | }) {} |
| 177 | |
| 178 | /** |
| 179 | * @internal |
| 180 | */ |
| 181 | export const ToolUseContent = Schema.Struct({ |
| 182 | type: Schema.Literal("tool_use"), |
| 183 | id: Schema.String, |
| 184 | name: Schema.String, |
| 185 | input: JsonObject, |
| 186 | _meta: Meta |
| 187 | }) |
| 188 | |
| 189 | /** |
| 190 | * @internal |
| 191 | */ |
| 192 | export const ToolResultContent = Schema.Struct({ |
| 193 | type: Schema.Literal("tool_result"), |
| 194 | toolUseId: Schema.String, |
| 195 | content: Schema.Array(ContentBlock), |
| 196 | structuredContent: optional(JsonObject), |
| 197 | isError: optional(Schema.Boolean), |
| 198 | _meta: Meta |
| 199 | }) |
| 200 | |
| 201 | /** |
| 202 | * @internal |
| 203 | */ |
| 204 | export const SamplingMessageContentBlock = Schema.Union([ |
| 205 | TextContent, |
| 206 | ImageContent, |
| 207 | AudioContent, |
| 208 | ToolUseContent, |
| 209 | ToolResultContent |
| 210 | ]) |
| 211 | |
| 212 | /** |
| 213 | * @internal |
| 214 | */ |
| 215 | export const SamplingMessage = Schema.Struct({ |
| 216 | role: Previous.Role, |
| 217 | content: Schema.Union([ |
| 218 | SamplingMessageContentBlock, |
| 219 | Schema.Array(SamplingMessageContentBlock) |
| 220 | ]), |
| 221 | _meta: Meta |
| 222 | }) |
| 223 | |
| 224 | /** |
| 225 | * @internal |
| 226 | */ |
| 227 | export const ToolChoice = Schema.Struct({ |
| 228 | mode: optional(Schema.Literals(["auto", "required", "none"])) |
| 229 | }) |
| 230 | |
| 231 | /** |
| 232 | * @internal |
| 233 | */ |
| 234 | export const CreateMessageResult = Schema.Struct({ |
| 235 | ...Previous.ResultMeta.fields, |
| 236 | ...SamplingMessage.fields, |
| 237 | model: Schema.String, |
| 238 | stopReason: optional(Schema.String) |
| 239 | }) |
| 240 | |
| 241 | /** |
| 242 | * @internal |
| 243 | */ |
| 244 | export class CreateMessage extends Rpc.make("sampling/createMessage", { |
| 245 | success: CreateMessageResult, |
| 246 | error: Previous.McpError, |
| 247 | payload: { |
| 248 | ...Previous.CreateMessage.payloadSchema.fields, |
| 249 | messages: Schema.Array(SamplingMessage), |
| 250 | maxTokens: Schema.Int, |
| 251 | tools: optional(Schema.Array(Tool)), |
| 252 | toolChoice: optional(ToolChoice) |
| 253 | } |
| 254 | }) {} |
| 255 | |
| 256 | /** |
| 257 | * @internal |
| 258 | */ |
| 259 | export const Root = Schema.Struct({ |
| 260 | ...Previous.Root.fields, |
| 261 | _meta: Meta |
| 262 | }) |
| 263 | |
| 264 | /** |
| 265 | * @internal |
| 266 | */ |
| 267 | export const ListRootsResult = Schema.Struct({ |
| 268 | ...Previous.ResultMeta.fields, |
| 269 | roots: Schema.Array(Root) |
| 270 | }) |
| 271 | |
| 272 | /** |
| 273 | * @internal |
| 274 | */ |
| 275 | export class ListRoots extends Rpc.make("roots/list", { |
| 276 | success: ListRootsResult, |
| 277 | error: Previous.McpError, |
| 278 | payload: Schema.UndefinedOr(Previous.RequestMeta) |
| 279 | }) {} |
| 280 | |
| 281 | /** |
| 282 | * @internal |
| 283 | */ |
| 284 | export const StringSchema = Schema.Struct({ |
| 285 | type: Schema.Literal("string"), |
| 286 | title: optional(Schema.String), |
| 287 | description: optional(Schema.String), |
| 288 | minLength: optional(Schema.Int), |
| 289 | maxLength: optional(Schema.Int), |
| 290 | format: optional(Schema.Literals(["email", "uri", "date", "date-time"])), |
| 291 | default: optional(Schema.String) |
| 292 | }) |
| 293 | |
| 294 | /** |
| 295 | * @internal |
| 296 | */ |
| 297 | export const NumberSchema = Schema.Struct({ |
| 298 | type: Schema.Literals(["number", "integer"]), |
| 299 | title: optional(Schema.String), |
| 300 | description: optional(Schema.String), |
| 301 | minimum: optional(Schema.Finite), |
| 302 | maximum: optional(Schema.Finite), |
| 303 | default: optional(Schema.Finite) |
| 304 | }) |
| 305 | |
| 306 | /** |
| 307 | * @internal |
| 308 | */ |
| 309 | export const BooleanSchema = Schema.Struct({ |
| 310 | type: Schema.Literal("boolean"), |
| 311 | title: optional(Schema.String), |
| 312 | description: optional(Schema.String), |
| 313 | default: optional(Schema.Boolean) |
| 314 | }) |
| 315 | |
| 316 | const EnumOption = Schema.Struct({ |
| 317 | const: Schema.String, |
| 318 | title: Schema.String |
| 319 | }) |
| 320 | |
| 321 | /** |
| 322 | * @internal |
| 323 | */ |
| 324 | export const UntitledSingleSelectEnumSchema = Schema.Struct({ |
| 325 | type: Schema.Literal("string"), |
| 326 | title: optional(Schema.String), |
| 327 | description: optional(Schema.String), |
| 328 | enum: Schema.Array(Schema.String), |
| 329 | default: optional(Schema.String) |
| 330 | }) |
| 331 | |
| 332 | /** |
| 333 | * @internal |
| 334 | */ |
| 335 | export const TitledSingleSelectEnumSchema = Schema.Struct({ |
| 336 | type: Schema.Literal("string"), |
| 337 | title: optional(Schema.String), |
| 338 | description: optional(Schema.String), |
| 339 | oneOf: Schema.Array(EnumOption), |
| 340 | default: optional(Schema.String) |
| 341 | }) |
| 342 | |
| 343 | /** |
| 344 | * @internal |
| 345 | */ |
| 346 | export const SingleSelectEnumSchema = Schema.Union([ |
| 347 | UntitledSingleSelectEnumSchema, |
| 348 | TitledSingleSelectEnumSchema |
| 349 | ]) |
| 350 | |
| 351 | /** |
| 352 | * @internal |
| 353 | */ |
| 354 | export const UntitledMultiSelectEnumSchema = Schema.Struct({ |
| 355 | type: Schema.Literal("array"), |
| 356 | title: optional(Schema.String), |
| 357 | description: optional(Schema.String), |
| 358 | minItems: optional(Schema.Int), |
| 359 | maxItems: optional(Schema.Int), |
| 360 | items: Schema.Struct({ |
| 361 | type: Schema.Literal("string"), |
| 362 | enum: Schema.Array(Schema.String) |
| 363 | }), |
| 364 | default: optional(Schema.Array(Schema.String)) |
| 365 | }) |
| 366 | |
| 367 | /** |
| 368 | * @internal |
| 369 | */ |
| 370 | export const TitledMultiSelectEnumSchema = Schema.Struct({ |
| 371 | type: Schema.Literal("array"), |
| 372 | title: optional(Schema.String), |
| 373 | description: optional(Schema.String), |
| 374 | minItems: optional(Schema.Int), |
| 375 | maxItems: optional(Schema.Int), |
| 376 | items: Schema.Struct({ |
| 377 | anyOf: Schema.Array(EnumOption) |
| 378 | }), |
| 379 | default: optional(Schema.Array(Schema.String)) |
| 380 | }) |
| 381 | |
| 382 | /** |
| 383 | * @internal |
| 384 | */ |
| 385 | export const MultiSelectEnumSchema = Schema.Union([ |
| 386 | UntitledMultiSelectEnumSchema, |
| 387 | TitledMultiSelectEnumSchema |
| 388 | ]) |
| 389 | |
| 390 | /** |
| 391 | * @internal |
| 392 | */ |
| 393 | export const LegacyTitledEnumSchema = Schema.Struct({ |
| 394 | type: Schema.Literal("string"), |
| 395 | title: optional(Schema.String), |
| 396 | description: optional(Schema.String), |
| 397 | enum: Schema.Array(Schema.String), |
| 398 | enumNames: optional(Schema.Array(Schema.String)), |
| 399 | default: optional(Schema.String) |
| 400 | }) |
| 401 | |
| 402 | /** |
| 403 | * @internal |
| 404 | */ |
| 405 | export const EnumSchema = Schema.Union([ |
| 406 | LegacyTitledEnumSchema, |
| 407 | SingleSelectEnumSchema, |
| 408 | MultiSelectEnumSchema |
| 409 | ]) |
| 410 | |
| 411 | /** |
| 412 | * @internal |
| 413 | */ |
| 414 | export const PrimitiveSchemaDefinition = Schema.Union([ |
| 415 | EnumSchema, |
| 416 | StringSchema, |
| 417 | NumberSchema, |
| 418 | BooleanSchema |
| 419 | ]) |
| 420 | |
| 421 | /** |
| 422 | * @internal |
| 423 | */ |
| 424 | export const RequestedSchema = Schema.Struct({ |
| 425 | $schema: optional(Schema.String), |
| 426 | type: Schema.Literal("object"), |
| 427 | properties: Schema.Record(Schema.String, PrimitiveSchemaDefinition), |
| 428 | required: optional(Schema.Array(Schema.String)) |
| 429 | }) |
| 430 | |
| 431 | /** |
| 432 | * @internal |
| 433 | */ |
| 434 | export const ElicitRequestFormParams = Schema.Struct({ |
| 435 | ...Previous.RequestMeta.fields, |
| 436 | mode: optional(Schema.Literal("form")), |
| 437 | message: Schema.String, |
| 438 | requestedSchema: RequestedSchema |
| 439 | }) |
| 440 | |
| 441 | /** |
| 442 | * @internal |
| 443 | */ |
| 444 | export const ElicitRequestURLParams = Schema.Struct({ |
| 445 | ...Previous.RequestMeta.fields, |
| 446 | mode: Schema.Literal("url"), |
| 447 | message: Schema.String, |
| 448 | elicitationId: Schema.String, |
| 449 | url: Schema.String |
| 450 | }) |
| 451 | |
| 452 | /** |
| 453 | * @internal |
| 454 | */ |
| 455 | export const ElicitRequestParams = Schema.Union([ |
| 456 | ElicitRequestFormParams, |
| 457 | ElicitRequestURLParams |
| 458 | ]) |
| 459 | |
| 460 | /** |
| 461 | * @internal |
| 462 | */ |
| 463 | export const ElicitResult = Schema.Struct({ |
| 464 | ...Previous.ResultMeta.fields, |
| 465 | action: Schema.Literals(["accept", "decline", "cancel"]), |
| 466 | content: optional(Schema.Record( |
| 467 | Schema.String, |
| 468 | Schema.Union([Schema.String, Schema.Finite, Schema.Boolean, Schema.Array(Schema.String)]) |
| 469 | )) |
| 470 | }) |
| 471 | |
| 472 | /** |
| 473 | * @internal |
| 474 | */ |
| 475 | export class Elicit extends Rpc.make("elicitation/create", { |
| 476 | success: ElicitResult, |
| 477 | error: Previous.McpError, |
| 478 | payload: ElicitRequestParams |
| 479 | }) {} |
| 480 | |
| 481 | /** |
| 482 | * @internal |
| 483 | */ |
| 484 | export class ElicitationCompleteNotification extends Rpc.make("notifications/elicitation/complete", { |
| 485 | payload: { |
| 486 | elicitationId: Schema.String |
| 487 | } |
| 488 | }) {} |
| 489 | |
| 490 | /** |
| 491 | * @internal |
| 492 | */ |
| 493 | export const InitializeResult = Schema.Struct({ |
| 494 | ...Previous.InitializeResult.fields, |
| 495 | serverInfo: Implementation |
| 496 | }) |
| 497 | |
| 498 | /** |
| 499 | * @internal |
| 500 | */ |
| 501 | export class Initialize extends Rpc.make("initialize", { |
| 502 | success: InitializeResult, |
| 503 | error: Previous.McpError, |
| 504 | payload: { |
| 505 | ...Previous.Initialize.payloadSchema.fields, |
| 506 | capabilities: ClientCapabilities, |
| 507 | clientInfo: Implementation |
| 508 | } |
| 509 | }) {} |
| 510 | |
| 511 | /** |
| 512 | * @internal |
| 513 | */ |
| 514 | export const ListResourcesResult = Schema.Struct({ |
| 515 | ...Previous.PaginatedResult.fields, |
| 516 | resources: Schema.Array(Resource) |
| 517 | }) |
| 518 | |
| 519 | /** |
| 520 | * @internal |
| 521 | */ |
| 522 | export const ListResourceTemplatesResult = Schema.Struct({ |
| 523 | ...Previous.PaginatedResult.fields, |
| 524 | resourceTemplates: Schema.Array(ResourceTemplate) |
| 525 | }) |
| 526 | |
| 527 | /** |
| 528 | * @internal |
| 529 | */ |
| 530 | export const ListPromptsResult = Schema.Struct({ |
| 531 | ...Previous.PaginatedResult.fields, |
| 532 | prompts: Schema.Array(Prompt) |
| 533 | }) |
| 534 | |
| 535 | /** |
| 536 | * @internal |
| 537 | */ |
| 538 | export const GetPromptResult = Schema.Struct({ |
| 539 | ...Previous.GetPromptResult.fields, |
| 540 | messages: Schema.Array(PromptMessage) |
| 541 | }) |
| 542 | |
| 543 | /** |
| 544 | * @internal |
| 545 | */ |
| 546 | export const ListToolsResult = Schema.Struct({ |
| 547 | ...Previous.PaginatedResult.fields, |
| 548 | tools: Schema.Array(Tool) |
| 549 | }) |
| 550 | |
| 551 | /** |
| 552 | * @internal |
| 553 | */ |
| 554 | export class ListResources extends Rpc.make("resources/list", { |
| 555 | success: ListResourcesResult, |
| 556 | error: Previous.McpError, |
| 557 | payload: Schema.UndefinedOr(Previous.PaginatedRequest) |
| 558 | }) {} |
| 559 | |
| 560 | /** |
| 561 | * @internal |
| 562 | */ |
| 563 | export class ListResourceTemplates extends Rpc.make("resources/templates/list", { |
| 564 | success: ListResourceTemplatesResult, |
| 565 | error: Previous.McpError, |
| 566 | payload: Schema.UndefinedOr(Previous.PaginatedRequest) |
| 567 | }) {} |
| 568 | |
| 569 | /** |
| 570 | * @internal |
| 571 | */ |
| 572 | export class ListPrompts extends Rpc.make("prompts/list", { |
| 573 | success: ListPromptsResult, |
| 574 | error: Previous.McpError, |
| 575 | payload: Schema.UndefinedOr(Previous.PaginatedRequest) |
| 576 | }) {} |
| 577 | |
| 578 | /** |
| 579 | * @internal |
| 580 | */ |
| 581 | export class GetPrompt extends Rpc.make("prompts/get", { |
| 582 | success: GetPromptResult, |
| 583 | error: Previous.McpError, |
| 584 | payload: { |
| 585 | ...Previous.RequestMeta.fields, |
| 586 | name: Schema.String, |
| 587 | arguments: optional(Schema.Record(Schema.String, Schema.String)) |
| 588 | } |
| 589 | }) {} |
| 590 | |
| 591 | /** |
| 592 | * @internal |
| 593 | */ |
| 594 | export class ListTools extends Rpc.make("tools/list", { |
| 595 | success: ListToolsResult, |
| 596 | error: Previous.McpError, |
| 597 | payload: Schema.UndefinedOr(Previous.PaginatedRequest) |
| 598 | }) {} |
| 599 | |
| 600 | /** |
| 601 | * @internal |
| 602 | */ |
| 603 | export class ClientRequestRpcs extends RpcGroup.make( |
| 604 | Previous.Ping, |
| 605 | Initialize, |
| 606 | Previous.Complete, |
| 607 | Previous.SetLevel, |
| 608 | GetPrompt, |
| 609 | ListPrompts, |
| 610 | ListResources, |
| 611 | ListResourceTemplates, |
| 612 | Previous.ReadResource, |
| 613 | Previous.Subscribe, |
| 614 | Previous.Unsubscribe, |
| 615 | CallTool, |
| 616 | ListTools |
| 617 | ) {} |
| 618 | |
| 619 | /** |
| 620 | * @internal |
| 621 | */ |
| 622 | export class ClientNotificationRpcs extends RpcGroup.make( |
| 623 | Previous.CancelledNotification, |
| 624 | Previous.ProgressNotification, |
| 625 | Previous.InitializedNotification, |
| 626 | Previous.RootsListChangedNotification |
| 627 | ) {} |
| 628 | |
| 629 | /** |
| 630 | * @internal |
| 631 | */ |
| 632 | export class ServerRequestRpcs extends RpcGroup.make( |
| 633 | Previous.Ping, |
| 634 | CreateMessage, |
| 635 | ListRoots, |
| 636 | Elicit |
| 637 | ) {} |
| 638 | |
| 639 | /** |
| 640 | * @internal |
| 641 | */ |
| 642 | export class ServerNotificationRpcs extends RpcGroup.make( |
| 643 | Previous.CancelledNotification, |
| 644 | Previous.ProgressNotification, |
| 645 | Previous.LoggingMessageNotification, |
| 646 | Previous.ResourceUpdatedNotification, |
| 647 | Previous.ResourceListChangedNotification, |
| 648 | Previous.ToolListChangedNotification, |
| 649 | Previous.PromptListChangedNotification, |
| 650 | ElicitationCompleteNotification |
| 651 | ) {} |