# `MingaClaudeBridge.Wire.ControlRequest`
[🔗](https://github.com/jsmestad/minga-claude-bridge/blob/main/lib/minga_claude_bridge/wire/control_request.ex#L1)

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`.

# `can_use_tool`

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

# `initialize`

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

# `mcp_message`

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

# `request`

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

# `t`

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

# `from_wire`

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

Decodes a `control_request` frame.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
