This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
dev-mcp-server is an MCP (Model Context Protocol) server that bridges LSP (Language Server Protocol) functionality for OCaml development. It exposes ocamllsp capabilities and ocp-index tools as MCP tools, enabling AI assistants to perform code navigation and lookup operations on OCaml codebases.
# Install dependencies (requires uv package manager)
uv sync
# Run the server (stdio transport for MCP)
uv run dev-mcp-server
# Or run directly
uv run python server.py
# Disable specific tool groups
uv run dev-mcp-server --no-lsp # Disable ocamllsp tools
uv run dev-mcp-server --no-ocp-index # Disable ocp-index/ocp-grep tools
# Environment variables (alternative to CLI flags)
DEV_MCP_NO_LSP=1 uv run dev-mcp-server
DEV_MCP_NO_OCP_INDEX=1 uv run dev-mcp-serverThe codebase consists of two main files:
-
server.py: FastMCP server exposing tools. Tools are conditionally registered at startup via
register_lsp_tools()andregister_ocp_index_tools(). Tool groups:- LSP-based tools:
find_references,go_to_definition,go_to_type_definition,hover,type_search,get_documentation - ocp-index tools:
ocp_index_complete,ocp_index_print,ocp_index_type,ocp_index_locate,ocp_grep
- LSP-based tools:
-
lsp_client.py: JSON-RPC client managing an ocamllsp subprocess. Handles LSP protocol framing, request/response correlation via threading, and file synchronization (
didOpen/didClose).
- Lazy LSP initialization: The
LspClientinstance is created on first tool invocation and reused. Workspace changes trigger client restart. - Workspace detection: Searches parent directories for
dune-project,.git, ordune-workspacemarkers. - File sync: Files are automatically opened in LSP before queries and tracked to avoid duplicate opens.
- ocamllsp extensions: Several tools use custom ocamllsp methods (
ocamllsp/hoverExtended,ocamllsp/typeSearch,ocamllsp/getDocumentation) documented in SPEC.md.
- Python 3.10+
mcp[cli]>=1.2.0(FastMCP framework)- External:
ocamllsp(LSP server), optionallyocp-indexandocp-grepfor identifier lookup tools