Control Protocol
Control requests let a host program steer a running Claude Code process.
They travel on the same JSON line channel as the stream messages.
The Agent SDK uses them, for example to change the model or to answer a permission question.
A host sends a line with type set to control_request and request.subtype set to set_model. Claude Code answers with a control_response line.
The protocol is on whenever you start claude -p --input-format stream-json --output-format stream-json. You write requests to stdin and read answers on stdout. You choose which requests to send.
Subtypes
The schema does not mark the direction of each request.
Only the Agent SDK pages describe most of them, and no other docs page does, so every row is marked Undocumented.
Source: the program (the bundled schema of 2.1.304).
subtype | Status | What It Does |
|---|---|---|
initialize | Undocumented | Starts the SDK session with hooks, MCP servers, and agent settings. |
interrupt | Undocumented | Stops the turn that runs now. |
can_ | Undocumented | Asks for permission to use a tool with the given input. |
set_ | Undocumented | Sets the permission mode. |
set_ | Undocumented | Sets the model for the next turns. |
set_ | Undocumented | No description in the program schema. |
rename_ | Undocumented | Sets the title of the session. |
set_ | Undocumented | No description in the program schema. |
mcp_ | Undocumented | Asks for the state of all MCP server connections. |
file_ | Undocumented | Asks for @ file suggestions for a partial path. |
get_ | Undocumented | Asks for the use of the context window by category. |
get_ | Undocumented | Asks for the cost summary that / prints in print mode. |
list_ | Undocumented | Asks for the models that the worker lets you choose. |
get_ | Undocumented | Asks for the data of /, with plan limits when they are known. |
get_ | Undocumented | Asks for the rows of the / screen as text. |
export_ | Undocumented | Asks for the conversation as the text that / writes. |
get_ | Undocumented | Asks for the rows and switches of the / dialog. |
get_ | Undocumented | Asks for the rows of the / menu. |
get_ | Undocumented | Asks for the state of the / dialog. |
get_ | Undocumented | Asks for the browsers that are connected to Claude in Chrome. |
select_ | Undocumented | Switches Claude in Chrome to the browser that you name. |
get_ | Undocumented | Asks for the state of the / dialog. |
get_ | Undocumented | Asks for the version of the binary. |
mcp_ | Undocumented | Calls an MCP tool without a model turn. |
rewind_ | Undocumented | Undoes the file changes made since a user message. |
cancel_ | Undocumented | Removes a waiting async user message from the queue. |
read_ | Undocumented | Reads a file of the session, for a remote sidebar viewer. |
list_ | Undocumented | No description in the program schema. |
get_ | Undocumented | Asks for the git diff of the workspace. |
get_ | Undocumented | Reads the current plan of plan mode. |
seed_ | Undocumented | Seeds the cache of read files with a path and a time. |
hook_ | Undocumented | Delivers a hook callback with its input. |
register_ | Undocumented | Registers the hooks of a device with the worker. |
upload_ | Undocumented | Sends a hook template before the device hooks register. |
remote_ | Undocumented | A cloud client says which tools it serves. |
remote_ | Undocumented | Forwards one step of a tool call to the attached machine. |
remote_ | Undocumented | Calls a plumbing tool on the attached machine. |
remote_ | Undocumented | Checks that an announced machine is still alive. |
remote_ | Undocumented | A new worker asks the client to announce its tools again. |
turn_ | Undocumented | No description in the program schema. |
mcp_ | Undocumented | Carries one MCP message for an MCP server that the SDK hosts. |
mcp_ | Undocumented | Replaces the set of MCP servers that the host manages. |
reload_ | Undocumented | Reloads plugins from disk. |
reload_ | Undocumented | Reloads skills from disk. |
reload_ | Undocumented | Reads the output style folders again. |
register_ | Undocumented | Adds a folder as a working folder root, and can reload CLAUDE., skills, and plugins. |
set_ | Undocumented | Moves the session to a new working folder, like /. |
claim_ | Undocumented | No description in the program schema. |
mcp_ | Undocumented | Reconnects an MCP server that failed. |
mcp_ | Undocumented | Turns an MCP server on or off. |
mcp_ | Undocumented | No description in the program schema. |
set_ | Undocumented | Sets or clears the permission mode of one MCP server. |
set_ | Undocumented | Tells the session which Claude in Chrome browser to prefer. |
set_ | Undocumented | Pauses or resumes prompt suggestions. |
stop_ | Undocumented | Stops a running task. |
background_ | Undocumented | No description in the program schema. |
get_ | Undocumented | Reads the last 8 KiB of the output of a background task. |
apply_ | Undocumented | Merges settings into the flag settings layer. |
get_ | Undocumented | Returns the merged settings and the settings of each source. |
update_ | Undocumented | Writes settings through the writer of Claude Code. |
get_ | Undocumented | Returns the hooks that the read-only / menu shows. |
list_ | Undocumented | Returns the permission rules and workspace folders that / lists. |
elicitation | Undocumented | Asks the SDK consumer to handle an MCP elicitation. |
request_ | Undocumented | Asks the SDK consumer to show a dialog and return the choice. |
submit_ | Undocumented | Sends a / report with the transcript and a cleaned error log. |
remote_ | Undocumented | Asks the host for a fresh work secret for Remote Control. |
oauth_ | Undocumented | Asks the host for a fresh OAuth token after a 401 error. |
host_ | Undocumented | Asks the host for a fresh provider credential after a credential failure. |
message_ | Undocumented | Records a thumbs up or down for a message. |
ui_ | Undocumented | A remote screen joins the session. |
ui_ | Undocumented | A remote screen leaves the session. |
ui_ | Undocumented | No description in the program schema. |
ui_ | Undocumented | A press on a button or link that a plugin drew for a remote screen. |
ui_ | Undocumented | Asks for the screen modules of a plugin. |
ui_ | Undocumented | A change in an input that a plugin drew for a remote screen. |
ui_ | Undocumented | A pick in a select that a plugin drew for a remote screen. |
ui_ | Undocumented | Asks for the list of open panes. |
ui_ | Undocumented | The person chose which open pane the screen shows. |
ui_ | Undocumented | The keyboard moved between the prompt box and a pane. |
ui_ | Undocumented | The person closed a pane on a remote screen. |
ui_ | Undocumented | The person scrolled a site that a remote screen draws. |
ui_ | Undocumented | The keyboard moved in a site that a remote screen draws. |
ui_ | Undocumented | No description in the program schema. |
ui_ | Undocumented | A plugin reads the draft and cursor of the prompt box. |
ui_ | Undocumented | A plugin puts text in the prompt box as a draft. |
ui_ | Undocumented | A plugin or the engine shows a suggestion in the prompt box. |
ui_ | Undocumented | No description in the program schema. |
ui_ | Undocumented | An edit in the prompt box of a remote screen. |
ui_ | Undocumented | A remote prompt box asks what the plugins add to its autocomplete list. |
success | Undocumented | The request was handled. |
error | Undocumented | The request failed or was refused. |
Some requests go from Claude Code to the host, such as can_use_tool, elicitation, hook_callback, request_user_dialog, and the token refresh requests.
The host must answer them or the turn waits.
Example
{"type":"control_request","request_id":"req-1","request":{"subtype":"set_model","model":"sonnet"}}
{"type":"control_response","response":{"subtype":"success","request_id":"req-1"}}
The set_model request has a model field. A success reply has subtype: "success" and the request_id.
An error reply has subtype: "error", the request_id, an error text, and sometimes an error_code.
Source: the program (strings of the request and response builders). The fields of the other subtypes are not listed here.
The examples were not run against the program. The request_id and model values are made up.
How It Works
Each reply is a single control_response that matches the request_id.
A sender can cancel its own request with control_cancel_request.
Long requests send control_request_progress lines first.
Related Pages
- Headless and Print Mode
- Stream JSON Messages
- MCP Runtime for the MCP requests (
mcp_status,mcp_call,mcp_toggle)