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 OpenHands starts, it:- Reads the MCP configuration.
- 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
MCP configuration can be defined in:- The OpenHands UI in the
Settings > MCP
page. - The
config.toml
file under the[mcp]
section if not using the UI.
Configuration Options
- SSE Servers
- SHTTP Servers
- Stdio Servers
SSE servers are configured using either a string URL or an object with the following properties:
-
url
(required)- Type:
str
- Description: The URL of the SSE server.
- Type:
-
api_key
(optional)- Type:
str
- Description: API key for authentication.
- Type:
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 configure OpenHands to use the HTTP endpoint:
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:- 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.