Overview
Model Context Protocol (MCP) is a mechanism that allows OpenHands to communicate with external tool servers. These servers can provide additional functionality to the agent, such as specialized data processing, external API access, or custom tools. MCP is based on the open standard defined at modelcontextprotocol.io.Supported MCPs
OpenHands supports the following MCP transport protocols:How MCP Works
When a conversation starts, OpenHands:- Reads the MCP servers you have configured and enabled.
- Connects to any configured SSE and SHTTP servers.
- Starts any configured stdio servers.
- Registers the tools provided by these servers with the agent.
- OpenHands routes the call to the appropriate MCP server.
- The server processes the request and returns a response.
- OpenHands converts the response to an observation and presents it to the agent.
Configuration
Where you configure MCP servers depends on how you run OpenHands:- Agent Canvas (local or connected to OpenHands Cloud):
Customize > MCP Servers. See Add a Custom Server. - CLI:
openhands mcp add, which writes~/.openhands/mcp.json. See CLI MCP Servers. - SDK: pass
mcp_configto your agent. See the SDK MCP Guide.
Add a Custom Server
To add a server that isn’t in theMarketplace:
- In Agent Canvas, open
Customize > MCP Servers. - Click
Add custom server. - Choose a
Server Typeand fill in the fields for that type (see below). - Click
Test connection. A working server reports how many tools it provides. - Save the server. New conversations can use its tools.
On a local backend, Agent Canvas saves MCP servers in its settings store (by default
~/.openhands/settings.json)
with credentials encrypted. Manage servers from Customize > MCP Servers rather than editing that file. There is no
per-project MCP configuration file.Server Fields
- SHTTP
- SSE
- STDIO
Streamable HTTP is the recommended transport for remote servers.
Server name: A name for the server.URL(required): The server’s endpoint, starting withhttp://orhttps://.Authentication: How OpenHands authenticates to the server.None: No credentials.Bearer token: Enter the token inAPI Key. OpenHands sendsAuthorization: Bearer <token>.Header: Enter custom headers inHeaders, oneNAME=valueper line (for example,X-API-Key=value).OAuth: See OAuth Authentication.
Timeout (seconds)(optional): How long to wait for the server before timing out. Use a longer timeout for servers whose tools run heavy operations such as large file processing.
When to Use Direct Stdio
Direct stdio connections may still be appropriate in these scenarios:- Development and testing: Quick prototyping of MCP servers.
- Simple, single-use tools: Tools that don’t require high reliability or concurrent access.
- Local-only environments: When you don’t want to manage additional proxy processes.
Configuration Examples
- Proxy Servers (SSE/HTTP) - Recommended
- Direct Stdio Servers
For stdio-based MCP servers, we recommend using MCP proxy tools like
Then add each proxy with
supergateway instead of direct stdio connections.
SuperGateway is a popular MCP proxy that converts stdio MCP servers to
HTTP/SSE endpoints.Start the proxy servers separately:Add custom server:localhost works when the agent server runs on the same machine as the proxy. If your conversations run in
Docker or a remote sandbox, use an address that environment can reach.- Custom FastAPI/Express servers: Build your own HTTP wrapper around stdio MCP servers.
- Docker-based proxies: Containerized solutions for better isolation.
- Cloud-hosted MCP services: Third-party services that provide MCP endpoints.
Documenting an Integration for OpenHands
If you maintain an MCP server and want to publish setup steps for OpenHands users:- For Agent Canvas, give the
Add custom servervalues:Server Type,URL, andAuthentication. - For the CLI, give the
openhands mcp addcommand. See CLI MCP Servers. - Don’t write a
config.toml[mcp]section. Current OpenHands releases ignore it. - To give the agent standing instructions (for example, when to call your tools), add them to the repository’s
AGENTS.md. OpenHands loads it into the agent’s context. See Repository Skills.
Manage Installed Servers
In Agent Canvas, openCustomize > MCP Servers to manage installed MCP servers. Use the control on an installed server card to disable it without deleting its configuration or saved credentials. Disabled servers are unavailable to new conversations until you enable them again.
Adding, editing, renaming, or deleting one server does not remove saved credentials for your other servers. Use the editor’s delete action only when you want to remove that server configuration. Editing a disabled server does not enable it.
OAuth Authentication
Some MCP servers (like Notion MCP) require OAuth authentication instead of API keys. OpenHands supports OAuth-based MCP servers through the FastMCP library.How OAuth Works
When you configure an OAuth-enabled MCP server:- First connection: When the agent first attempts to use tools from an OAuth-protected MCP server, OpenHands initiates the OAuth flow
- Browser authentication: A browser window opens automatically for you to authorize access
- Token storage: After authorization, tokens are securely stored locally in
~/.fastmcp/oauth-mcp-client-cache/ - Automatic refresh: FastMCP automatically refreshes tokens as needed
Configuration
- Agent Canvas
- CLI
- SDK
Servers in the
Marketplace that use OAuth, such as Notion, start the authorization flow when you install them.For a custom server, click Add custom server, choose SHTTP or SSE, and set Authentication to OAuth.
Fill in OAuth client ID, OAuth client secret, and OAuth scopes if the server requires them.OAuth MCP servers require user interaction for the initial authentication. This means they may not be suitable for fully automated/headless workflows. For automation, consider using API key-based authentication where available.

