My agentic slop goes here. Not intended for anyone else!
1#!/bin/bash
2
3# Script to configure OCaml LSP MCP server for Claude in a subdirectory
4
5set -e
6
7# Check if a directory argument was provided
8if [ "$#" -ne 1 ]; then
9 echo "Usage: $0 <workspace-directory>"
10 echo "Example: $0 /path/to/ocaml/project"
11 exit 1
12fi
13
14WORKSPACE_DIR="$1"
15
16# Convert to absolute path if relative
17if [[ "$WORKSPACE_DIR" != /* ]]; then
18 WORKSPACE_DIR="$(cd "$WORKSPACE_DIR" && pwd)"
19fi
20
21# Check if workspace directory exists
22if [ ! -d "$WORKSPACE_DIR" ]; then
23 echo "Error: Directory '$WORKSPACE_DIR' does not exist"
24 exit 1
25fi
26
27# Find ocamllsp dynamically
28OCAMLLSP=""
29
30# Try using which command directly
31OCAMLLSP=$(which ocamllsp 2>/dev/null || true)
32
33# If not found, try with opam exec
34if [ -z "$OCAMLLSP" ]; then
35 OCAMLLSP=$(opam exec -- which ocamllsp 2>/dev/null || true)
36fi
37
38# If still not found, check current opam switch
39if [ -z "$OCAMLLSP" ] && [ -n "$OPAM_SWITCH_PREFIX" ]; then
40 if [ -f "$OPAM_SWITCH_PREFIX/bin/ocamllsp" ]; then
41 OCAMLLSP="$OPAM_SWITCH_PREFIX/bin/ocamllsp"
42 fi
43fi
44
45if [ -z "$OCAMLLSP" ] || [ ! -f "$OCAMLLSP" ]; then
46 echo "Error: Could not find ocamllsp"
47 echo "Please ensure ocamllsp is installed: opam install ocaml-lsp-server"
48 exit 1
49fi
50
51# Find mcp-language-server
52MCP_SERVER="/Users/avsm/go/bin/mcp-language-server"
53if [ ! -f "$MCP_SERVER" ]; then
54 echo "Error: mcp-language-server not found at $MCP_SERVER"
55 echo "Please ensure mcp-language-server is installed"
56 exit 1
57fi
58
59echo "Configuring OCaml LSP MCP for workspace: $WORKSPACE_DIR"
60echo "Using ocamllsp: $OCAMLLSP"
61echo "Using mcp-language-server: $MCP_SERVER"
62
63# Execute the Claude MCP configuration command
64claude mcp add ocamllsp "$MCP_SERVER" -- -workspace "$WORKSPACE_DIR" -lsp "$OCAMLLSP"
65
66if [ $? -eq 0 ]; then
67 echo "Successfully configured OCaml LSP MCP for $WORKSPACE_DIR"
68else
69 echo "Failed to configure OCaml LSP MCP"
70 exit 1
71fi