Ragex MCP Server Guide
View SourceSocket naming
Ragex may run several independent instances at once (one per project, or one
per dllb server port), so the MCP Unix socket is namespaced instead of
using a single fixed path. The resolution order (identical across the
Elixir server, bin/ragex-mcp, start_server.sh/test_socket.sh, and the
nvim/lvim clients) is:
RAGEX_MCP_SOCK-- explicit override, used verbatim.DLLB_PORT-- if set, the socket is/tmp/ragex_mcp_<port>.sock.- Otherwise, the socket is namespaced by the project directory being
served:
/tmp/ragex_mcp_<sanitized_path>.sock.
To find the socket for the server you started, run ls /tmp/ragex_mcp_*.sock
or check the MCP Socket Server listening on ... line the server logs on
startup. The examples below use $SOCKET_PATH as a stand-in for whichever
path applies to your instance.
Quick Start
# 1. Clean up any old server for this project
pkill -f "mix run"
rm -f /tmp/ragex_mcp_*.sock
# 2. Start the server
cd ~/Proyectos/Oeditus/ragex
./start_server.sh
# 3. Test in another terminal (auto-detects the socket for this directory)
./test_socket.sh
The Problem
If you see "Searching..." hanging forever in LunarVim, it means:
- The socket file exists at
$SOCKET_PATH - BUT no process is listening on it (dead socket)
This happens when:
- Server crashes or is killed while socket file remains
- Server gets stuck in Erlang BREAK mode
- Server was redirected to background incorrectly
The Solution
Step 1: Clean Up
# Kill any existing Ragex processes
pkill -f "mix run"
# Remove the dead socket (use the exact path from `ls /tmp/ragex_mcp_*.sock`)
rm -f "$SOCKET_PATH"
Step 2: Start Server Properly
Option A: Interactive (Recommended for debugging)
cd ~/Proyectos/Oeditus/ragex
mix run --no-halt
Watch for:
MCP Socket Server listening on /tmp/ragex_mcp_<...>.sockSocket file verified: /tmp/ragex_mcp_<...>.sockAccept loop started with PID: ...
Option B: Background with logging
cd ~/Proyectos/Oeditus/ragex
./start_server.sh
Step 3: Verify Server is Working
# Test socket communication
./test_socket.sh
You should see:
✓ Socket file exists
✓ Server responded
✓ Socket communication is working!Step 4: Test in LunarVim
" Enable debug mode temporarily to see what's happening
:lua require('ragex').config.debug = true
" Try a command
:Ragex searchTroubleshooting
"Connection refused" error
Symptoms:
- Socket file exists:
ls /tmp/ragex_mcp_*.sockshows the file - But
./test_socket.shfails with "Connection refused"
Cause: Dead socket - file exists but no process listening
Fix:
pkill -f "mix run"
rm -f /tmp/ragex_mcp_*.sock
./start_server.sh
Server crashes immediately
Check logs:
# If using start_server.sh
tail -f /tmp/ragex_server.log
# If running interactively, look for errors in the terminal
Common issues:
- Model not downloaded: Run
mix ragex.models.download - Port conflict: Check if another process is using the socket
- Permission issues: Ensure
/tmpis writable
Stuck in BREAK mode
Symptoms:
- You see
BREAK: (a)bort (c)ontinue...prompt - Server appears hung
Fix:
# Kill the process
pkill -9 -f "mix run"
# Clean up
rm -f /tmp/ragex_mcp_*.sock
# Start fresh
./start_server.sh
LunarVim still hangs
Check server is running:
./test_socket.shEnable debug mode in LunarVim:
-- In ~/.config/lvim/config.lua require('ragex').setup({ debug = true, -- Enable debug logging -- ... rest of config })Check notifications: After running
:Ragex search, look for debug messages in notificationsCheck socket path matches:
-- In LunarVim :lua print(require('ragex').config.socket_path)Should print the socket for the project you're editing, e.g.
/tmp/ragex_mcp_home_user_myproject.sock(or/tmp/ragex_mcp_<port>.sockifDLLB_PORTis set).
Server Management
Start Server
./start_server.sh
Stop Server
pkill -f "mix run"
rm -f /tmp/ragex_mcp_*.sock
Restart Server
pkill -f "mix run"
rm -f /tmp/ragex_mcp_*.sock
./start_server.sh
Check Server Status
# Check if process is running
ps aux | grep "mix run" | grep -v grep
# Check if socket is responsive
./test_socket.sh
What the Server Does
When started, the Ragex application:
Starts the Supervision Tree:
- Graph Store (ETS tables for code graph)
- Embeddings (Bumblebee ML models)
- Vector Store (semantic search)
- File Watcher (auto-reindex)
- AI Provider Registry
- AI Cache & Usage tracking
Starts MCP Servers:
- Socket Server: Unix domain socket at
/tmp/ragex_mcp_<port_or_project>.sock(see "Socket naming" above) - Stdio Server: For stdio-based clients
- Socket Server: Unix domain socket at
Waits for Connections:
- Each client connection spawns a handler process
- Handles MCP JSON-RPC 2.0 requests
- Returns responses via the socket
Performance Tips
- First startup is slow: Models need to load (~1-2 minutes)
- First analysis is slow: Embeddings are generated and cached
- Subsequent operations are fast: Everything is cached
Integration with LunarVim
Once the server is running and ./test_socket.sh succeeds:
Restart LunarVim or reload config:
:LvimReloadTry commands:
:Ragex search :Ragex analyze_file :checkhealth ragexUse keybindings:
<leader>rs " Search <leader>ra " Analyze file <leader>rA " Analyze directory
Need Help?
- Run
./test_socket.shfirst - Check
/tmp/ragex_server.logfor errors - Enable debug mode in LunarVim config
- Look for error messages in LunarVim notifications
Remember: The server must be running in a terminal for the plugin to work!