MingaClaudeBridge.Wire.ControlRequest (minga_claude_bridge v0.1.0)

Copy Markdown View Source

A control_request frame. Claude Code sends these to the bridge (for example mcp_message and can_use_tool), and the bridge sends them to Claude Code (initialize and interrupt). Both directions share this shape, so outbound frames decode back to this struct.

request is a tagged sum over the request subtypes the bridge handles:

  • {:mcp_message, %{server_name, message}} where message is the raw JSON-RPC 2.0 map for the named SDK MCP server.
  • {:can_use_tool, %{tool_name, input, tool_use_id}}
  • {:initialize, %{sdk_mcp_servers, system_prompt, append_system_prompt}} where system_prompt is a list of strings or nil.
  • :interrupt
  • {:unknown_request, subtype} for any other subtype. The bridge must still answer it, usually with an error response, because Claude Code waits for a reply.

request_id is chosen by the sender and echoed by the matching control_response and any control_cancel_request.

Summary

Functions

Decodes a control_request frame.

Types

can_use_tool()

@type can_use_tool() :: %{
  tool_name: String.t(),
  input: MingaClaudeBridge.Wire.Field.json_map(),
  tool_use_id: String.t() | nil
}

initialize()

@type initialize() :: %{
  sdk_mcp_servers: [String.t()] | nil,
  system_prompt: [String.t()] | nil,
  append_system_prompt: String.t() | nil
}

mcp_message()

@type mcp_message() :: %{
  server_name: String.t(),
  message: MingaClaudeBridge.Wire.Field.json_map()
}

request()

@type request() ::
  {:mcp_message, mcp_message()}
  | {:can_use_tool, can_use_tool()}
  | {:initialize, initialize()}
  | :interrupt
  | {:unknown_request, subtype :: String.t()}

t()

@type t() :: %MingaClaudeBridge.Wire.ControlRequest{
  request: request(),
  request_id: String.t()
}

Functions

from_wire(map)

@spec from_wire(MingaClaudeBridge.Wire.Field.json_map()) :: {:ok, t()} | :error

Decodes a control_request frame.