Commit b8e6f31
authored
fix(mcp): re-cap mcp dependency below 2.0 (#2941)
Installing GAIA's `[mcp]` extra today can resolve `mcp` 2.0.0, which
silently breaks every MCP server GAIA ships — not just on `main`, but in
the `v0.23.0` tag as already released. mcp 2.0.0 removed the API GAIA's
server code imports (`mcp.server.fastmcp.FastMCP`, renamed to
`MCPServer` and relocated), so any custom agent exposed as an MCP
server, the TUI MCP server, and the Agent UI MCP server all fail to even
import. GAIA's own CI already caught this — the "Custom agent MCP
harness" job has been failing on the `v0.23.0` release branch — but that
job doesn't block merges, so it shipped anyway.
**Verified independently: `main`'s tip, the `v0.23.0` release PR's head
commit, and the `v0.23.0` tag itself all currently carry the broken
`<3.0` cap.** #2885's "not a v0.23.0 blocker" line is inaccurate; a
follow-up comment on that issue covers it separately.
This restores the `<2.0` cap that a routine dependency bump had widened
without doing the accompanying client port its own code comment called
for, corrects that comment's description of *what* breaks (the
hand-rolled `MCPClient.connect()` it named doesn't import the `mcp`
package at all — the real failure is in GAIA's FastMCP-based server
code), and adds a test that fails if the cap widens again without that
port. The actual port to the mcp 2.x API is tracked separately (#2940)
since it needs a live client/server round trip to verify, not just an
import-level fix.
Closes #2885
### Test plan
- [x] `python -m pytest tests/unit/test_mcp_extras.py -v` — both new
guard tests pass
- [x] Before-fix reproduction: `pip install 'mcp>=1.1.0,<3.0'` resolves
to `mcp==2.0.0`; `from mcp.server.fastmcp import FastMCP` raises
`ModuleNotFoundError`
- [x] After-fix verification: clean-venv `pip install -e ".[mcp]"`
resolves to `mcp==1.29.0`; `from mcp.server.fastmcp import FastMCP`
succeeds
- [x] `tests/installer/test_custom_agent_mcp_harness.py` — all 3 pass
under the fixed cap (mcp 1.29.0); controlled A/B in the same venv forced
to mcp 2.0.0 reproduces 1 of the 3 failing ("Unknown tool name" — the
dummy MCP server dies on the same import before it can register its
tool)
- [x] `python util/lint.py --all` passes
<details>
<summary>Reproduction evidence (before / after)</summary>
**Before fix — today's `<3.0` cap resolves to mcp 2.0.0:**
```
$ pip install 'mcp>=1.1.0,<3.0' --dry-run
Collecting mcp<3.0,>=1.1.0
Downloading mcp-2.0.0-py3-none-any.whl.metadata (7.7 kB)
...
Would install ... mcp-2.0.0 ...
```
**Before fix — the API GAIA's MCP servers import does not exist under
it:**
```
$ python -c "from mcp.server.fastmcp import FastMCP"
Traceback (most recent call last):
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'mcp.server.fastmcp'
```
**After fix — clean venv, fixed cap:**
```
$ pip install -e ".[mcp]"
...
$ pip show mcp
Name: mcp
Version: 1.29.0
$ python -c "from mcp.server.fastmcp import FastMCP; print(FastMCP)"
<class 'mcp.server.fastmcp.server.FastMCP'>
```
**Controlled A/B — same venv, same test file, only the mcp version
changes:**
```
$ python -m pytest tests/installer/test_custom_agent_mcp_harness.py -v # mcp==1.29.0
test_custom_agent_dummy_mcp_path_uses_installed_bundle PASSED
test_custom_agent_with_mcp_reports_diagnosable_connection_failure PASSED
test_custom_agent_no_mcp_path_imports_and_emits_no_mcp_traffic PASSED
3 passed
$ pip install mcp==2.0.0 # force-upgrade the same venv
$ python -m pytest tests/installer/test_custom_agent_mcp_harness.py -v # mcp==2.0.0
test_custom_agent_dummy_mcp_path_uses_installed_bundle FAILED
AssertionError: assert 'error' == 'success'
ERROR gaia.agents.base.agent._execute_tool: Unknown tool name. Use only tools listed in your AVAILABLE TOOLS section.
test_custom_agent_with_mcp_reports_diagnosable_connection_failure PASSED
test_custom_agent_no_mcp_path_imports_and_emits_no_mcp_traffic PASSED
1 failed, 2 passed
```
Root cause of that one failure: the harness's own dummy MCP server
fixture (`tests/fixtures/mcp/dummy_server/server.py`) has the same `from
mcp.server.fastmcp import FastMCP` import, so under mcp 2.0.0 it crashes
on startup before it can register its tool — the client never sees it,
hence "Unknown tool name" rather than a connection error.
**Live-CI corroboration (not generated for this PR — already existing,
found while investigating):** `build-installers.yml`'s "Custom agent MCP
harness" job has failed with the identical `assert 'error' == 'success'`
signature on the `v0.23.0` release branch's own CI runs, on both
`ubuntu-latest` and `windows-latest`. That job isn't required for merge,
so it shipped anyway.
</details>1 parent efa2e80 commit b8e6f31
2 files changed
Lines changed: 167 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
221 | 221 | | |
222 | 222 | | |
223 | 223 | | |
224 | | - | |
225 | | - | |
226 | | - | |
227 | | - | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
228 | 231 | | |
229 | 232 | | |
230 | 233 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
0 commit comments