My agentic slop goes here. Not intended for anyone else!
at main 15 kB view raw
1(** MCP Protocol Messages. 2 3 This module provides all protocol message types for the Model Context Protocol (MCP). 4 It includes initialization, resources, tools, prompts, logging, and other protocol messages. 5 6 All types include unknown field preservation for forward compatibility. *) 7 8(** {1 Protocol Version} *) 9 10type protocol_version = string 11(** MCP protocol version string (e.g., "2024-11-05") *) 12 13val protocol_version_jsont : protocol_version Jsont.t 14 15(** {1 Initialize Protocol} *) 16 17module Initialize : sig 18 (** Initialize request parameters *) 19 type request_params = { 20 protocol_version : protocol_version; 21 capabilities : Capabilities.Client.t; 22 client_info : Capabilities.Implementation.t; 23 unknown : Jsont.json; 24 } 25 26 val make_request_params : 27 protocol_version:protocol_version -> 28 capabilities:Capabilities.Client.t -> 29 client_info:Capabilities.Implementation.t -> 30 unit -> 31 request_params 32 33 val request_params_jsont : request_params Jsont.t 34 35 (** Initialize result *) 36 type result = { 37 protocol_version : protocol_version; 38 capabilities : Capabilities.Server.t; 39 server_info : Capabilities.Implementation.t; 40 instructions : string option; 41 unknown : Jsont.json; 42 } 43 44 val make_result : 45 protocol_version:protocol_version -> 46 capabilities:Capabilities.Server.t -> 47 server_info:Capabilities.Implementation.t -> 48 ?instructions:string -> 49 unit -> 50 result 51 52 val result_jsont : result Jsont.t 53 54 val method_ : string 55 (** Method name: "initialize" *) 56end 57 58module Initialized : sig 59 (** Initialized notification (sent after initialize completes) *) 60 type notification = { 61 unknown : Jsont.json; 62 } 63 64 val make_notification : unit -> notification 65 val notification_jsont : notification Jsont.t 66 67 val method_ : string 68 (** Method name: "notifications/initialized" *) 69end 70 71module Ping : sig 72 (** Ping request (keepalive) *) 73 type params = { 74 unknown : Jsont.json; 75 } 76 77 val make_params : unit -> params 78 val params_jsont : params Jsont.t 79 80 (** Ping result (empty object) *) 81 type result = { 82 unknown : Jsont.json; 83 } 84 85 val make_result : unit -> result 86 val result_jsont : result Jsont.t 87 88 val method_ : string 89 (** Method name: "ping" *) 90end 91 92(** {1 Resources} *) 93 94module Resources : sig 95 (** Resource descriptor *) 96 type resource = { 97 uri : string; 98 name : string; 99 description : string option; 100 mime_type : string option; 101 unknown : Jsont.json; 102 } 103 104 val make_resource : 105 uri:string -> 106 name:string -> 107 ?description:string -> 108 ?mime_type:string -> 109 unit -> 110 resource 111 112 val resource_jsont : resource Jsont.t 113 114 (** Resource template (URI template with placeholders) *) 115 type resource_template = { 116 uri_template : string; 117 name : string; 118 description : string option; 119 mime_type : string option; 120 unknown : Jsont.json; 121 } 122 123 val make_resource_template : 124 uri_template:string -> 125 name:string -> 126 ?description:string -> 127 ?mime_type:string -> 128 unit -> 129 resource_template 130 131 val resource_template_jsont : resource_template Jsont.t 132 133 (** Resource contents (from read request) *) 134 type resource_contents = { 135 uri : string; 136 mime_type : string option; 137 text : string option; 138 blob : string option; (** Base64-encoded binary data *) 139 unknown : Jsont.json; 140 } 141 142 val make_text_contents : 143 uri:string -> 144 text:string -> 145 ?mime_type:string -> 146 unit -> 147 resource_contents 148 149 val make_blob_contents : 150 uri:string -> 151 blob:string -> 152 mime_type:string -> 153 resource_contents 154 155 val resource_contents_jsont : resource_contents Jsont.t 156 157 (** List resources request *) 158 type list_request = { 159 cursor : string option; 160 unknown : Jsont.json; 161 } 162 163 val make_list_request : ?cursor:string -> unit -> list_request 164 val list_request_jsont : list_request Jsont.t 165 166 (** List resources result *) 167 type list_result = { 168 resources : resource list; 169 next_cursor : string option; 170 unknown : Jsont.json; 171 } 172 173 val make_list_result : 174 resources:resource list -> 175 ?next_cursor:string -> 176 unit -> 177 list_result 178 179 val list_result_jsont : list_result Jsont.t 180 181 (** Read resource request *) 182 type read_request = { 183 uri : string; 184 unknown : Jsont.json; 185 } 186 187 val make_read_request : uri:string -> read_request 188 val read_request_jsont : read_request Jsont.t 189 190 (** Read resource result *) 191 type read_result = { 192 contents : resource_contents list; 193 unknown : Jsont.json; 194 } 195 196 val make_read_result : contents:resource_contents list -> read_result 197 val read_result_jsont : read_result Jsont.t 198 199 (** Subscribe to resource updates *) 200 type subscribe_request = { 201 uri : string; 202 unknown : Jsont.json; 203 } 204 205 val make_subscribe_request : uri:string -> subscribe_request 206 val subscribe_request_jsont : subscribe_request Jsont.t 207 208 (** Unsubscribe from resource updates *) 209 type unsubscribe_request = { 210 uri : string; 211 unknown : Jsont.json; 212 } 213 214 val make_unsubscribe_request : uri:string -> unsubscribe_request 215 val unsubscribe_request_jsont : unsubscribe_request Jsont.t 216 217 (** Resource updated notification *) 218 type updated_notification = { 219 uri : string; 220 unknown : Jsont.json; 221 } 222 223 val make_updated_notification : uri:string -> updated_notification 224 val updated_notification_jsont : updated_notification Jsont.t 225 226 (** Resource list changed notification *) 227 type list_changed_notification = { 228 unknown : Jsont.json; 229 } 230 231 val make_list_changed_notification : unit -> list_changed_notification 232 val list_changed_notification_jsont : list_changed_notification Jsont.t 233 234 val list_method : string 235 (** Method name: "resources/list" *) 236 237 val read_method : string 238 (** Method name: "resources/read" *) 239 240 val subscribe_method : string 241 (** Method name: "resources/subscribe" *) 242 243 val unsubscribe_method : string 244 (** Method name: "resources/unsubscribe" *) 245 246 val updated_notification_method : string 247 (** Method name: "notifications/resources/updated" *) 248 249 val list_changed_notification_method : string 250 (** Method name: "notifications/resources/list_changed" *) 251end 252 253(** {1 Tools} *) 254 255module Tools : sig 256 (** Tool descriptor *) 257 type tool = { 258 name : string; 259 description : string option; 260 input_schema : Jsont.json; (** JSON Schema for tool inputs *) 261 unknown : Jsont.json; 262 } 263 264 val make_tool : 265 name:string -> 266 ?description:string -> 267 input_schema:Jsont.json -> 268 unit -> 269 tool 270 271 val tool_jsont : tool Jsont.t 272 273 (** List tools request *) 274 type list_request = { 275 cursor : string option; 276 unknown : Jsont.json; 277 } 278 279 val make_list_request : ?cursor:string -> unit -> list_request 280 val list_request_jsont : list_request Jsont.t 281 282 (** List tools result *) 283 type list_result = { 284 tools : tool list; 285 next_cursor : string option; 286 unknown : Jsont.json; 287 } 288 289 val make_list_result : 290 tools:tool list -> 291 ?next_cursor:string -> 292 unit -> 293 list_result 294 295 val list_result_jsont : list_result Jsont.t 296 297 (** Call tool request *) 298 type call_request = { 299 name : string; 300 arguments : Jsont.json option; 301 unknown : Jsont.json; 302 } 303 304 val make_call_request : 305 name:string -> 306 ?arguments:Jsont.json -> 307 unit -> 308 call_request 309 310 val call_request_jsont : call_request Jsont.t 311 312 (** Call tool result *) 313 type call_result = { 314 content : Content.block list; 315 is_error : bool option; 316 unknown : Jsont.json; 317 } 318 319 val make_call_result : 320 content:Content.block list -> 321 ?is_error:bool -> 322 unit -> 323 call_result 324 325 val call_result_jsont : call_result Jsont.t 326 327 (** Tool list changed notification *) 328 type list_changed_notification = { 329 unknown : Jsont.json; 330 } 331 332 val make_list_changed_notification : unit -> list_changed_notification 333 val list_changed_notification_jsont : list_changed_notification Jsont.t 334 335 val list_method : string 336 (** Method name: "tools/list" *) 337 338 val call_method : string 339 (** Method name: "tools/call" *) 340 341 val list_changed_notification_method : string 342 (** Method name: "notifications/tools/list_changed" *) 343end 344 345(** {1 Prompts} *) 346 347module Prompts : sig 348 (** Prompt argument descriptor *) 349 type prompt_argument = { 350 name : string; 351 description : string option; 352 required : bool option; 353 unknown : Jsont.json; 354 } 355 356 val make_prompt_argument : 357 name:string -> 358 ?description:string -> 359 ?required:bool -> 360 unit -> 361 prompt_argument 362 363 val prompt_argument_jsont : prompt_argument Jsont.t 364 365 (** Prompt descriptor *) 366 type prompt = { 367 name : string; 368 description : string option; 369 arguments : prompt_argument list option; 370 unknown : Jsont.json; 371 } 372 373 val make_prompt : 374 name:string -> 375 ?description:string -> 376 ?arguments:prompt_argument list -> 377 unit -> 378 prompt 379 380 val prompt_jsont : prompt Jsont.t 381 382 (** Prompt message role *) 383 type role = User | Assistant 384 385 val role_jsont : role Jsont.t 386 387 (** Prompt message *) 388 type prompt_message = { 389 role : role; 390 content : Content.block list; 391 unknown : Jsont.json; 392 } 393 394 val make_prompt_message : 395 role:role -> 396 content:Content.block list -> 397 unit -> 398 prompt_message 399 400 val prompt_message_jsont : prompt_message Jsont.t 401 402 (** List prompts request *) 403 type list_request = { 404 cursor : string option; 405 unknown : Jsont.json; 406 } 407 408 val make_list_request : ?cursor:string -> unit -> list_request 409 val list_request_jsont : list_request Jsont.t 410 411 (** List prompts result *) 412 type list_result = { 413 prompts : prompt list; 414 next_cursor : string option; 415 unknown : Jsont.json; 416 } 417 418 val make_list_result : 419 prompts:prompt list -> 420 ?next_cursor:string -> 421 unit -> 422 list_result 423 424 val list_result_jsont : list_result Jsont.t 425 426 (** Get prompt request *) 427 type get_request = { 428 name : string; 429 arguments : (string * string) list option; (** Key-value pairs *) 430 unknown : Jsont.json; 431 } 432 433 val make_get_request : 434 name:string -> 435 ?arguments:(string * string) list -> 436 unit -> 437 get_request 438 439 val get_request_jsont : get_request Jsont.t 440 441 (** Get prompt result *) 442 type get_result = { 443 description : string option; 444 messages : prompt_message list; 445 unknown : Jsont.json; 446 } 447 448 val make_get_result : 449 ?description:string -> 450 messages:prompt_message list -> 451 unit -> 452 get_result 453 454 val get_result_jsont : get_result Jsont.t 455 456 (** Prompt list changed notification *) 457 type list_changed_notification = { 458 unknown : Jsont.json; 459 } 460 461 val make_list_changed_notification : unit -> list_changed_notification 462 val list_changed_notification_jsont : list_changed_notification Jsont.t 463 464 val list_method : string 465 (** Method name: "prompts/list" *) 466 467 val get_method : string 468 (** Method name: "prompts/get" *) 469 470 val list_changed_notification_method : string 471 (** Method name: "notifications/prompts/list_changed" *) 472end 473 474(** {1 Logging} *) 475 476module Logging : sig 477 (** Log level *) 478 type level = 479 | Debug 480 | Info 481 | Notice 482 | Warning 483 | Error 484 | Critical 485 | Alert 486 | Emergency 487 488 val level_jsont : level Jsont.t 489 val level_to_string : level -> string 490 491 (** Logging message notification *) 492 type notification = { 493 level : level; 494 logger : string option; 495 data : Jsont.json option; 496 unknown : Jsont.json; 497 } 498 499 val make_notification : 500 level:level -> 501 ?logger:string -> 502 ?data:Jsont.json -> 503 unit -> 504 notification 505 506 val notification_jsont : notification Jsont.t 507 508 val method_ : string 509 (** Method name: "notifications/message" *) 510end 511 512(** {1 Completions} *) 513 514module Completions : sig 515 (** Completion reference (argument or resource URI) *) 516 type completion_ref = { 517 ref_type : string; (** "ref/prompt" or "ref/resource" *) 518 uri : string; 519 unknown : Jsont.json; 520 } 521 522 val make_completion_ref : 523 ref_type:string -> 524 uri:string -> 525 unit -> 526 completion_ref 527 528 val completion_ref_jsont : completion_ref Jsont.t 529 530 (** Completion request *) 531 type request = { 532 ref_ : completion_ref; 533 argument : string option; 534 unknown : Jsont.json; 535 } 536 537 val make_request : 538 ref_:completion_ref -> 539 ?argument:string -> 540 unit -> 541 request 542 543 val request_jsont : request Jsont.t 544 545 (** Completion result *) 546 type result = { 547 completion : string list; 548 total : int option; 549 has_more : bool option; 550 unknown : Jsont.json; 551 } 552 553 val make_result : 554 completion:string list -> 555 ?total:int -> 556 ?has_more:bool -> 557 unit -> 558 result 559 560 val result_jsont : result Jsont.t 561 562 val method_ : string 563 (** Method name: "completion/complete" *) 564end 565 566(** {1 Roots} *) 567 568module Roots : sig 569 (** Root descriptor *) 570 type root = { 571 uri : string; 572 name : string option; 573 unknown : Jsont.json; 574 } 575 576 val make_root : 577 uri:string -> 578 ?name:string -> 579 unit -> 580 root 581 582 val root_jsont : root Jsont.t 583 584 (** List roots request *) 585 type list_request = { 586 unknown : Jsont.json; 587 } 588 589 val make_list_request : unit -> list_request 590 val list_request_jsont : list_request Jsont.t 591 592 (** List roots result *) 593 type list_result = { 594 roots : root list; 595 unknown : Jsont.json; 596 } 597 598 val make_list_result : roots:root list -> list_result 599 val list_result_jsont : list_result Jsont.t 600 601 (** Roots list changed notification *) 602 type list_changed_notification = { 603 unknown : Jsont.json; 604 } 605 606 val make_list_changed_notification : unit -> list_changed_notification 607 val list_changed_notification_jsont : list_changed_notification Jsont.t 608 609 val list_method : string 610 (** Method name: "roots/list" *) 611 612 val list_changed_notification_method : string 613 (** Method name: "notifications/roots/list_changed" *) 614end 615 616(** {1 Progress} *) 617 618module Progress : sig 619 (** Progress notification *) 620 type notification = { 621 progress_token : string; (** Unique token identifying the operation *) 622 progress : float; (** Progress value (0.0 to 1.0) *) 623 total : float option; (** Optional total value *) 624 unknown : Jsont.json; 625 } 626 627 val make_notification : 628 progress_token:string -> 629 progress:float -> 630 ?total:float -> 631 unit -> 632 notification 633 634 val notification_jsont : notification Jsont.t 635 636 val method_ : string 637 (** Method name: "notifications/progress" *) 638end 639 640(** {1 Cancellation} *) 641 642module Cancellation : sig 643 (** Cancel request notification *) 644 type notification = { 645 request_id : Jsonrpc.Id.t; 646 reason : string option; 647 unknown : Jsont.json; 648 } 649 650 val make_notification : 651 request_id:Jsonrpc.Id.t -> 652 ?reason:string -> 653 unit -> 654 notification 655 656 val notification_jsont : notification Jsont.t 657 658 val method_ : string 659 (** Method name: "notifications/cancelled" *) 660end