(** MCP SDK - Model Context Protocol SDK for OCaml *) open Mcp open Jsonrpc (** SDK version *) val version : string (** Logging utilities *) module Log : sig type level = Debug | Info | Warning | Error val string_of_level : level -> string val log : level -> string -> unit val debug : string -> unit val info : string -> unit val warning : string -> unit val error : string -> unit end (** Context for tools and resources *) module Context : sig type t = { request_id: RequestId.t option; lifespan_context: (string * Json.t) list; mutable progress_token: ProgressToken.t option; } val create : ?request_id:RequestId.t -> ?lifespan_context:(string * Json.t) list -> unit -> t val get_context_value : t -> string -> Json.t option val report_progress : t -> float -> float -> JSONRPCMessage.t option end (** Tools for the MCP server *) module Tool : sig type handler = Context.t -> Json.t -> (Json.t, string) result type t = { name: string; description: string option; input_schema: Json.t; handler: handler; } val create : name:string -> ?description:string -> input_schema:Json.t -> handler:handler -> unit -> t val to_json : t -> Json.t end (** Resources for the MCP server *) module Resource : sig type handler = Context.t -> string list -> (string, string) result type t = { uri_template: string; description: string option; mime_type: string option; handler: handler; } val create : uri_template:string -> ?description:string -> ?mime_type:string -> handler:handler -> unit -> t val to_json : t -> Json.t end (** Prompts for the MCP server *) module Prompt : sig type argument = { name: string; description: string option; required: bool; } type message = { role: Role.t; content: content; } type handler = Context.t -> (string * string) list -> (message list, string) result type t = { name: string; description: string option; arguments: argument list; handler: handler; } val create : name:string -> ?description:string -> ?arguments:argument list -> handler:handler -> unit -> t val create_argument : name:string -> ?description:string -> ?required:bool -> unit -> argument val yojson_of_message : message -> Json.t val message_of_yojson : Json.t -> message val to_json : t -> Json.t end (** Main server type *) type server = { name: string; version: string; protocol_version: string; mutable capabilities: Json.t; mutable tools: Tool.t list; mutable resources: Resource.t list; mutable prompts: Prompt.t list; mutable lifespan_context: (string * Json.t) list; mutable startup_hook: (unit -> unit) option; mutable shutdown_hook: (unit -> unit) option; } (** Create a new server *) val create_server : name:string -> ?version:string -> ?protocol_version:string -> unit -> server (** Default capabilities for the server *) val default_capabilities : ?with_tools:bool -> ?with_resources:bool -> ?with_prompts:bool -> unit -> Json.t (** Register a tool with the server *) val register_tool : server -> Tool.t -> Tool.t (** Create and register a tool in one step *) val add_tool : server -> name:string -> ?description:string -> ?schema_properties:(string * string * string) list -> ?schema_required:string list -> (Json.t -> Json.t) -> Tool.t (** Register a resource with the server *) val register_resource : server -> Resource.t -> Resource.t (** Create and register a resource in one step *) val add_resource : server -> uri_template:string -> ?description:string -> ?mime_type:string -> (string list -> string) -> Resource.t (** Register a prompt with the server *) val register_prompt : server -> Prompt.t -> Prompt.t (** Create and register a prompt in one step *) val add_prompt : server -> name:string -> ?description:string -> ?arguments:(string * string option * bool) list -> ((string * string) list -> Prompt.message list) -> Prompt.t (** Set server capabilities *) val set_capabilities : server -> Json.t -> unit (** Configure server with default capabilities based on registered components *) val configure_server : server -> ?with_tools:bool -> ?with_resources:bool -> ?with_prompts:bool -> unit -> server (** Set startup hook *) val set_startup_hook : server -> (unit -> unit) -> unit (** Set shutdown hook *) val set_shutdown_hook : server -> (unit -> unit) -> unit (** Run the server using stdio transport (legacy method) *) val run_server : server -> unit (** Transport type for the server *) type transport_type = | Stdio (** Read/write to stdin/stdout *) | Http (** HTTP server - to be implemented *) (** Create and start a server with the specified transport *) val run_server_with_transport : server -> transport_type -> unit (** Helper functions for creating common objects *) val make_text_content : string -> content val make_text_content_with_annotations : string -> Annotated.annotation -> content val make_image_content : string -> string -> content val make_image_content_with_annotations : string -> string -> Annotated.annotation -> content val make_audio_content : string -> string -> content val make_audio_content_with_annotations : string -> string -> Annotated.annotation -> content val make_text_resource_content : string -> string -> ?mime_type:string -> unit -> content val make_blob_resource_content : string -> string -> ?mime_type:string -> unit -> content val make_tool_schema : (string * string * string) list -> string list -> Json.t