Ragex.MCP.SocketPath (Ragex v0.30.0)

View Source

Resolves the Unix domain socket path used by the MCP socket server and its clients (bin/ragex-mcp, bin/ragex-bridge, Ragex.MCP.Client, editor plugins).

Running ragex "in the wild" means several independent instances may be active on the same machine at once -- one per project, or one per dllb backend port. A single hardcoded /tmp/ragex_mcp.sock causes one instance to steal the socket file out from under another, or causes a client to bridge into the wrong server entirely.

To avoid that, the path is namespaced using this precedence:

  1. RAGEX_MCP_SOCK -- explicit override, used verbatim. Mirrors dllb's own DLLB_SOCK escape hatch.
  2. DLLB_PORT -- if set, this instance is tied to a specific dllb server port, so the socket is namespaced by that port: ragex_mcp_<port>.sock.
  3. Otherwise, namespaced by the identity of the project being served: RAGEX_PROJECT, then RAGEX_AUTO_ANALYZE, then the current working directory, sanitized into ragex_mcp_<sanitized_path>.sock.

Bash callers (bin/ragex-mcp) must implement the exact same precedence so that a launcher script and the BEAM VM it starts always agree on the socket path.

Summary

Functions

Resolves the socket path as a charlist, ready for :gen_tcp :local addresses.

Resolves the socket path as a binary string.

Functions

compute()

@spec compute() :: charlist()

Resolves the socket path as a charlist, ready for :gen_tcp :local addresses.

compute_string()

@spec compute_string() :: String.t()

Resolves the socket path as a binary string.