Get the FREE Ultimate OpenClaw Setup Guide →

ocaml

OCaml implementation of the Model Context Protocol (MCP)

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio tmattio-ocaml-mcp docker run -i ocaml-mcp-server \
  --env OCAML_MCP_VERBOSITY="info (optional, default: info)" \
  --env OCAML_MCP_CONFIG_PATH="path to config if using external config (optional)"

How to use

The OCaml MCP server provides AI-assisted development tooling for OCaml projects by exposing a set of tools through the MCP protocol. It integrates with Merlin for editor-backed type information, Dune RPC for build and status queries, and various OCaml Platform utilities to offer features like real-time build status, module signature extraction, and code navigation. You can query the server for tasks such as retrieving module signatures from compiled artifacts, finding definitions or references, evaluating OCaml expressions in the project context, and performing project-structure analyses. When used over a transport (stdio, socket, HTTP via the server), clients can request build status, run tests, or perform code analysis with structured results and diagnostics.

How to install

Prerequisites:

  • OCaml and OPAM installed on your system
  • Access to needed OCaml tooling (Merlin, Dune, ocamlformat) if you plan to use the full feature set

Step-by-step:

  1. Install the MCP server via OPAM (OCaml package manager): opam update opam install ocaml-mcp-server

  2. Run the server locally (stdio): ocaml-mcp-server

  3. Run the server as an HTTP service (example): ocaml-mcp-server --socket 8080

  4. (Optional) Run via Docker: docker run -i ocaml-mcp-server

  5. Verify installation by connecting a client that speaks the MCP protocol and issuing a capability query or a simple ping/ping-like request to ensure the server responds as expected.

Additional notes

Notes and tips:

  • The OCaml MCP server integrates with Merlin, Dune RPC, and ocamlformat to provide tooling around type information, file operations, and formatting.
  • Some features are marked as WIP (e.g., certain navigation and completion capabilities); check the server status for enabled capabilities.
  • For production deployments, consider configuring authentication (OAuth 2.1 is on the roadmap) and transport security (WebSocket/SSE support is planned).
  • If using Docker, ensure the container has access to your local OCaml project files and toolchains.
  • Environment variables can control verbosity and config paths; adjust OCAML_MCP_VERBOSITY to control log detail.
  • When running with HTTP, ensure the port is externally accessible and not blocked by firewalls.

Related MCP Servers

Sponsor this space

Reach thousands of developers