| 1 | /** |
| 2 | * MCP v2026-07-28 wire schemas. |
| 3 | * |
| 4 | * @internal |
| 5 | */ |
| 6 | import * as Rpc from "../../../rpc/Rpc.ts" |
| 7 | import * as RpcGroup from "../../../rpc/RpcGroup.ts" |
| 8 | import * as Schema from "../../../Schema.ts" |
| 9 | import * as Previous from "./v2025_11_25.ts" |
| 10 | |
| 11 | export * from "./v2025_11_25.ts" |
| 12 | |
| 13 | /** |
| 14 | * @internal |
| 15 | */ |
| 16 | export const protocolVersion = "2026-07-28" |
| 17 | |
| 18 | const optional = Previous.optional |
| 19 | const Meta = optional(Schema.JsonObject) |
| 20 | |
| 21 | /** |
| 22 | * @internal |
| 23 | */ |
| 24 | export const RequestId = Schema.Union([Schema.String, Schema.Int]) |
| 25 | /** |
| 26 | * @internal |
| 27 | */ |
| 28 | export const ProgressToken = RequestId |
| 29 | /** |
| 30 | * @internal |
| 31 | */ |
| 32 | export const Role = Previous.Role |
| 33 | /** |
| 34 | * @internal |
| 35 | */ |
| 36 | export const LoggingLevel = Previous.LoggingLevel |
| 37 | /** |
| 38 | * @internal |
| 39 | */ |
| 40 | export const Implementation = Previous.Implementation |
| 41 | |
| 42 | /** |
| 43 | * @internal |
| 44 | */ |
| 45 | export const ClientCapabilities = Schema.StructWithRest( |
| 46 | Schema.Struct({ |
| 47 | experimental: optional(Schema.Record(Schema.String, Schema.JsonObject)), |
| 48 | roots: optional(Schema.Struct({})), |
| 49 | sampling: optional(Schema.Struct({ |
| 50 | context: optional(Schema.JsonObject), |
| 51 | tools: optional(Schema.JsonObject) |
| 52 | })), |
| 53 | elicitation: optional(Schema.Struct({ |
| 54 | form: optional(Schema.JsonObject), |
| 55 | url: optional(Schema.JsonObject) |
| 56 | })), |
| 57 | extensions: optional(Schema.Record(Schema.String, Schema.JsonObject)) |
| 58 | }), |
| 59 | [Schema.JsonObject] |
| 60 | ) |
| 61 | |
| 62 | /** |
| 63 | * @internal |
| 64 | */ |
| 65 | export const ServerCapabilities = Schema.StructWithRest( |
| 66 | Schema.Struct({ |
| 67 | experimental: optional(Schema.Record(Schema.String, Schema.JsonObject)), |
| 68 | logging: optional(Schema.JsonObject), |
| 69 | completions: optional(Schema.JsonObject), |
| 70 | prompts: optional(Schema.Struct({ listChanged: optional(Schema.Boolean) })), |
| 71 | resources: optional(Schema.Struct({ |
| 72 | subscribe: optional(Schema.Boolean), |
| 73 | listChanged: optional(Schema.Boolean) |
| 74 | })), |
| 75 | tools: optional(Schema.Struct({ listChanged: optional(Schema.Boolean) })), |
| 76 | extensions: optional(Schema.Record(Schema.String, Schema.JsonObject)) |
| 77 | }), |
| 78 | [Schema.JsonObject] |
| 79 | ) |
| 80 | |
| 81 | /** |
| 82 | * @internal |
| 83 | */ |
| 84 | export const RequestMetaObject = Schema.StructWithRest( |
| 85 | Schema.Struct({ |
| 86 | progressToken: optional(ProgressToken), |
| 87 | "io.modelcontextprotocol/protocolVersion": Schema.String, |
| 88 | "io.modelcontextprotocol/clientInfo": optional(Implementation), |
| 89 | "io.modelcontextprotocol/clientCapabilities": ClientCapabilities, |
| 90 | "io.modelcontextprotocol/logLevel": optional(LoggingLevel) |
| 91 | }), |
| 92 | [Schema.JsonObject] |
| 93 | ) |
| 94 | |
| 95 | /** |
| 96 | * @internal |
| 97 | */ |
| 98 | export const RequestParams = Schema.Struct({ _meta: RequestMetaObject }) |
| 99 | |
| 100 | /** |
| 101 | * @internal |
| 102 | */ |
| 103 | export const NotificationMetaObject = Schema.StructWithRest( |
| 104 | Schema.Struct({ |
| 105 | "io.modelcontextprotocol/subscriptionId": optional(RequestId) |
| 106 | }), |
| 107 | [Schema.JsonObject] |
| 108 | ) |
| 109 | /** |
| 110 | * @internal |
| 111 | */ |
| 112 | export const NotificationParams = Schema.Struct({ _meta: optional(NotificationMetaObject) }) |
| 113 | |
| 114 | /** |
| 115 | * @internal |
| 116 | */ |
| 117 | export const ResultMetaObject = Schema.StructWithRest( |
| 118 | Schema.Struct({ |
| 119 | "io.modelcontextprotocol/serverInfo": Implementation |
| 120 | }), |
| 121 | [Schema.JsonObject] |
| 122 | ) |
| 123 | /** |
| 124 | * @internal |
| 125 | */ |
| 126 | export const ResultMeta = { |
| 127 | _meta: ResultMetaObject, |
| 128 | resultType: Schema.Literal("complete") |
| 129 | } |
| 130 | /** |
| 131 | * @internal |
| 132 | */ |
| 133 | export const McpError = Schema.Struct({ |
| 134 | code: Schema.Int, |
| 135 | message: Schema.String, |
| 136 | data: optional(Schema.Json) |
| 137 | }) |
| 138 | /** |
| 139 | * @internal |
| 140 | */ |
| 141 | export type McpError = typeof McpError.Type |
| 142 | |
| 143 | /** |
| 144 | * @internal |
| 145 | */ |
| 146 | export const METHOD_NOT_FOUND = -32601 |
| 147 | /** |
| 148 | * @internal |
| 149 | */ |
| 150 | export const INVALID_PARAMS = -32602 |
| 151 | /** |
| 152 | * @internal |
| 153 | */ |
| 154 | export const MISSING_REQUIRED_CLIENT_CAPABILITY = -32021 |
| 155 | |
| 156 | /** |
| 157 | * @internal |
| 158 | */ |
| 159 | export const Annotations = Previous.Annotations |
| 160 | |
| 161 | /** |
| 162 | * @internal |
| 163 | */ |
| 164 | export const Resource = Schema.Struct({ |
| 165 | ...Previous.Resource.fields, |
| 166 | size: optional(Schema.Int), |
| 167 | annotations: optional(Annotations) |
| 168 | }) |
| 169 | |
| 170 | /** |
| 171 | * @internal |
| 172 | */ |
| 173 | export const ResourceTemplate = Previous.ResourceTemplate |
| 174 | /** |
| 175 | * @internal |
| 176 | */ |
| 177 | export const ResourceContents = Previous.ResourceContents |
| 178 | /** |
| 179 | * @internal |
| 180 | */ |
| 181 | export const TextContent = Previous.TextContent |
| 182 | /** |
| 183 | * @internal |
| 184 | */ |
| 185 | export const ImageContent = Previous.ImageContent |
| 186 | /** |
| 187 | * @internal |
| 188 | */ |
| 189 | export const AudioContent = Previous.AudioContent |
| 190 | /** |
| 191 | * @internal |
| 192 | */ |
| 193 | export const ResourceLink = Schema.Struct({ ...Resource.fields, type: Schema.Literal("resource_link") }) |
| 194 | /** |
| 195 | * @internal |
| 196 | */ |
| 197 | export const EmbeddedResource = Previous.EmbeddedResource |
| 198 | /** |
| 199 | * @internal |
| 200 | */ |
| 201 | export const ContentBlock = Schema.Union([ |
| 202 | TextContent, |
| 203 | ImageContent, |
| 204 | AudioContent, |
| 205 | ResourceLink, |
| 206 | EmbeddedResource |
| 207 | ]) |
| 208 | |
| 209 | /** |
| 210 | * @internal |
| 211 | */ |
| 212 | export const Prompt = Previous.Prompt |
| 213 | /** |
| 214 | * @internal |
| 215 | */ |
| 216 | export const PromptMessage = Schema.Struct({ role: Role, content: ContentBlock }) |
| 217 | |
| 218 | const ToolInputSchema = Schema.StructWithRest( |
| 219 | Schema.Struct({ |
| 220 | $schema: optional(Schema.String), |
| 221 | type: Schema.Literal("object") |
| 222 | }), |
| 223 | [Schema.JsonObject] |
| 224 | ) |
| 225 | const ToolOutputSchema = Schema.StructWithRest( |
| 226 | Schema.Struct({ $schema: optional(Schema.String) }), |
| 227 | [Schema.JsonObject] |
| 228 | ) |
| 229 | /** |
| 230 | * @internal |
| 231 | */ |
| 232 | export const ToolAnnotations = Previous.ToolAnnotations |
| 233 | /** |
| 234 | * @internal |
| 235 | */ |
| 236 | export const Tool = Schema.Struct({ |
| 237 | ...Previous.Tool.fields, |
| 238 | inputSchema: ToolInputSchema, |
| 239 | outputSchema: optional(ToolOutputSchema), |
| 240 | annotations: optional(ToolAnnotations) |
| 241 | }) |
| 242 | |
| 243 | /** |
| 244 | * @internal |
| 245 | */ |
| 246 | export const ToolUseContent = Previous.ToolUseContent |
| 247 | /** |
| 248 | * @internal |
| 249 | */ |
| 250 | export const ToolResultContent = Schema.Struct({ |
| 251 | type: Schema.Literal("tool_result"), |
| 252 | toolUseId: Schema.String, |
| 253 | content: Schema.Array(ContentBlock), |
| 254 | structuredContent: optional(Schema.Json), |
| 255 | isError: optional(Schema.Boolean), |
| 256 | _meta: Meta |
| 257 | }) |
| 258 | /** |
| 259 | * @internal |
| 260 | */ |
| 261 | export const SamplingMessageContentBlock = Schema.Union([ |
| 262 | TextContent, |
| 263 | ImageContent, |
| 264 | AudioContent, |
| 265 | ToolUseContent, |
| 266 | ToolResultContent |
| 267 | ]) |
| 268 | /** |
| 269 | * @internal |
| 270 | */ |
| 271 | export const SamplingMessage = Schema.Struct({ |
| 272 | role: Role, |
| 273 | content: Schema.Union([SamplingMessageContentBlock, Schema.Array(SamplingMessageContentBlock)]), |
| 274 | _meta: Meta |
| 275 | }) |
| 276 | /** |
| 277 | * @internal |
| 278 | */ |
| 279 | export const ModelHint = Schema.StructWithRest( |
| 280 | Schema.Struct({ name: optional(Schema.String) }), |
| 281 | [Schema.JsonObject] |
| 282 | ) |
| 283 | const ModelPriority = Schema.Finite.check(Schema.isBetween({ minimum: 0, maximum: 1 })) |
| 284 | /** |
| 285 | * @internal |
| 286 | */ |
| 287 | export const ModelPreferences = Schema.Struct({ |
| 288 | ...Previous.ModelPreferences.fields, |
| 289 | hints: optional(Schema.Array(ModelHint)), |
| 290 | costPriority: optional(ModelPriority), |
| 291 | speedPriority: optional(ModelPriority), |
| 292 | intelligencePriority: optional(ModelPriority) |
| 293 | }) |
| 294 | /** |
| 295 | * @internal |
| 296 | */ |
| 297 | export const ToolChoice = Previous.ToolChoice |
| 298 | |
| 299 | /** |
| 300 | * @internal |
| 301 | */ |
| 302 | export const CreateMessageRequest = Schema.Struct({ |
| 303 | method: Schema.Literal("sampling/createMessage"), |
| 304 | params: Schema.Struct({ |
| 305 | messages: Schema.Array(SamplingMessage), |
| 306 | modelPreferences: optional(ModelPreferences), |
| 307 | systemPrompt: optional(Schema.String), |
| 308 | includeContext: optional(Schema.Literals(["none", "thisServer", "allServers"])), |
| 309 | temperature: optional(Schema.Finite), |
| 310 | maxTokens: Schema.Int, |
| 311 | stopSequences: optional(Schema.Array(Schema.String)), |
| 312 | metadata: optional(Schema.JsonObject), |
| 313 | tools: optional(Schema.Array(Tool)), |
| 314 | toolChoice: optional(ToolChoice) |
| 315 | }) |
| 316 | }) |
| 317 | /** |
| 318 | * @internal |
| 319 | */ |
| 320 | export const CreateMessageResult = Schema.Struct({ |
| 321 | ...SamplingMessage.fields, |
| 322 | model: Schema.String, |
| 323 | stopReason: optional(Schema.String) |
| 324 | }) |
| 325 | |
| 326 | /** |
| 327 | * @internal |
| 328 | */ |
| 329 | export const Root = Previous.Root |
| 330 | /** |
| 331 | * @internal |
| 332 | */ |
| 333 | export const ListRootsRequest = Schema.Struct({ |
| 334 | method: Schema.Literal("roots/list"), |
| 335 | params: optional(Schema.Struct({ _meta: Meta })) |
| 336 | }) |
| 337 | /** |
| 338 | * @internal |
| 339 | */ |
| 340 | export const ListRootsResult = Schema.Struct({ roots: Schema.Array(Root) }) |
| 341 | |
| 342 | /** |
| 343 | * @internal |
| 344 | */ |
| 345 | export const StringSchema = Previous.StringSchema |
| 346 | /** |
| 347 | * @internal |
| 348 | */ |
| 349 | export const NumberSchema = Previous.NumberSchema |
| 350 | /** |
| 351 | * @internal |
| 352 | */ |
| 353 | export const BooleanSchema = Previous.BooleanSchema |
| 354 | /** |
| 355 | * @internal |
| 356 | */ |
| 357 | export const SingleSelectEnumSchema = Previous.SingleSelectEnumSchema |
| 358 | /** |
| 359 | * @internal |
| 360 | */ |
| 361 | export const MultiSelectEnumSchema = Previous.MultiSelectEnumSchema |
| 362 | /** |
| 363 | * @internal |
| 364 | */ |
| 365 | export const LegacyTitledEnumSchema = Previous.LegacyTitledEnumSchema |
| 366 | /** |
| 367 | * @internal |
| 368 | */ |
| 369 | export const EnumSchema = Schema.Union([ |
| 370 | LegacyTitledEnumSchema, |
| 371 | SingleSelectEnumSchema, |
| 372 | MultiSelectEnumSchema |
| 373 | ]) |
| 374 | /** |
| 375 | * @internal |
| 376 | */ |
| 377 | export const PrimitiveSchemaDefinition = Schema.Union([ |
| 378 | EnumSchema, |
| 379 | StringSchema, |
| 380 | NumberSchema, |
| 381 | BooleanSchema |
| 382 | ]) |
| 383 | /** |
| 384 | * @internal |
| 385 | */ |
| 386 | export const RequestedSchema = Schema.Struct({ |
| 387 | $schema: optional(Schema.String), |
| 388 | type: Schema.Literal("object"), |
| 389 | properties: Schema.Record(Schema.String, PrimitiveSchemaDefinition), |
| 390 | required: optional(Schema.Array(Schema.String)) |
| 391 | }) |
| 392 | /** |
| 393 | * @internal |
| 394 | */ |
| 395 | export const ElicitRequestFormParams = Schema.Struct({ |
| 396 | mode: optional(Schema.Literal("form")), |
| 397 | message: Schema.String, |
| 398 | requestedSchema: RequestedSchema |
| 399 | }) |
| 400 | /** |
| 401 | * @internal |
| 402 | */ |
| 403 | export const ElicitRequestURLParams = Schema.Struct({ |
| 404 | mode: Schema.Literal("url"), |
| 405 | message: Schema.String, |
| 406 | url: Schema.String |
| 407 | }) |
| 408 | /** |
| 409 | * @internal |
| 410 | */ |
| 411 | export const ElicitRequestParams = Schema.Union([ElicitRequestFormParams, ElicitRequestURLParams]) |
| 412 | /** |
| 413 | * @internal |
| 414 | */ |
| 415 | export const ElicitRequest = Schema.Struct({ |
| 416 | method: Schema.Literal("elicitation/create"), |
| 417 | params: ElicitRequestParams |
| 418 | }) |
| 419 | /** |
| 420 | * @internal |
| 421 | */ |
| 422 | export const ElicitResult = Schema.Struct({ |
| 423 | action: Schema.Literals(["accept", "decline", "cancel"]), |
| 424 | content: optional(Schema.Record( |
| 425 | Schema.String, |
| 426 | Schema.Union([Schema.String, Schema.Finite, Schema.Boolean, Schema.Array(Schema.String)]) |
| 427 | )) |
| 428 | }) |
| 429 | |
| 430 | /** |
| 431 | * @internal |
| 432 | */ |
| 433 | export const InputRequest = Schema.Union([CreateMessageRequest, ListRootsRequest, ElicitRequest]) |
| 434 | /** |
| 435 | * @internal |
| 436 | */ |
| 437 | export const InputResponse = Schema.Union([CreateMessageResult, ListRootsResult, ElicitResult]) |
| 438 | /** |
| 439 | * @internal |
| 440 | */ |
| 441 | export const InputRequests = Schema.Record(Schema.String, InputRequest) |
| 442 | /** |
| 443 | * @internal |
| 444 | */ |
| 445 | export const InputResponses = Schema.Record(Schema.String, InputResponse) |
| 446 | const InputRequiredResultMeta = { |
| 447 | _meta: ResultMetaObject, |
| 448 | resultType: Schema.Literal("input_required") |
| 449 | } |
| 450 | /** |
| 451 | * @internal |
| 452 | */ |
| 453 | export const InputRequiredResult = Schema.Union([ |
| 454 | Schema.StructWithRest( |
| 455 | Schema.Struct({ |
| 456 | ...InputRequiredResultMeta, |
| 457 | inputRequests: InputRequests, |
| 458 | requestState: optional(Schema.String) |
| 459 | }), |
| 460 | [Schema.JsonObject] |
| 461 | ), |
| 462 | Schema.StructWithRest( |
| 463 | Schema.Struct({ |
| 464 | ...InputRequiredResultMeta, |
| 465 | inputRequests: optional(InputRequests), |
| 466 | requestState: Schema.String |
| 467 | }), |
| 468 | [Schema.JsonObject] |
| 469 | ) |
| 470 | ]) |
| 471 | /** |
| 472 | * @internal |
| 473 | */ |
| 474 | export const InputResponseRequestParams = { |
| 475 | ...RequestParams.fields, |
| 476 | inputResponses: optional(InputResponses), |
| 477 | requestState: optional(Schema.String) |
| 478 | } |
| 479 | |
| 480 | /** |
| 481 | * @internal |
| 482 | */ |
| 483 | export const CacheableResult = { |
| 484 | ...ResultMeta, |
| 485 | ttlMs: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)), |
| 486 | cacheScope: Schema.Literals(["public", "private"]) |
| 487 | } |
| 488 | /** |
| 489 | * @internal |
| 490 | */ |
| 491 | export const PaginatedRequestParams = { |
| 492 | ...RequestParams.fields, |
| 493 | cursor: optional(Schema.String) |
| 494 | } |
| 495 | /** |
| 496 | * @internal |
| 497 | */ |
| 498 | export const PaginatedResult = { |
| 499 | ...ResultMeta, |
| 500 | nextCursor: optional(Schema.String) |
| 501 | } |
| 502 | |
| 503 | /** |
| 504 | * @internal |
| 505 | */ |
| 506 | export const DiscoverResult = Schema.StructWithRest( |
| 507 | Schema.Struct({ |
| 508 | ...CacheableResult, |
| 509 | supportedVersions: Schema.Array(Schema.String), |
| 510 | capabilities: ServerCapabilities, |
| 511 | instructions: optional(Schema.String) |
| 512 | }), |
| 513 | [Schema.JsonObject] |
| 514 | ) |
| 515 | /** |
| 516 | * @internal |
| 517 | */ |
| 518 | export class Discover extends Rpc.make("server/discover", { |
| 519 | success: DiscoverResult, |
| 520 | error: McpError, |
| 521 | payload: RequestParams |
| 522 | }) {} |
| 523 | |
| 524 | /** |
| 525 | * @internal |
| 526 | */ |
| 527 | export const ListResourcesResult = Schema.StructWithRest( |
| 528 | Schema.Struct({ |
| 529 | ...PaginatedResult, |
| 530 | ...CacheableResult, |
| 531 | resources: Schema.Array(Resource) |
| 532 | }), |
| 533 | [Schema.JsonObject] |
| 534 | ) |
| 535 | /** |
| 536 | * @internal |
| 537 | */ |
| 538 | export class ListResources extends Rpc.make("resources/list", { |
| 539 | success: ListResourcesResult, |
| 540 | error: McpError, |
| 541 | payload: PaginatedRequestParams |
| 542 | }) {} |
| 543 | |
| 544 | /** |
| 545 | * @internal |
| 546 | */ |
| 547 | export const ListResourceTemplatesResult = Schema.StructWithRest( |
| 548 | Schema.Struct({ |
| 549 | ...PaginatedResult, |
| 550 | ...CacheableResult, |
| 551 | resourceTemplates: Schema.Array(ResourceTemplate) |
| 552 | }), |
| 553 | [Schema.JsonObject] |
| 554 | ) |
| 555 | /** |
| 556 | * @internal |
| 557 | */ |
| 558 | export class ListResourceTemplates extends Rpc.make("resources/templates/list", { |
| 559 | success: ListResourceTemplatesResult, |
| 560 | error: McpError, |
| 561 | payload: PaginatedRequestParams |
| 562 | }) {} |
| 563 | |
| 564 | /** |
| 565 | * @internal |
| 566 | */ |
| 567 | export const ReadResourceResult = Schema.StructWithRest( |
| 568 | Schema.Struct({ |
| 569 | ...CacheableResult, |
| 570 | contents: Schema.Array(ResourceContents) |
| 571 | }), |
| 572 | [Schema.JsonObject] |
| 573 | ) |
| 574 | /** |
| 575 | * @internal |
| 576 | */ |
| 577 | export class ReadResource extends Rpc.make("resources/read", { |
| 578 | success: Schema.Union([ReadResourceResult, InputRequiredResult]), |
| 579 | error: McpError, |
| 580 | payload: { ...InputResponseRequestParams, uri: Schema.String } |
| 581 | }) {} |
| 582 | |
| 583 | /** |
| 584 | * @internal |
| 585 | */ |
| 586 | export const ListPromptsResult = Schema.StructWithRest( |
| 587 | Schema.Struct({ |
| 588 | ...PaginatedResult, |
| 589 | ...CacheableResult, |
| 590 | prompts: Schema.Array(Prompt) |
| 591 | }), |
| 592 | [Schema.JsonObject] |
| 593 | ) |
| 594 | /** |
| 595 | * @internal |
| 596 | */ |
| 597 | export class ListPrompts extends Rpc.make("prompts/list", { |
| 598 | success: ListPromptsResult, |
| 599 | error: McpError, |
| 600 | payload: PaginatedRequestParams |
| 601 | }) {} |
| 602 | |
| 603 | /** |
| 604 | * @internal |
| 605 | */ |
| 606 | export const GetPromptResult = Schema.StructWithRest( |
| 607 | Schema.Struct({ |
| 608 | ...ResultMeta, |
| 609 | description: optional(Schema.String), |
| 610 | messages: Schema.Array(PromptMessage) |
| 611 | }), |
| 612 | [Schema.JsonObject] |
| 613 | ) |
| 614 | /** |
| 615 | * @internal |
| 616 | */ |
| 617 | export class GetPrompt extends Rpc.make("prompts/get", { |
| 618 | success: Schema.Union([GetPromptResult, InputRequiredResult]), |
| 619 | error: McpError, |
| 620 | payload: { |
| 621 | ...InputResponseRequestParams, |
| 622 | name: Schema.String, |
| 623 | arguments: optional(Schema.Record(Schema.String, Schema.String)) |
| 624 | } |
| 625 | }) {} |
| 626 | |
| 627 | /** |
| 628 | * @internal |
| 629 | */ |
| 630 | export const ListToolsResult = Schema.StructWithRest( |
| 631 | Schema.Struct({ |
| 632 | ...PaginatedResult, |
| 633 | ...CacheableResult, |
| 634 | tools: Schema.Array(Tool) |
| 635 | }), |
| 636 | [Schema.JsonObject] |
| 637 | ) |
| 638 | /** |
| 639 | * @internal |
| 640 | */ |
| 641 | export class ListTools extends Rpc.make("tools/list", { |
| 642 | success: ListToolsResult, |
| 643 | error: McpError, |
| 644 | payload: PaginatedRequestParams |
| 645 | }) {} |
| 646 | |
| 647 | /** |
| 648 | * @internal |
| 649 | */ |
| 650 | export const CallToolResult = Schema.StructWithRest( |
| 651 | Schema.Struct({ |
| 652 | ...ResultMeta, |
| 653 | content: Schema.Array(ContentBlock), |
| 654 | structuredContent: optional(Schema.Json), |
| 655 | isError: optional(Schema.Boolean) |
| 656 | }), |
| 657 | [Schema.JsonObject] |
| 658 | ) |
| 659 | /** |
| 660 | * @internal |
| 661 | */ |
| 662 | export class CallTool extends Rpc.make("tools/call", { |
| 663 | success: Schema.Union([CallToolResult, InputRequiredResult]), |
| 664 | error: McpError, |
| 665 | payload: { |
| 666 | ...InputResponseRequestParams, |
| 667 | name: Schema.String, |
| 668 | arguments: optional(Schema.JsonObject) |
| 669 | } |
| 670 | }) {} |
| 671 | |
| 672 | /** |
| 673 | * @internal |
| 674 | */ |
| 675 | export const PromptReference = Previous.PromptReference |
| 676 | /** |
| 677 | * @internal |
| 678 | */ |
| 679 | export const ResourceTemplateReference = Previous.ResourceTemplateReference |
| 680 | /** |
| 681 | * @internal |
| 682 | */ |
| 683 | export const CompleteResult = Schema.StructWithRest( |
| 684 | Schema.Struct({ |
| 685 | ...ResultMeta, |
| 686 | completion: Schema.Struct({ |
| 687 | values: Schema.Array(Schema.String).check(Schema.isMaxLength(100)), |
| 688 | total: optional(Schema.Int), |
| 689 | hasMore: optional(Schema.Boolean) |
| 690 | }) |
| 691 | }), |
| 692 | [Schema.JsonObject] |
| 693 | ) |
| 694 | /** |
| 695 | * @internal |
| 696 | */ |
| 697 | export class Complete extends Rpc.make("completion/complete", { |
| 698 | success: CompleteResult, |
| 699 | error: McpError, |
| 700 | payload: { |
| 701 | ...RequestParams.fields, |
| 702 | ref: Schema.Union([PromptReference, ResourceTemplateReference]), |
| 703 | argument: Schema.Struct({ name: Schema.String, value: Schema.String }), |
| 704 | context: optional(Schema.Struct({ |
| 705 | arguments: optional(Schema.Record(Schema.String, Schema.String)) |
| 706 | })) |
| 707 | } |
| 708 | }) {} |
| 709 | |
| 710 | /** |
| 711 | * @internal |
| 712 | */ |
| 713 | export const SubscriptionFilter = Schema.Struct({ |
| 714 | toolsListChanged: optional(Schema.Boolean), |
| 715 | promptsListChanged: optional(Schema.Boolean), |
| 716 | resourcesListChanged: optional(Schema.Boolean), |
| 717 | resourceSubscriptions: optional(Schema.Array(Schema.String)) |
| 718 | }) |
| 719 | /** |
| 720 | * @internal |
| 721 | */ |
| 722 | export const SubscriptionsListenResultMetaObject = Schema.StructWithRest( |
| 723 | Schema.Struct({ |
| 724 | "io.modelcontextprotocol/serverInfo": Implementation, |
| 725 | "io.modelcontextprotocol/subscriptionId": RequestId |
| 726 | }), |
| 727 | [Schema.JsonObject] |
| 728 | ) |
| 729 | /** |
| 730 | * @internal |
| 731 | */ |
| 732 | export const SubscriptionsListenResult = Schema.StructWithRest( |
| 733 | Schema.Struct({ |
| 734 | _meta: SubscriptionsListenResultMetaObject, |
| 735 | resultType: Schema.Literal("complete") |
| 736 | }), |
| 737 | [Schema.JsonObject] |
| 738 | ) |
| 739 | /** |
| 740 | * @internal |
| 741 | */ |
| 742 | export class SubscriptionsListen extends Rpc.make("subscriptions/listen", { |
| 743 | success: SubscriptionsListenResult, |
| 744 | error: McpError, |
| 745 | payload: { ...RequestParams.fields, notifications: SubscriptionFilter } |
| 746 | }) {} |
| 747 | |
| 748 | /** |
| 749 | * @internal |
| 750 | */ |
| 751 | export class CancelledNotification extends Rpc.make("notifications/cancelled", { |
| 752 | payload: { |
| 753 | ...NotificationParams.fields, |
| 754 | requestId: RequestId, |
| 755 | reason: optional(Schema.String) |
| 756 | } |
| 757 | }) {} |
| 758 | /** |
| 759 | * @internal |
| 760 | */ |
| 761 | export class ProgressNotification extends Rpc.make("notifications/progress", { |
| 762 | payload: { |
| 763 | ...NotificationParams.fields, |
| 764 | progressToken: ProgressToken, |
| 765 | progress: Schema.Finite, |
| 766 | total: optional(Schema.Finite), |
| 767 | message: optional(Schema.String) |
| 768 | } |
| 769 | }) {} |
| 770 | /** |
| 771 | * @internal |
| 772 | */ |
| 773 | export class LoggingMessageNotification extends Rpc.make("notifications/message", { |
| 774 | payload: { |
| 775 | ...NotificationParams.fields, |
| 776 | level: LoggingLevel, |
| 777 | logger: optional(Schema.String), |
| 778 | data: Schema.Json |
| 779 | } |
| 780 | }) {} |
| 781 | /** |
| 782 | * @internal |
| 783 | */ |
| 784 | export class ResourceUpdatedNotification extends Rpc.make("notifications/resources/updated", { |
| 785 | payload: { ...NotificationParams.fields, uri: Schema.String } |
| 786 | }) {} |
| 787 | /** |
| 788 | * @internal |
| 789 | */ |
| 790 | export class ResourceListChangedNotification extends Rpc.make("notifications/resources/list_changed", { |
| 791 | payload: Schema.UndefinedOr(NotificationParams) |
| 792 | }) {} |
| 793 | /** |
| 794 | * @internal |
| 795 | */ |
| 796 | export class ToolListChangedNotification extends Rpc.make("notifications/tools/list_changed", { |
| 797 | payload: Schema.UndefinedOr(NotificationParams) |
| 798 | }) {} |
| 799 | /** |
| 800 | * @internal |
| 801 | */ |
| 802 | export class PromptListChangedNotification extends Rpc.make("notifications/prompts/list_changed", { |
| 803 | payload: Schema.UndefinedOr(NotificationParams) |
| 804 | }) {} |
| 805 | /** |
| 806 | * @internal |
| 807 | */ |
| 808 | export class SubscriptionsAcknowledgedNotification extends Rpc.make( |
| 809 | "notifications/subscriptions/acknowledged", |
| 810 | { payload: { ...NotificationParams.fields, notifications: SubscriptionFilter } } |
| 811 | ) {} |
| 812 | |
| 813 | /** |
| 814 | * @internal |
| 815 | */ |
| 816 | export class ClientRequestRpcs extends RpcGroup.make( |
| 817 | Discover, |
| 818 | Complete, |
| 819 | GetPrompt, |
| 820 | ListPrompts, |
| 821 | ListResources, |
| 822 | ListResourceTemplates, |
| 823 | ReadResource, |
| 824 | SubscriptionsListen, |
| 825 | CallTool, |
| 826 | ListTools |
| 827 | ) {} |
| 828 | |
| 829 | /** |
| 830 | * @internal |
| 831 | */ |
| 832 | export class ClientNotificationRpcs extends RpcGroup.make(CancelledNotification) {} |
| 833 | /** |
| 834 | * @internal |
| 835 | */ |
| 836 | export class ClientRpcs extends ClientRequestRpcs.merge(ClientNotificationRpcs) {} |
| 837 | |
| 838 | // In v2026-07-28 these requests are embedded in InputRequiredResult rather than |
| 839 | // being sent as independent JSON-RPC requests. |
| 840 | /** |
| 841 | * @internal |
| 842 | */ |
| 843 | export class ServerRequestRpcs extends RpcGroup.make() {} |
| 844 | |
| 845 | /** |
| 846 | * @internal |
| 847 | */ |
| 848 | export class ServerNotificationRpcs extends RpcGroup.make( |
| 849 | CancelledNotification, |
| 850 | ProgressNotification, |
| 851 | LoggingMessageNotification, |
| 852 | ResourceUpdatedNotification, |
| 853 | ResourceListChangedNotification, |
| 854 | ToolListChangedNotification, |
| 855 | PromptListChangedNotification, |
| 856 | SubscriptionsAcknowledgedNotification |
| 857 | ) {} |