My agentic slop goes here. Not intended for anyone else!
1(** Model Context Protocol (MCP) OCaml Implementation.
2
3 This library provides a type-safe, Eio-based implementation of the Model Context Protocol,
4 using jsont for JSON serialization with forward-compatible unknown field preservation.
5
6 {1 Quick Start}
7
8 The MCP library is organized into several modules:
9
10 - {!Jsonrpc}: JSON-RPC 2.0 protocol layer
11 - {!Content}: Content block types (text, image, audio, resources)
12 - {!Capabilities}: Client and server capability negotiation
13
14 {1 Example}
15
16 {[
17 open Mcp
18
19 (* Create client capabilities *)
20 let client_caps = Capabilities.Client.make
21 ~sampling:(Capabilities.Sampling.make ~tools:true ())
22 ()
23
24 (* Create content blocks *)
25 let text_block = Content.text "Hello, MCP!"
26 let image_block = Content.image ~data:"..." ~mime_type:"image/png"
27 ]}
28
29 {1 Design Principles}
30
31 - {b Type Safety}: All protocol types use jsont codecs for bidirectional JSON serialization
32 - {b Forward Compatibility}: Unknown fields are preserved in all types
33 - {b Eio Integration}: Uses Eio for structured concurrency
34 - {b Protocol Compliance}: Follows MCP specification exactly
35
36 {1 Modules} *)
37
38(** JSON-RPC 2.0 protocol implementation *)
39module Jsonrpc : module type of Jsonrpc
40
41(** MCP content block types *)
42module Content : module type of Content
43
44(** Client and server capability negotiation *)
45module Capabilities : module type of Capabilities
46
47(** MCP protocol messages (initialize, resources, tools, prompts, logging, etc.) *)
48module Messages : module type of Messages
49
50(** Bidirectional JSON-RPC session management *)
51module Session : module type of Session
52
53(** Transport layer for JSON-RPC communication *)
54module Transport : module type of Transport
55
56(** Stdio transport implementation *)
57module Transport_stdio : module type of Transport_stdio
58
59(** High-level MCP server session API *)
60module Server_session : module type of Server_session
61
62(** High-level MCP client session API *)
63module Client_session : module type of Client_session