+330
bin/audio_example.ml
+330
bin/audio_example.ml
···
···+let value = int_of_float (amplitude *. max_amplitude *. sin (2.0 *. Float.pi *. frequency *. t)) in+let b2 = if i * 3 + 1 < String.length bytes then Char.code (String.get bytes (i * 3 + 1)) else 0 in+let b3 = if i * 3 + 2 < String.length bytes then Char.code (String.get bytes (i * 3 + 2)) else 0 in
+45
-11
bin/capitalize_sdk.ml
+45
-11
bin/capitalize_sdk.ml
·········
·········
+193
bin/completion_example.ml
+193
bin/completion_example.ml
···
···+("rust", ["memory safety"; "performance"; "static typing"; "ownership"; "zero-cost abstractions"]);+("javascript", ["dynamic typing"; "interpreted"; "prototypes"; "single-threaded"; "event-driven"]);+content = make_text_content (Printf.sprintf "Tell me about the %s programming language" language)+content = make_text_content (Printf.sprintf "%s is a programming language with the following features: %s" language features)
+35
-9
bin/dune
+35
-9
bin/dune
···
···
+468
bin/image_generator_example.ml
+468
bin/image_generator_example.ml
···
···+let b2 = if i * 3 + 1 < String.length bytes then Char.code (String.get bytes (i * 3 + 1)) else 0 in+let b3 = if i * 3 + 2 < String.length bytes then Char.code (String.get bytes (i * 3 + 2)) else 0 in+let result = Buffer.create (8 + Buffer.length ihdr_chunk + Buffer.length idat_chunk + Buffer.length iend_chunk) in+content = make_text_content (Printf.sprintf "Please describe what you see in this %dx%d pixel art."
+502
bin/multimodal_example.ml
+502
bin/multimodal_example.ml
···
···+let b2 = if i * 3 + 1 < String.length bytes then Char.code (String.get bytes (i * 3 + 1)) else 0 in+let b3 = if i * 3 + 2 < String.length bytes then Char.code (String.get bytes (i * 3 + 2)) else 0 in+let value = int_of_float (amplitude *. max_amplitude *. sin (2.0 *. Float.pi *. frequency *. t)) in+content = make_text_content "I've received your multimodal message with text, image, and audio."+content = make_text_resource_content (Printf.sprintf "resource://%s" resource_id) resource_content ~mime_type:"text/plain" ()+let server = configure_server server ~with_tools:true ~with_resources:false ~with_prompts:true () in
-370
bin/multimodal_sdk.ml
-370
bin/multimodal_sdk.ml
···
···
-166
bin/ocaml_eval_sdk.ml
-166
bin/ocaml_eval_sdk.ml
···
···
+186
bin/resource_template_example.ml
+186
bin/resource_template_example.ml
···
···+Text TextContent.{ text = Printf.sprintf "Resource reference for document %s:" doc_id; annotations = None };+content = make_text_content (Printf.sprintf "Please summarize the following document (ID: %s):" doc_id)
+365
bin/server.ml
+365
bin/server.ml
···
···+log_debug (Printf.sprintf "Client info: %s v%s" req.client_info.name req.client_info.version);+log_debug (Printf.sprintf "Protocol version mismatch: client=%s server=%s - will use server version"+Some (create_error ~id:req.id ~code:(-32601) ~message:("Method not found: " ^ req.method_) ()))+log_error (Printf.sprintf "Exception during message processing: %s" (Printexc.to_string exc));
+5
bin/server.mli
+5
bin/server.mli
···
···
-18
dune-project
-18
dune-project
···
+3
-13
lib/dune
+3
-13
lib/dune
···
···
+427
-144
lib/mcp.ml
+427
-144
lib/mcp.ml
··········································
··········································
+219
-805
lib/mcp.mli
+219
-805
lib/mcp.mli
···-- Follows a client-server model where clients (often LLM-integrated applications) communicate with MCP servers-| Text of TextContent.t (** Text content for natural language messages. This is the most common content type for user-assistant interactions. *)-| Image of ImageContent.t (** Image content for visual data. Used for sharing visual context in multimodal conversations. *)-| Audio of AudioContent.t (** Audio content for audio data. Used for sharing audio context in multimodal conversations. *)-| Resource of EmbeddedResource.t (** Resource content for referencing server-side resources. Used for incorporating managed server content with stable URIs. *)-val create_request : ?params:Json.t option -> ?progress_token:ProgressToken.t option -> id:RequestId.t -> method_:Method.t -> unit -> tval create_error : id:RequestId.t -> code:int -> message:string -> ?data:Json.t option -> unit -> tval create : capabilities:Json.t -> client_info:Implementation.t -> protocol_version:string -> tval create : capabilities:Json.t -> server_info:Implementation.t -> protocol_version:string -> ?instructions:string -> ?meta:Json.t -> unit -> t-val create_notification : ?params:Json.t option -> method_:Method.t -> unit -> JSONRPCMessage.t-val create_request : ?params:Json.t option -> ?progress_token:ProgressToken.t option -> id:RequestId.t -> method_:Method.t -> unit -> JSONRPCMessage.t-val create_error : id:RequestId.t -> code:int -> message:string -> ?data:Json.t option -> unit -> JSONRPCMessage.t
···+val create_request : ?params:Json.t option -> ?progress_token:ProgressToken.t option -> id:RequestId.t -> method_:string -> unit -> tval create_error : id:RequestId.t -> code:int -> message:string -> ?data:Json.t option -> unit -> tval create : capabilities:Json.t -> client_info:Implementation.t -> protocol_version:string -> tval create : capabilities:Json.t -> server_info:Implementation.t -> protocol_version:string -> ?instructions:string -> ?meta:Json.t -> unit -> t+val create_request : ?params:Json.t option -> ?progress_token:ProgressToken.t option -> id:RequestId.t -> method_:string -> unit -> JSONRPCMessage.t+val create_error : id:RequestId.t -> code:int -> message:string -> ?data:Json.t option -> unit -> JSONRPCMessage.t+val create_completion_request : id:RequestId.t -> argument:Completion.Argument.t -> ref:Completion.Request.reference -> JSONRPCMessage.t+val create_completion_response : id:RequestId.t -> values:string list -> ?has_more:bool option -> ?total:int option -> ?meta:Json.t option -> unit -> JSONRPCMessage.t
-726
lib/mcp_message.ml
-726
lib/mcp_message.ml
···
···
-264
lib/mcp_message.mli
-264
lib/mcp_message.mli
···-val create_response : id:RequestId.t -> resources:Resource.t list -> ?next_cursor:Cursor.t -> unit -> JSONRPCMessage.t-val create_response : id:RequestId.t -> contents:ResourceContent.t list -> unit -> JSONRPCMessage.t-val create_response : id:RequestId.t -> tools:Tool.t list -> ?next_cursor:Cursor.t -> unit -> JSONRPCMessage.t-val create_request : name:string -> arguments:Json.t -> ?id:RequestId.t -> unit -> JSONRPCMessage.t-val create_response : id:RequestId.t -> content:ToolContent.t list -> is_error:bool -> unit -> JSONRPCMessage.t-val create_response : id:RequestId.t -> prompts:Prompt.t list -> ?next_cursor:Cursor.t -> unit -> JSONRPCMessage.t-val create_request : name:string -> arguments:(string * string) list -> ?id:RequestId.t -> unit -> JSONRPCMessage.t-val create_response : id:RequestId.t -> ?description:string -> messages:PromptMessage.t list -> unit -> JSONRPCMessage.t-val create_notification : progress:float -> total:float -> progress_token:ProgressToken.t -> unit -> JSONRPCMessage.t
···
+110
-71
lib/mcp_sdk.ml
+110
-71
lib/mcp_sdk.ml
·····················-let create_rich_tool_result ?(text=None) ?(image=None) ?(audio=None) ?(resource=None) ~is_error () =···
························
+57
-21
lib/mcp_sdk.mli
+57
-21
lib/mcp_sdk.mli
···-val create : ?request_id:RequestId.t -> ?progress_token:ProgressToken.t -> ?lifespan_context:(string * Json.t) list -> unit -> t···val create : name:string -> ?description:string -> ?arguments:argument list -> handler:handler -> unit -> tval create_server : name:string -> ?version:string -> ?protocol_version:string -> unit -> server···val default_capabilities : ?with_tools:bool -> ?with_resources:bool -> ?with_prompts:bool -> unit -> Json.tval add_tool : server -> name:string -> ?description:string -> ?schema_properties:(string * string * string) list -> ?schema_required:string list -> (Json.t -> Json.t) -> Tool.tval add_resource : server -> uri_template:string -> ?description:string -> ?mime_type:string -> (string list -> string) -> Resource.tval add_prompt : server -> name:string -> ?description:string -> ?arguments:(string * string option * bool) list -> ((string * string) list -> Prompt.message list) -> Prompt.tval configure_server : server -> ?with_tools:bool -> ?with_resources:bool -> ?with_prompts:bool -> unit -> server
······val create : name:string -> ?description:string -> ?arguments:argument list -> handler:handler -> unit -> tval create_server : name:string -> ?version:string -> ?protocol_version:string -> unit -> server···val default_capabilities : ?with_tools:bool -> ?with_resources:bool -> ?with_prompts:bool -> unit -> Json.tval add_tool : server -> name:string -> ?description:string -> ?schema_properties:(string * string * string) list -> ?schema_required:string list -> (Json.t -> Json.t) -> Tool.tval add_resource : server -> uri_template:string -> ?description:string -> ?mime_type:string -> (string list -> string) -> Resource.tval add_prompt : server -> name:string -> ?description:string -> ?arguments:(string * string option * bool) list -> ((string * string) list -> Prompt.message list) -> Prompt.tval configure_server : server -> ?with_tools:bool -> ?with_resources:bool -> ?with_prompts:bool -> unit -> server
+512
-258
lib/mcp_server.ml
+512
-258
lib/mcp_server.ml
···-Some (create_jsonrpc_error req.id MethodNotFound ("Method not found: " ^ (Method.to_string req.method_)) ()))-Log.debug (Printf.sprintf "Received notification with method: %s" (Method.to_string notif.method_));-Log.error (Printf.sprintf "Exception during message processing: %s" (Printexc.to_string exc));
···+Some (create_error ~id:req.id ~code:ErrorCode.invalid_params ~message:"Invalid params for tools/call" ())+Some (create_error ~id:req.id ~code:ErrorCode.method_not_found ~message:"Resources not supported" ())+Some (create_error ~id:req.id ~code:ErrorCode.method_not_found ~message:"Prompts not supported" ())+Some (create_error ~id:req.id ~code:ErrorCode.invalid_params ~message:(Printf.sprintf "Prompt not found: %s" name) ())+Some (create_error ~id:req.id ~code:ErrorCode.invalid_params ~message:"Invalid params format" ())+Some (create_error ~id:req.id ~code:ErrorCode.method_not_found ~message:"Prompts not supported" ())+Some (create_error ~id:req.id ~code:ErrorCode.method_not_found ~message:("Method not found: " ^ req.method_) ())+Log.error (Printf.sprintf "Exception during message processing: %s" (Printexc.to_string exc));+Log.debug (Printf.sprintf "Raw input: %s" (String.sub line 0 (min 100 (String.length line))));+Log.error (Printf.sprintf "Input was: %s" (String.sub line 0 (min 100 (String.length line))));+let error_resp = create_error ~id ~code:ErrorCode.internal_error ~message:(Printexc.to_string exc) () in
+54
lib/mcp_server.mli
+54
lib/mcp_server.mli
···
···
-29
mcp.opam
-29
mcp.opam
···
···
+178
spec/00-arch.md
+178
spec/00-arch.md
···
···
+4
spec/README.md
+4
spec/README.md
+239
spec/lifecycle.md
+239
spec/lifecycle.md
···
···+| -------- | -------------- | -------------------------------------------------------------------------- |+| Client | `sampling` | Support for LLM [sampling]({{< ref "../client/sampling" >}}) requests |+| Server | `logging` | Emits structured [log messages]({{< ref "../server/utilities/logging" >}}) |
+265
spec/prompts.md
+265
spec/prompts.md
···
···
+357
spec/resources.md
+357
spec/resources.md
···
···+[XDG MIME type](https://specifications.freedesktop.org/shared-mime-info-spec/0.14/ar01s02.html#id-1.3.14),
spec/slash-command.png
spec/slash-command.png
This is a binary file and will not be displayed.
+299
spec/tools.md
+299
spec/tools.md
···
···
+278
spec/transports.md
+278
spec/transports.md
···
···+[SSE standard](https://html.spec.whatwg.org/multipage/server-sent-events.html#event-stream-interpretation).+[`Last-Event-ID`](https://html.spec.whatwg.org/multipage/server-sent-events.html#the-last-event-id-header)