The Command-Line Interface (CLI) provides a powerful interface that lets you engage with OpenHands directly from your terminal.
uvx
for the default fetch
MCP server (more details below).
uvx
:
Create shell aliases for easy access across environments
.bashrc
, .zshrc
, etc.):source ~/.bashrc
or source ~/.zshrc
(depending on your shell).Install OpenHands in home directory without global installation
uv
:~/.openhands/sessions
.
SANDBOX_VOLUMES
to specify the directory you want OpenHands to access (See using SANDBOX_VOLUMES for more info)LLM_MODEL
- the LLM model to use (e.g. export LLM_MODEL="anthropic/claude-sonnet-4-20250514"
)LLM_API_KEY
- your API key (e.g. export LLM_API_KEY="sk_test_12345"
)mv ~/.openhands-state ~/.openhands
to migrate your
conversation history to the new location.-e SANDBOX_USER_ID=$(id -u)
is passed to the Docker command to ensure the sandbox user matches the host user’s
permissions. This prevents the agent from creating root-owned files in the mounted workspace.
The conversation history will be saved in ~/.openhands/sessions
.
>
). Enter your first task or type a command to
begin your conversation.
>
) is displayed:
Command | Description |
---|---|
/help | Show all available interactive commands and their descriptions |
/exit | Exit the application |
/init | Initialize a new repository for agent exploration |
/status | Show conversation details and usage metrics |
/new | Start a new conversation |
/settings | View and modify current LLM/agent settings |
/resume | Resume the agent if paused |
/mcp | Manage MCP server configuration and view connection errors |
/settings
command. Just
follow the prompts:
config.toml
file in the current directory or ~/.openhands/config.toml
.
/init
command helps the agent understand your project by creating a .openhands/microagents/repo.md
file with
project details and structure. Use this when onboarding the agent to a new codebase.
Ctrl-P
. To continue the conversation after pausing, simply
type /resume
at the prompt.
/mcp
command in the CLI. This command provides an interactive interface for managing Model Context Protocol (MCP) servers:
~/.openhands/config.toml
file and will prompt you to restart OpenHands for changes to take effect.
By default, the Fetch MCP server will be automatically configured for OpenHands. You can also enable search engine via the Tavily MCP server by setting the search_api_key
under the [core]
section in the ~/.openhands/config.toml
file.
config.toml
file with MCP server configuration:/help
at any time to see the list of available commands./settings
.a
or always
at the first confirmation prompt to automatically confirm subsequent actions for the current conversation./new
to begin a fresh conversation without restarting the CLI.