Ragex.MCP.Client (Ragex v0.14.1)

View Source

Client for communicating with a running Ragex MCP server via Unix socket.

Allows mix tasks and other callers to delegate work to an already-running Ragex instance instead of starting a new BEAM VM (which would try to allocate GPU memory for Bumblebee a second time).

Usage

if Ragex.MCP.Client.server_running?() do
  {:ok, conn} = Ragex.MCP.Client.connect()
  {:ok, result} = Ragex.MCP.Client.call_tool(conn, "analyze_directory", %{"path" => "."})
  Ragex.MCP.Client.disconnect(conn)
end

Summary

Functions

Calls an MCP tool on the remote server.

Opens a connection to the Ragex MCP socket server.

Closes the connection to the server.

Sends a ping to the server. Returns {:ok, response} or {:error, reason}.

Returns true if a Ragex MCP server is reachable on the Unix socket.

Types

t()

@type t() :: %Ragex.MCP.Client{
  request_id: non_neg_integer(),
  socket: :gen_tcp.socket()
}

Functions

call_tool(conn, tool_name, arguments \\ %{})

@spec call_tool(t(), String.t(), map()) :: {:ok, term()} | {:error, term()}

Calls an MCP tool on the remote server.

Returns {:ok, result} where result is the decoded JSON response, or {:error, reason}.

connect()

@spec connect() :: {:ok, t()} | {:error, term()}

Opens a connection to the Ragex MCP socket server.

Returns {:ok, conn} or {:error, reason}.

disconnect(client)

@spec disconnect(t()) :: :ok

Closes the connection to the server.

ping(conn)

@spec ping(t()) :: {:ok, map()} | {:error, term()}

Sends a ping to the server. Returns {:ok, response} or {:error, reason}.

server_running?()

@spec server_running?() :: boolean()

Returns true if a Ragex MCP server is reachable on the Unix socket.

Sends a ping request and checks for a valid response.