DatagroutConduit.Transport.Behaviour behaviour (DataGrout Conduit v0.6.0)

Copy Markdown View Source

Behaviour for MCP/JSONRPC transport implementations.

Both transports send HTTP POST requests to the remote server. The transport is responsible for framing and parsing the protocol envelope.

Summary

Callbacks

Build a configured Req client for the given endpoint.

Send a request and return the parsed result body.

Types

connect_opts()

@type connect_opts() :: %{
  url: String.t(),
  identity: DatagroutConduit.Identity.t() | nil,
  auth: DatagroutConduit.Client.auth() | nil
}

request_opts()

@type request_opts() :: %{
  method: String.t(),
  params: map(),
  id: String.t() | integer()
}

Callbacks

connect(connect_opts)

@callback connect(connect_opts()) :: {:ok, Req.Request.t()} | {:error, term()}

Build a configured Req client for the given endpoint.

send_request(t, request_opts)

@callback send_request(Req.Request.t(), request_opts()) ::
  {:ok, map()} | {:ok, map(), String.t() | nil} | {:error, term()}

Send a request and return the parsed result body.

MCP transport may return {:ok, result, session_id} with the mcp-session-id response header. JSON-RPC transport returns {:ok, result}.