-1
.gitignore
-1
.gitignore
.ocamlformat
.ocamlformat
This is a binary file and will not be displayed.
+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
+113
-68
bin/capitalize_sdk.ml
+113
-68
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)
+33
-21
bin/dune
+33
-21
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."
-721
bin/markdown_book_sdk.ml
-721
bin/markdown_book_sdk.ml
···-OCaml is a general-purpose, multi-paradigm programming language which extends the Caml dialect of ML with object-oriented features.-OCaml was created in 1996 by Xavier Leroy, Jรฉrรดme Vouillon, Damien Doligez, and Didier Rรฉmy at INRIA in France. It evolved from the Caml language, which itself was an implementation of ML.-OCaml offers a unique combination of features that make it particularly well-suited for certain domains:-- **Symbolic Computing**: Excellent for manipulating complex data structures and symbolic expressions-- **Systems Programming**: Can be used for low-level systems programming with high safety guarantees-In the following chapters, we'll explore the language features in depth and learn how to leverage OCaml's strengths for building robust, maintainable software.-In OCaml, variables are immutable by default. Once a value is bound to a name, that binding cannot change.-This introduction to basic syntax sets the foundation for understanding OCaml's more advanced features, which we'll explore in the next chapters.-Variants (also called algebraic data types) represent values that can be one of several cases:-These data structures form the backbone of OCaml programming and allow for expressing complex data relationships in a type-safe way.-OCaml's module system is one of its most powerful features. It allows for organizing code into reusable components with clear interfaces.-module MakeSet (Element : sig type t val compare : t -> t -> int end) : COLLECTION with type 'a t = Element.t list = struct-The module system enables OCaml programmers to build highly modular, reusable code with clear boundaries between components.-OCaml offers several advanced features that set it apart from other languages. This chapter explores some of the more powerful language constructs.-These advanced features make OCaml a uniquely powerful language for expressing complex programs with strong guarantees about correctness.
···
+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
-433
bin/multimodal_sdk.ml
-433
bin/multimodal_sdk.ml
···
···
-161
bin/ocaml_eval_sdk.ml
-161
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
···
···
-20
dune-project
-20
dune-project
···
+11
-22
lib/dune
+11
-22
lib/dune
···
···
+899
-655
lib/mcp.ml
+899
-655
lib/mcp.ml
···························
············+let annotations = List.assoc_opt "annotations" fields |> Option.map Annotated.annotation_of_yojson in+let annotations = List.assoc_opt "annotations" fields |> Option.map Annotated.annotation_of_yojson in+let annotations = List.assoc_opt "annotations" fields |> Option.map Annotated.annotation_of_yojson in+let annotations = List.assoc_opt "annotations" fields |> Option.map Annotated.annotation_of_yojson in···············
+231
-957
lib/mcp.mli
+231
-957
lib/mcp.mli
···············
···············+val create_request : ?params:Json.t option -> ?progress_token:ProgressToken.t option -> id:RequestId.t -> method_:string -> unit -> t+val create_error : id:RequestId.t -> code:int -> message:string -> ?data:Json.t option -> unit -> t+val create : capabilities:Json.t -> client_info:Implementation.t -> protocol_version:string -> t+val 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
-833
lib/mcp_rpc.ml
-833
lib/mcp_rpc.ml
···
···
-366
lib/mcp_rpc.mli
-366
lib/mcp_rpc.mli
···
···
+293
-399
lib/mcp_sdk.ml
+293
-399
lib/mcp_sdk.ml
·········-(* Convert a list of ResourceTemplate.t to the format needed for resources/templates/list response *)······
·········+let default_capabilities ?(with_tools=true) ?(with_resources=false) ?(with_prompts=false) () =···+let add_tool server ~name ?description ?(schema_properties=[]) ?(schema_required=[]) handler =···
+102
-203
lib/mcp_sdk.mli
+102
-203
lib/mcp_sdk.mli
·········
······+val create : name:string -> ?description:string -> input_schema:Json.t -> handler:handler -> unit -> t···+val create : uri_template:string -> ?description:string -> ?mime_type:string -> handler:handler -> unit -> t+val create : name:string -> ?description:string -> ?arguments:argument list -> handler:handler -> unit -> t+val 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.t+val add_tool : server -> name:string -> ?description:string -> ?schema_properties:(string * string * string) list -> ?schema_required:string list -> (Json.t -> Json.t) -> Tool.t+val add_resource : server -> uri_template:string -> ?description:string -> ?mime_type:string -> (string list -> string) -> Resource.t+val add_prompt : server -> name:string -> ?description:string -> ?arguments:(string * string option * bool) list -> ((string * string) list -> Prompt.message list) -> Prompt.t+val configure_server : server -> ?with_tools:bool -> ?with_resources:bool -> ?with_prompts:bool -> unit -> server
+507
-539
lib/mcp_server.ml
+507
-539
lib/mcp_server.ml
···-(* Only a warning since on Windows, once the client closes the connection, we normally fail with `I/O error while reading: Eio.Io Net Connection_reset Unix_error (Broken pipe, "stub_cstruct_read", "")` *)
···+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
···
···
-32
mcp.opam
-32
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)