PtcRunner.Upstream.Transport behaviour (PtcRunner v0.12.0)

Copy Markdown View Source

Behaviour for root-owned upstream client transports.

Transports return PtcRunner.Upstream.Result tuples and normalize any protocol-specific envelopes before values reach tool/call.

Summary

Functions

Start a transport GenServer with :trap_exit temporarily enabled in the caller, so a child that fails during init/1 surfaces as {:error, reason} instead of crashing the (often unsupervised) caller. The caller's original :trap_exit flag is restored afterward.

Types

call_opts()

@type call_opts() :: [timeout: pos_integer(), max_response_bytes: pos_integer()]

server_name()

@type server_name() :: String.t()

tool_name()

@type tool_name() :: String.t()

tool_schema()

@type tool_schema() :: map()

upstream()

@type upstream() :: map()

Callbacks

call(upstream, tool_name, args, call_opts)

@callback call(upstream(), tool_name(), args :: map(), call_opts()) ::
  PtcRunner.Upstream.Result.t()

list_tools(upstream)

@callback list_tools(upstream()) ::
  {:ok, [tool_schema()]}
  | {:error, PtcRunner.Upstream.Result.reason(), String.t()}

Functions

start_trapped(module, name, config)

@spec start_trapped(module(), server_name(), map()) :: GenServer.on_start()

Start a transport GenServer with :trap_exit temporarily enabled in the caller, so a child that fails during init/1 surfaces as {:error, reason} instead of crashing the (often unsupervised) caller. The caller's original :trap_exit flag is restored afterward.

Shared by the stateful MCP transports (McpHttp, McpStdio).