commits
The old one did not allow customization, and using logs will also make this behave like its dependencies.
Signed-off-by: Marcello Seri <marcello.seri@gmail.com>
With yojson 3.0.0 fails with
```
File "vendor/ocaml-mcp/lib/mcp_server.ml", line 303, characters 43-47:
303 | let text = Yojson.Safe.to_string json in
^^^^
Error: The value json has type
[> `Assoc of (string * [> `Bool of 'a | `List of Json.t list ]) list
]
but an expression was expected of type
Yojson.Safe.t =
[ `Assoc of (string * Yojson.Safe.t) list
| `Bool of bool
| `Float of float
| `Int of int
| `Intlit of string
| `List of Yojson.Safe.t list
| `Null
| `String of string ]
Type [> `Bool of 'a | `List of Json.t list ]
is not compatible with type
Yojson.Safe.t =
[ `Assoc of (string * Yojson.Safe.t) list
| `Bool of bool
| `Float of float
| `Int of int
| `Intlit of string
| `List of Yojson.Safe.t list
| `Null
| `String of string ]
Type
Json.t =
[ `Assoc of (string * Json.t) list
| `Bool of bool
| `Float of float
| `Int of int
| `Intlit of string
| `List of Json.t list
| `Null
| `String of string
| `Tuple of Json.t list
| `Variant of string * Json.t option ]
is not compatible with type
Yojson.Safe.t =
[ `Assoc of (string * Yojson.Safe.t) list
| `Bool of bool
| `Float of float
| `Int of int
| `Intlit of string
| `List of Yojson.Safe.t list
| `Null
| `String of string ]
The second variant type does not allow tag(s) `Tuple, `Variant
```
(ocaml-lsp-server already had this upper bound so you can notice the
issue only when it is not present)
Signed-off-by: Marcello Seri <marcello.seri@gmail.com>
Both are supported after all (see https://modelcontextprotocol.io/docs/concepts/architecture)
- Add handle_resource_templates_list function for the resources/templates/list method
- Add resourceTemplates capability to the server
- Update server capabilities with resourceTemplates option
This fixes the 'Method not found: resources/templates/list' error when running the MCP server.
- Add ResourceTemplate module with handlers for templated URIs
- Update Resource module to use direct URIs without templates
- Implement URI parameter extraction from template patterns
- Fix handling of resources/read to match against both resources and templates
- Refactor resource matching into a dedicated Resource_matcher module
- Update example code to use resource templates properly
- Fix JSON-RPC method names for consistency
- Add translator functions to convert between SDK and RPC types
- Use these functions in the Mcp_server for all RPC handlers
- Implement proper content type conversion for tool responses
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Update all instances of direct 'raise (Json.Of_json' to use the centralized helper
- Use consistent error message formatting with the helper in both mcp.ml and mcp_rpc.ml
- Ensure all JSON parsing errors include the JSON object in the error message
- Maintain standard naming patterns for all error messages
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Add logf, debugf, infof, warningf, and errorf functions that take format strings
- Keep original log functions for backward compatibility
- Update logging calls across the codebase to use format string versions
- Simplify code by removing unnecessary Printf.sprintf calls
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Create a new Util submodule with common parsing utilities
- Refactor JSON parsing across various modules to use these utilities
- Improve error handling with more precise error messages
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Update ocaml_eval_sdk.ml to use Mcp_rpc instead of Mcp_message
- Fix Tool.create_tool_result references in binary modules
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Replace string-based methods with a type-safe algebraic data type to
better enforce correctness in the protocol implementation.
- Added Method.t variant type with all MCP methods as constructors
- Added to_string and of_string conversion functions
- Updated JSONRPCMessage to use Method.t instead of strings
- Modified create_notification and create_request to use Method.t parameter
- Updated all method references throughout the codebase
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Fix the OCaml eval SDK to use Mcp.make_text_content instead of direct
TextContent constructor for consistent API usage.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Refactor all SDK examples to use the standardized Mcp.make_*_content
functions instead of direct constructors for better consistency.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit moves the RPC message types from Mcp to a separate Mcp_message
module with a consistent structure:
1. Each message type (ResourcesList, ResourcesRead, etc.) has its own module
2. Each module contains Request, Response, and other relevant submodules
3. Each submodule has a single `type t` with JSON conversion functions
4. Each submodule includes the Json.Jsonable.S interface
This restructuring provides better type safety and a more consistent API
for handling JSON-RPC messages in the OCaml MCP implementation.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit adds detailed OCamldoc annotations to the Mcp.mli interface file, based on the Model Context Protocol specifications. The annotations provide:
- Detailed module overview explaining the MCP architecture and components
- Thorough documentation for all types, modules, and functions
- Explanations of core protocol concepts
- JSON format examples using OCamldoc verbatim blocks
- Parameter documentation with @param tags
The annotations will improve code understandability and support OCamldoc generation.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Created a new MCP server for directly evaluating OCaml code
- Uses compiler-libs.toplevel for direct code evaluation in process
- Provides rich error messages with detailed diagnostics
- Maintains toplevel state between evaluations
- Initializes with common libraries and modules
- Returns formatted results with syntax highlighting
- Captures stdout/stderr output during evaluation
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Implemented a simple GIF image generator with 8-color palette
- Created a basic red and blue checkerboard pattern
- Added proper GIF header, descriptor, and image data blocks
- Updated all image MIME types to image/gif
- GIF format is more widely compatible than SVG
- This makes the multimodal example more self-contained without dependencies
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Fixed WAV header generation to properly encode binary data
- Implemented proper little-endian integer serialization
- Replaced PPM image format with SVG vector graphics
- Added various random SVG shapes (circles, rectangles, lines, polygons)
- Updated protocol version to 2025-03-26 to match spec
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit adds a new multimodal_sdk.ml example that demonstrates:
- Generating and returning image content (PPM format)
- Generating and returning audio content (WAV format)
- Combining multiple content types in a single tool response
- Using the new error handling and tool result infrastructure
- Implementing resource templates with multimodal responses
The example includes:
- A Base64 encoder for binary data
- A PPM (simple RGB format) image generator with checkerboard pattern
- A WAV audio generator for sine wave tones
- Multiple tools using different content types
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Add proper AudioContent module to Mcp
- Add Audio content type to content type
- Update content serialization/deserialization functions
- Support JSON-RPC error code standardization
- Improve tool result handling with structured content
- Add helper functions for creating rich tool results with multiple content types
- Ensure content types match MCP specification
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit refactors the Mcp_sdk module to use a direct approach instead of
OCaml functors for creating servers. The changes include:
- Remove the MakeServer functor and Server module
- Create direct functions for working with servers
- Expose register_* and add_* functions for tools, resources, and prompts
- Update the capitalize_sdk.ml example to use the new API
- Simplify the server creation and configuration process
The non-functor API provides a more straightforward approach for creating
MCP servers in OCaml.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit adds an MCP SDK module that provides a higher-level interface for
creating MCP servers. The SDK simplifies the creation of tools, resources, and
prompts with a more accessible API, avoiding the use of functors.
Key improvements:
- Created a modular Mcp_sdk library for easy server creation
- Fixed build issues and interface constraints
- Added a capitalize_sdk.ml example server using the new SDK
- Improved logging for server operations
- Restructured dune files to handle multiple libraries
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Implements a simple MCP server that exposes a 'capitalize' tool which converts text to uppercase.
Includes comprehensive debugging and fixes protocol compatibility issues for Claude Desktop.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
With yojson 3.0.0 fails with
```
File "vendor/ocaml-mcp/lib/mcp_server.ml", line 303, characters 43-47:
303 | let text = Yojson.Safe.to_string json in
^^^^
Error: The value json has type
[> `Assoc of (string * [> `Bool of 'a | `List of Json.t list ]) list
]
but an expression was expected of type
Yojson.Safe.t =
[ `Assoc of (string * Yojson.Safe.t) list
| `Bool of bool
| `Float of float
| `Int of int
| `Intlit of string
| `List of Yojson.Safe.t list
| `Null
| `String of string ]
Type [> `Bool of 'a | `List of Json.t list ]
is not compatible with type
Yojson.Safe.t =
[ `Assoc of (string * Yojson.Safe.t) list
| `Bool of bool
| `Float of float
| `Int of int
| `Intlit of string
| `List of Yojson.Safe.t list
| `Null
| `String of string ]
Type
Json.t =
[ `Assoc of (string * Json.t) list
| `Bool of bool
| `Float of float
| `Int of int
| `Intlit of string
| `List of Json.t list
| `Null
| `String of string
| `Tuple of Json.t list
| `Variant of string * Json.t option ]
is not compatible with type
Yojson.Safe.t =
[ `Assoc of (string * Yojson.Safe.t) list
| `Bool of bool
| `Float of float
| `Int of int
| `Intlit of string
| `List of Yojson.Safe.t list
| `Null
| `String of string ]
The second variant type does not allow tag(s) `Tuple, `Variant
```
(ocaml-lsp-server already had this upper bound so you can notice the
issue only when it is not present)
Signed-off-by: Marcello Seri <marcello.seri@gmail.com>
- Add ResourceTemplate module with handlers for templated URIs
- Update Resource module to use direct URIs without templates
- Implement URI parameter extraction from template patterns
- Fix handling of resources/read to match against both resources and templates
- Refactor resource matching into a dedicated Resource_matcher module
- Update example code to use resource templates properly
- Fix JSON-RPC method names for consistency
- Update all instances of direct 'raise (Json.Of_json' to use the centralized helper
- Use consistent error message formatting with the helper in both mcp.ml and mcp_rpc.ml
- Ensure all JSON parsing errors include the JSON object in the error message
- Maintain standard naming patterns for all error messages
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Add logf, debugf, infof, warningf, and errorf functions that take format strings
- Keep original log functions for backward compatibility
- Update logging calls across the codebase to use format string versions
- Simplify code by removing unnecessary Printf.sprintf calls
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Replace string-based methods with a type-safe algebraic data type to
better enforce correctness in the protocol implementation.
- Added Method.t variant type with all MCP methods as constructors
- Added to_string and of_string conversion functions
- Updated JSONRPCMessage to use Method.t instead of strings
- Modified create_notification and create_request to use Method.t parameter
- Updated all method references throughout the codebase
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit moves the RPC message types from Mcp to a separate Mcp_message
module with a consistent structure:
1. Each message type (ResourcesList, ResourcesRead, etc.) has its own module
2. Each module contains Request, Response, and other relevant submodules
3. Each submodule has a single `type t` with JSON conversion functions
4. Each submodule includes the Json.Jsonable.S interface
This restructuring provides better type safety and a more consistent API
for handling JSON-RPC messages in the OCaml MCP implementation.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit adds detailed OCamldoc annotations to the Mcp.mli interface file, based on the Model Context Protocol specifications. The annotations provide:
- Detailed module overview explaining the MCP architecture and components
- Thorough documentation for all types, modules, and functions
- Explanations of core protocol concepts
- JSON format examples using OCamldoc verbatim blocks
- Parameter documentation with @param tags
The annotations will improve code understandability and support OCamldoc generation.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Created a new MCP server for directly evaluating OCaml code
- Uses compiler-libs.toplevel for direct code evaluation in process
- Provides rich error messages with detailed diagnostics
- Maintains toplevel state between evaluations
- Initializes with common libraries and modules
- Returns formatted results with syntax highlighting
- Captures stdout/stderr output during evaluation
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Implemented a simple GIF image generator with 8-color palette
- Created a basic red and blue checkerboard pattern
- Added proper GIF header, descriptor, and image data blocks
- Updated all image MIME types to image/gif
- GIF format is more widely compatible than SVG
- This makes the multimodal example more self-contained without dependencies
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Fixed WAV header generation to properly encode binary data
- Implemented proper little-endian integer serialization
- Replaced PPM image format with SVG vector graphics
- Added various random SVG shapes (circles, rectangles, lines, polygons)
- Updated protocol version to 2025-03-26 to match spec
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit adds a new multimodal_sdk.ml example that demonstrates:
- Generating and returning image content (PPM format)
- Generating and returning audio content (WAV format)
- Combining multiple content types in a single tool response
- Using the new error handling and tool result infrastructure
- Implementing resource templates with multimodal responses
The example includes:
- A Base64 encoder for binary data
- A PPM (simple RGB format) image generator with checkerboard pattern
- A WAV audio generator for sine wave tones
- Multiple tools using different content types
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Add proper AudioContent module to Mcp
- Add Audio content type to content type
- Update content serialization/deserialization functions
- Support JSON-RPC error code standardization
- Improve tool result handling with structured content
- Add helper functions for creating rich tool results with multiple content types
- Ensure content types match MCP specification
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit refactors the Mcp_sdk module to use a direct approach instead of
OCaml functors for creating servers. The changes include:
- Remove the MakeServer functor and Server module
- Create direct functions for working with servers
- Expose register_* and add_* functions for tools, resources, and prompts
- Update the capitalize_sdk.ml example to use the new API
- Simplify the server creation and configuration process
The non-functor API provides a more straightforward approach for creating
MCP servers in OCaml.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit adds an MCP SDK module that provides a higher-level interface for
creating MCP servers. The SDK simplifies the creation of tools, resources, and
prompts with a more accessible API, avoiding the use of functors.
Key improvements:
- Created a modular Mcp_sdk library for easy server creation
- Fixed build issues and interface constraints
- Added a capitalize_sdk.ml example server using the new SDK
- Improved logging for server operations
- Restructured dune files to handle multiple libraries
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>