Skip to main content

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

subtypeStatusWhat It Does
initializeUndocumentedStarts the SDK session with hooks, MCP servers, and agent settings.
interruptUndocumentedStops the turn that runs now.
can_use_toolUndocumentedAsks for permission to use a tool with the given input.
set_permission_modeUndocumentedSets the permission mode.
set_modelUndocumentedSets the model for the next turns.
set_max_thinking_tokensUndocumentedNo description in the program schema.
rename_sessionUndocumentedSets the title of the session.
set_colorUndocumentedNo description in the program schema.
mcp_statusUndocumentedAsks for the state of all MCP server connections.
file_suggestionsUndocumentedAsks for @ file suggestions for a partial path.
get_context_usageUndocumentedAsks for the use of the context window by category.
get_session_costUndocumentedAsks for the cost summary that /usage prints in print mode.
list_modelsUndocumentedAsks for the models that the worker lets you choose.
get_usageUndocumentedAsks for the data of /usage, with plan limits when they are known.
get_statusUndocumentedAsks for the rows of the /status screen as text.
export_conversationUndocumentedAsks for the conversation as the text that /export writes.
get_memory_dialogUndocumentedAsks for the rows and switches of the /memory dialog.
get_skills_dialogUndocumentedAsks for the rows of the /skills menu.
get_chrome_dialogUndocumentedAsks for the state of the /chrome dialog.
get_chrome_browsersUndocumentedAsks for the browsers that are connected to Claude in Chrome.
select_chrome_browserUndocumentedSwitches Claude in Chrome to the browser that you name.
get_sandbox_dialogUndocumentedAsks for the state of the /sandbox dialog.
get_binary_versionUndocumentedAsks for the version of the binary.
mcp_callUndocumentedCalls an MCP tool without a model turn.
rewind_filesUndocumentedUndoes the file changes made since a user message.
cancel_async_messageUndocumentedRemoves a waiting async user message from the queue.
read_fileUndocumentedReads a file of the session, for a remote sidebar viewer.
list_directoryUndocumentedNo description in the program schema.
get_workspace_diffUndocumentedAsks for the git diff of the workspace.
get_planUndocumentedReads the current plan of plan mode.
seed_read_stateUndocumentedSeeds the cache of read files with a path and a time.
hook_callbackUndocumentedDelivers a hook callback with its input.
register_device_hooksUndocumentedRegisters the hooks of a device with the worker.
upload_device_hook_templateUndocumentedSends a hook template before the device hooks register.
remote_tools_announceUndocumentedA cloud client says which tools it serves.
remote_tool_callUndocumentedForwards one step of a tool call to the attached machine.
remote_plumbing_callUndocumentedCalls a plumbing tool on the attached machine.
remote_tools_probeUndocumentedChecks that an announced machine is still alive.
remote_tools_reannounceUndocumentedA new worker asks the client to announce its tools again.
turn_handoffUndocumentedNo description in the program schema.
mcp_messageUndocumentedCarries one MCP message for an MCP server that the SDK hosts.
mcp_set_serversUndocumentedReplaces the set of MCP servers that the host manages.
reload_pluginsUndocumentedReloads plugins from disk.
reload_skillsUndocumentedReloads skills from disk.
reload_output_stylesUndocumentedReads the output style folders again.
register_repo_rootUndocumentedAdds a folder as a working folder root, and can reload CLAUDE.md, skills, and plugins.
set_cwdUndocumentedMoves the session to a new working folder, like /cd.
claim_sessionUndocumentedNo description in the program schema.
mcp_reconnectUndocumentedReconnects an MCP server that failed.
mcp_toggleUndocumentedTurns an MCP server on or off.
mcp_read_resourceUndocumentedNo description in the program schema.
set_mcp_permission_mode_overrideUndocumentedSets or clears the permission mode of one MCP server.
set_chrome_browser_hintsUndocumentedTells the session which Claude in Chrome browser to prefer.
set_prompt_suggestions_pausedUndocumentedPauses or resumes prompt suggestions.
stop_taskUndocumentedStops a running task.
background_tasksUndocumentedNo description in the program schema.
get_task_outputUndocumentedReads the last 8 KiB of the output of a background task.
apply_flag_settingsUndocumentedMerges settings into the flag settings layer.
get_settingsUndocumentedReturns the merged settings and the settings of each source.
update_settingsUndocumentedWrites settings through the writer of Claude Code.
get_hooks_listingUndocumentedReturns the hooks that the read-only /hooks menu shows.
list_permission_rulesUndocumentedReturns the permission rules and workspace folders that /permissions lists.
elicitationUndocumentedAsks the SDK consumer to handle an MCP elicitation.
request_user_dialogUndocumentedAsks the SDK consumer to show a dialog and return the choice.
submit_feedbackUndocumentedSends a /feedback report with the transcript and a cleaned error log.
remote_control_work_secretUndocumentedAsks the host for a fresh work secret for Remote Control.
oauth_token_refreshUndocumentedAsks the host for a fresh OAuth token after a 401 error.
host_auth_token_refreshUndocumentedAsks the host for a fresh provider credential after a credential failure.
message_ratedUndocumentedRecords a thumbs up or down for a message.
ui_attachUndocumentedA remote screen joins the session.
ui_detachUndocumentedA remote screen leaves the session.
ui_renderUndocumentedNo description in the program schema.
ui_pressUndocumentedA press on a button or link that a plugin drew for a remote screen.
ui_client_moduleUndocumentedAsks for the screen modules of a plugin.
ui_inputUndocumentedA change in an input that a plugin drew for a remote screen.
ui_selectUndocumentedA pick in a select that a plugin drew for a remote screen.
ui_panesUndocumentedAsks for the list of open panes.
ui_pane_showUndocumentedThe person chose which open pane the screen shows.
ui_pane_focusUndocumentedThe keyboard moved between the prompt box and a pane.
ui_closeUndocumentedThe person closed a pane on a remote screen.
ui_scrollUndocumentedThe person scrolled a site that a remote screen draws.
ui_focusUndocumentedThe keyboard moved in a site that a remote screen draws.
ui_copyUndocumentedNo description in the program schema.
ui_prompt_readUndocumentedA plugin reads the draft and cursor of the prompt box.
ui_prompt_fillUndocumentedA plugin puts text in the prompt box as a draft.
ui_prompt_suggestUndocumentedA plugin or the engine shows a suggestion in the prompt box.
ui_read_selectionUndocumentedNo description in the program schema.
ui_prompt_editUndocumentedAn edit in the prompt box of a remote screen.
ui_prompt_autocompleteUndocumentedA remote prompt box asks what the plugins add to its autocomplete list.
successUndocumentedThe request was handled.
errorUndocumentedThe 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​

Change the model, then read the reply
{"type":"control_request","request_id":"req-1","request":{"subtype":"set_model","model":"sonnet"}}
Reply from Claude Code
{"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.

Not Verified

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.