···
val to_message : t -> string
52
-
(** MCP Protocol Methods - Standard method names used in JSON-RPC messages *)
52
+
(** MCP Protocol Methods - Algebraic data type representing all MCP methods *)
54
-
(** Standard protocol methods used in MCP JSON-RPC messages *)
56
-
val initialize : string (** "initialize" - Start the MCP lifecycle *)
58
-
val initialized : string (** "notifications/initialized" - Signal readiness after initialization *)
54
+
(** Method type representing all MCP protocol methods *)
56
+
(* Initialization and lifecycle methods *)
57
+
| Initialize (** Start the MCP lifecycle *)
58
+
| Initialized (** Signal readiness after initialization *)
60
+
(* Resource methods *)
61
+
| ResourcesList (** Discover available resources *)
62
+
| ResourcesRead (** Retrieve resource contents *)
63
+
| ResourcesTemplatesList (** List available resource templates *)
64
+
| ResourcesSubscribe (** Subscribe to resource changes *)
65
+
| ResourcesListChanged (** Resource list has changed *)
66
+
| ResourcesUpdated (** Resource has been updated *)
69
+
| ToolsList (** Discover available tools *)
70
+
| ToolsCall (** Invoke a tool *)
71
+
| ToolsListChanged (** Tool list has changed *)
73
+
(* Prompt methods *)
74
+
| PromptsList (** Discover available prompts *)
75
+
| PromptsGet (** Retrieve a prompt template with arguments *)
76
+
| PromptsListChanged (** Prompt list has changed *)
78
+
(* Progress notifications *)
79
+
| Progress (** Progress update for long-running operations *)
60
-
val resources_list : string (** "resources/list" - Discover available resources *)
62
-
val resources_read : string (** "resources/read" - Retrieve resource contents *)
64
-
val resources_templates_list : string (** "resources/templates/list" - List available resource templates *)
66
-
val resources_subscribe : string (** "resources/subscribe" - Subscribe to resource changes *)
68
-
val resources_list_changed : string (** "notifications/resources/list_changed" - Resource list has changed *)
70
-
val resources_updated : string (** "notifications/resources/updated" - Resource has been updated *)
72
-
val tools_list : string (** "tools/list" - Discover available tools *)
74
-
val tools_call : string (** "tools/call" - Invoke a tool *)
76
-
val tools_list_changed : string (** "notifications/tools/list_changed" - Tool list has changed *)
78
-
val prompts_list : string (** "prompts/list" - Discover available prompts *)
80
-
val prompts_get : string (** "prompts/get" - Retrieve a prompt template with arguments *)
82
-
val prompts_list_changed : string (** "notifications/prompts/list_changed" - Prompt list has changed *)
81
+
(** Convert method type to string representation
82
+
@param method_ The method to convert
83
+
@return The string representation of the method (e.g., "initialize", "resources/list")
85
+
val to_string : t -> string
84
-
val progress : string (** "notifications/progress" - Progress update for long-running operations *)
87
+
(** Convert string to method type
88
+
@param s The string representation of the method
89
+
@return The corresponding method type
90
+
@raise Failure if the string is not a valid MCP method
92
+
val of_string : string -> t
···
511
-
(** Method name for the notification, following the MCP naming conventions.
512
-
Common method patterns include:
513
-
- "notifications/X" for standard notifications
514
-
- "notifications/X/Y" for more specific notifications
516
-
Examples: "notifications/initialized", "notifications/resources/updated" *)
519
+
(** Method for the notification, using the Method.t type to ensure type safety.
520
+
Examples: Method.Initialized, Method.ResourcesUpdated *)
(** Optional parameters for the notification as arbitrary JSON.
The structure depends on the specific notification method. *)
···
(** Unique identifier for the request, which will be echoed in the response.
This can be a string or integer and should be unique within the session. *)
548
-
(** Method name for the request, following the MCP naming conventions.
549
-
Common method patterns include:
550
-
- "X/Y" for standard operations
551
-
- "X/Y/Z" for more specific operations
553
-
Examples: "initialize", "resources/read", "tools/call", "prompts/get" *)
552
+
(** Method for the request, using the Method.t type to ensure type safety.
553
+
Examples: Method.Initialize, Method.ResourcesRead, Method.ToolsCall *)
(** Optional parameters for the request as arbitrary JSON.
The structure depends on the specific request method. *)
···
@param method_ Method name for the notification
@return A new JSON-RPC notification message
720
-
val create_notification : ?params:Json.t option -> method_:string -> unit -> t
720
+
val create_notification : ?params:Json.t option -> method_:Method.t -> unit -> t
(** Create a new request message
@param params Optional parameters for the request
···
@param method_ Method name for the request
@return A new JSON-RPC request message
729
-
val create_request : ?params:Json.t option -> ?progress_token:ProgressToken.t option -> id:RequestId.t -> method_:string -> unit -> t
729
+
val create_request : ?params:Json.t option -> ?progress_token:ProgressToken.t option -> id:RequestId.t -> method_:Method.t -> unit -> t
(** Create a new response message
@param id ID matching the original request
···
- "notifications/tools/list_changed" - Available tools changed
@param params Optional parameters for the notification as a JSON value
917
-
@param method_ Method name for the notification, typically following MCP naming conventions
917
+
@param method_ Method type for the notification
@return A new JSON-RPC notification message
920
-
val create_notification : ?params:Json.t option -> method_:string -> unit -> JSONRPCMessage.t
920
+
val create_notification : ?params:Json.t option -> method_:Method.t -> unit -> JSONRPCMessage.t
(** Create a new request message
···
@param progress_token Optional progress token for long-running operations
that can report progress updates
@param id Unique identifier for the request, used to correlate with the response
940
-
@param method_ Method name for the request, following MCP naming conventions
940
+
@param method_ Method type for the request
@return A new JSON-RPC request message
943
-
val create_request : ?params:Json.t option -> ?progress_token:ProgressToken.t option -> id:RequestId.t -> method_:string -> unit -> JSONRPCMessage.t
943
+
val create_request : ?params:Json.t option -> ?progress_token:ProgressToken.t option -> id:RequestId.t -> method_:Method.t -> unit -> JSONRPCMessage.t
(** Create a new response message