powerful-smartphone-18734
06/19/2025, 2:53 PMchilly-france-44439
06/19/2025, 2:56 PMconfig.mcp
We should maybe first look at self.config.mcp
, and then settings.mcp
, finally if nothing exists, do an empty MCPConfig like we do now.
If self.config.mcp
and settings.mcp
both exists, we should throw a warning message and say we will follow config.mcp
narrow-agent-26548
06/19/2025, 2:56 PMpowerful-smartphone-18734
06/19/2025, 2:56 PMnarrow-agent-26548
06/19/2025, 3:04 PMsessions.py
as requested. Here's what was implemented:
✅ Problem Solved
The original code was ignoring self.config.mcp
(from config.toml) and only checking settings.mcp_config
, causing MCP configurations from config files to be lost.
✅ Solution Implemented
1. Proper priority order: self.config.mcp
> settings.mcp_config
> empty MCPConfig
2. Warning message when both configurations exist, informing that config.mcp
will be used
3. Preserved existing logic for adding OpenHands' default MCP server
4. Added comprehensive tests to verify the behavior
✅ Key Changes
• Replaced the simple settings.mcp_config or MCPConfig(...)
logic with proper priority checking
• Added detection of whether each config source has MCP servers configured
• Added warning logging when both sources are present
• Maintained backward compatibility and existing functionality
✅ Testing
• Created unit tests covering all scenarios (both configs, only settings, only config, neither)
• Verified the logic works correctly with a standalone test
• All pre-commit hooks pass
🔗 Pull Request Created
I've pushed the changes and created a draft pull request: https://github.com/All-Hands-AI/OpenHands/pull/9237
The fix ensures that MCP configurations defined in config.toml
are properly preserved and not overwritten by settings, maintaining the expected configuration hierarchy as requested.chilly-france-44439
06/19/2025, 3:12 PMpowerful-smartphone-18734
06/19/2025, 3:17 PMpowerful-smartphone-18734
06/19/2025, 3:17 PMpowerful-smartphone-18734
06/19/2025, 3:36 PMpowerful-smartphone-18734
06/19/2025, 3:36 PMpowerful-smartphone-18734
06/19/2025, 3:37 PMpowerful-smartphone-18734
06/19/2025, 3:40 PMchilly-france-44439
06/19/2025, 3:54 PMchilly-france-44439
06/19/2025, 3:54 PM112931 - openhandsINFO utils.py:76 - Initializing MCP agent for url='http://localhost:33652/mcp/sse' api_key='******' with SSE connection...
112933 - openhandsINFO client.py:49 - Connected to server with tools: ['fetch_fetch']This is actually the mcp server within the runtime container
chilly-france-44439
06/19/2025, 3:54 PMchilly-france-44439
06/19/2025, 3:55 PMpowerful-smartphone-18734
06/19/2025, 3:58 PMpowerful-smartphone-18734
06/19/2025, 3:58 PMchilly-france-44439
06/19/2025, 4:02 PMchilly-france-44439
06/19/2025, 4:02 PMpowerful-smartphone-18734
06/19/2025, 4:09 PMchilly-france-44439
06/19/2025, 4:10 PMchilly-france-44439
06/19/2025, 4:10 PMchilly-france-44439
06/19/2025, 4:11 PMpowerful-smartphone-18734
06/19/2025, 4:12 PMchilly-france-44439
06/19/2025, 4:13 PMsupergateway
in docs/uusage/mcp.mdx
due to how OpenHands supports stdio MCPnutritious-balloon-65098
06/19/2025, 4:13 PMpowerful-smartphone-18734
06/19/2025, 4:14 PM