Skip to content

fix(mcp): re-cap mcp dependency below 2.0 - #2941

Merged
itomek merged 3 commits into
mainfrom
tmi/fix-2885-mcp-cap
Aug 13, 2026
Merged

itomek merged 3 commits into
mainfrom
tmi/fix-2885-mcp-cap

Conversation

@itomek

@itomek itomek commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator

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

  • python -m pytest tests/unit/test_mcp_extras.py -v — both new guard tests pass
  • 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
  • After-fix verification: clean-venv pip install -e ".[mcp]" resolves to mcp==1.29.0; from mcp.server.fastmcp import FastMCP succeeds
  • 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)
  • python util/lint.py --all passes
Reproduction evidence (before / after)

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.

itomek added 3 commits August 13, 2026 10:26
setup.py's [mcp] extra pins mcp>=1.1.0,<3.0, but the comment directly
above it still says the dependency is "Capped below 2.0" because
mcp 2.0.0 breaks MCPClient.connect(). The pin and the comment
contradict each other, so a fresh install can silently resolve an
incompatible mcp 2.x.

Add a static packaging test that fails whenever the pin's upper bound
drifts from <2.0 while the comment still claims that cap, so the
contradiction can't return unnoticed. Currently red against the
unfixed setup.py; the next commit fixes the pin.
…n constant

Investigation while this guard was under review found the "breaks
MCPClient.connect()" framing imprecise: MCPClient (src/gaia/mcp/client/
mcp_client.py) never imports the mcp package at all, so that specific
method cannot break from an mcp version bump. The real break is mcp
2.0.0 removing mcp.server.fastmcp (FastMCP -> MCPServer), which every
FastMCP-based server GAIA ships depends on.

Update the test's docstrings and assertion messages to describe the
verified mechanism instead of the stale one, and factor the expected
pin/comment strings into named constants so a legitimate future change
(the client port) only needs to update one place.
main's [mcp] extra pinned mcp>=1.1.0,<3.0, which resolves to mcp 2.0.0
today. That release removed mcp.server.fastmcp (FastMCP renamed to
MCPServer, moved to mcp.server.mcpserver), so every FastMCP-based MCP
server GAIA ships (agent_mcp_server.py, servers/agent_ui_mcp.py,
servers/tui_mcp.py, and servers/docker_mcp.py transitively) fails to
import under it. A prior fix correctly capped this at <2.0; a later
mechanical dependency bump widened it again without the client port
the adjacent comment calls for.

Re-cap at <2.0 (mcp 1.29.0, the version this pin actually resolves to
today) and correct the comment's description of the break -- it named
MCPClient.connect() specifically, but that hand-rolled client imports
no code from the mcp package; the failure is in GAIA's own MCP-server
wrapping code, whose subprocess dies on import.

Porting those servers to the mcp 2.x API is tracked separately since
it needs a live wire-protocol round trip to verify, not just an
import-level check.
@github-actions

Copy link
Copy Markdown
Contributor

Approve with suggestions

This restores the mcp dependency cap to <2.0 — it had drifted to <3.0 while the comment above it still claimed a 2.0 cap, so a fresh pip install 'amd-gaia[mcp]' could pull an mcp 2.x that breaks GAIA's MCP servers. A new packaging test locks the pin and the comment together so they can't silently disagree again. The fix and its justification check out: every server the comment names really does import the module mcp 2.0 removed.

One thing to fix before merge: the new test file's own docstrings still describe the broken state in the present tense — they say the pin "reads <3.0" while the same PR changes it to <2.0. Anyone reading the guard later will be told the bug is still live. It's a two-sentence wording fix.

Real-world evidence

N/A — packaging and test-only change with no runnable user surface; no evidence bundle was produced for this PR. My verdict rests on static review: I confirmed the imports the cap protects and traced the parsing logic by hand, but I could not execute pytest in this environment (the shell was unavailable), so CI's own run of the new tests is the confirmation to watch.

🔍 Technical details

Issues

🟢 Docstrings describe the pre-fix state as current (tests/unit/test_mcp_extras.py:10, :143). Both read as present tense about a pin this PR already corrected — exactly the doc/code contradiction CLAUDE.md calls out.

ships. But the pin previously read ``mcp>=1.1.0,<3.0``, which did NOT enforce
the cap the comment describes: the comment and the enforced version range
contradicted each other, so ``pip install`` could still resolve an mcp 2.x that
breaks those servers.

and at :141:

    setup.py documents the cap with a comment ("Capped below 2.0: mcp 2.0.0
    ... removed mcp.server.fastmcp"), but the pin itself can drift out of
    sync with what the comment claims (it read ``mcp>=1.1.0,<3.0`` before
    #2885). This must fail whenever the comment still claims the dependency
    is capped below 2.0 but the pin is anything other than EXPECTED_MCP_PIN
    — the contradiction must not silently pass.

🟢 Prose wording is now a CI gate (tests/unit/test_mcp_extras.py:149). EXPECTED_CAP_COMMENT_SUBSTRING requires the literal phrase "capped below 2.0", so rewording the comment to e.g. "Pinned below 2.0" reddens CI even with a correct pin. The docstring acknowledges this and the failure message tells you what to do, so it's a defensible trade — just be aware the second test's pin == EXPECTED_MCP_PIN assertion is fully redundant with test_mcp_extra_pin_is_capped_below_2_0; the comment-substring check is its only unique coverage.

🟢 _parse_extra is now duplicated in a third test file — identical bodies in tests/unit/test_packaging.py, tests/unit/test_api_extras.py, and tests/unit/test_mcp_extras.py:52. Following the existing pattern was the right call here, but the next one that needs it should hoist it into tests/unit/conftest.py instead.

Verified

  • The cap's justification is accurate, not assumed: from mcp.server.fastmcp import FastMCP appears in src/gaia/mcp/agent_mcp_server.py:15, src/gaia/mcp/servers/agent_ui_mcp.py:36,246, and src/gaia/mcp/servers/tui_mcp.py:35,1257. docker_mcp.py:10 imports AgentMCPServer, so the "blocked transitively" note in _PORT_INSTRUCTION is correct too.
  • setup.py:230 is the only mcp pin in the repo — no hub agent or sub-package re-declares it, so the single guard covers the whole surface.
  • Line-walking parse in _pin_and_preceding_comment is sound: while j > block_start correctly stops before the "mcp": [ line, and the assert pin_line_idx is not None guard means the tuple[str, str] return annotation holds.

Strengths

  • The guard asserts the enforced range, not the comment's claim about it — which is precisely the failure mode that let <3.0 sit under a "Capped below 2.0" comment in the first place.
  • EXPECTED_MCP_PIN as a single source of truth gives a future cap-lifting change exactly one constant to edit, and _PORT_INSTRUCTION puts the three files that must be ported into the failure message itself, where whoever trips it will actually read it.
  • Static source parsing keeps the test runnable in the CI unit venv that never installs [mcp] — consistent with test_api_extras.py and test_base_keyring_dep.py.

@github-actions

Copy link
Copy Markdown
Contributor

Verdict: Approve with suggestions

This restores the mcp dependency cap to below 2.0 and adds a CI guard so it can't quietly widen again. The fix is right: GAIA's three MCP servers all import the module that mcp 2.0 deleted, so any install that resolved a 2.x would have shipped broken MCP servers.

One thing to fix before merge is cosmetic but misleading: the new test file's docstrings still describe the old, broken state ("the pin currently reads <3.0"), so a future reader will think the bug is still live in the tree the PR fixes.

Worth a follow-up thought: the widening came from an automated dependency bump, and nothing stops the same bump from being proposed again next week. The new guard will now turn that into a red build instead of a silent regression — which is the important half — but telling the dependency bot to leave this one alone would stop the weekly churn entirely.

Real-world evidence

N/A — packaging + tests-only change with no runnable user surface; no evidence bundle was produced for this run. My verdict rests on static review: I confirmed against the checked-out tree that all three MCP servers import the module mcp 2.0 removed, that setup.py contains the only mcp pin in the repo, and that the CI job running these unit tests is triggered by setup.py changes, so the guard actually fires on a future widening. I could not execute the test suite in this environment (shell unavailable), so the new tests are reviewed by reading, not by running — please confirm CI is green.

🔍 Technical details

Verified

  • mcp>=1.1.0,<2.0 is justified: from mcp.server.fastmcp import FastMCP appears in src/gaia/mcp/agent_mcp_server.py:15, src/gaia/mcp/servers/agent_ui_mcp.py:36,246, src/gaia/mcp/servers/tui_mcp.py:35,1257.
  • setup.py:230 is the only mcp version pin in the repo (no hub package or requirements file re-pins it), so the single-source-of-truth framing holds.
  • The guard is reachable: .github/workflows/test_unit.yml:17,26 lists setup.py in its path filter and line 104 runs all of tests/unit/.
  • I traced _parse_extra / _pin_and_preceding_comment against the real setup.py:223-233 block by hand and both resolve correctly (pin mcp>=1.1.0,<2.0, comment run starting at line 224).

🟢 Minor — stale docstrings describe the pre-fix state (tests/unit/test_mcp_extras.py:10, :144)

Both say the pin reads <3.0; after this PR it reads <2.0. As merged, the file documents a bug it just fixed.

ships. Before #2885 the pin itself read ``mcp>=1.1.0,<3.0``, which did NOT
enforce the cap the comment described: the comment and the enforced version
range contradicted each other, so ``pip install`` could still resolve an mcp
2.x that breaks those servers.

And at :141-146, drop the parenthetical "(it currently reads mcp>=1.1.0,<3.0)" the same way.

🟢 Minor — the bump will be re-proposed (.github/dependabot.yml:23-26)

docs/releases/v0.23.0.mdx:158 shows the widening arrived via the grouped python-dependencies bump (#2749). The patterns: ["*"] group will propose mcp majors again every Monday; the guard makes that a red build rather than a merge, but an ignore keeps the noise out:

    # Group all Python dependency updates together to reduce PR noise
    groups:
      python-dependencies:
        patterns:
          - "*"
    ignore:
      # mcp 2.x removed mcp.server.fastmcp — GAIA's FastMCP-based servers must be
      # ported before the cap can lift (#2885). Guarded by test_mcp_extras.py.
      - dependency-name: "mcp"
        update-types: ["version-update:semver-major"]

🟢 Minor — the two tests overlap (tests/unit/test_mcp_extras.py:151, :166)

test_mcp_extra_capped_comment_matches_pin's second assert re-checks what test_mcp_extra_pin_is_capped_below_2_0 already asserts; the unique value is the comment-wording lock. Not wrong — just note that a legitimate cap lift now means editing EXPECTED_MCP_PIN, EXPECTED_CAP_COMMENT_SUBSTRING, setup.py's comment, and two docstrings. Worth considering whether exact-string equality on the pin is the right granularity, since a harmless reformat (<2.0.0, or reordered specifiers) fails the test even though the constraint is unchanged; parsing with packaging.specifiers.SpecifierSet and asserting the upper bound would be tolerant of that. The exact-string style does match the house pattern in test_api_extras.py, so this is a judgment call, not a defect.

🟢 Minor — _parse_extra is now a third verbatim copy (tests/unit/test_packaging.py, test_api_extras.py, test_mcp_extras.py). Fine to leave for now; if a fourth packaging guard appears, promote it to a shared helper in tests/unit/conftest.py.

Strengths

  • The fix names the exact breakage (mcp.server.fastmcp removal) and the exact files that must be ported before the cap lifts — the next person to see a red guard knows precisely what work unblocks it.
  • Guarding the pin and the comment-vs-pin contradiction is the right lesson from fix(mcp): main's mcp dependency cap (<3.0) contradicts its own comment and allows an incompatible mcp 2.x install #2885: the original regression survived because a stale comment made the widened range look intentional.
  • The static, source-text-only approach means the guard runs in the unit-test venv that doesn't install [mcp] — no new CI dependency.

@itomek
itomek merged commit b8e6f31 into main Aug 13, 2026
214 of 230 checks passed
@itomek
itomek deleted the tmi/fix-2885-mcp-cap branch August 13, 2026 16:38
kovtcharov pushed a commit to kovtcharov/gaia that referenced this pull request Aug 17, 2026
…ix the sidecar's code-index root

SkillLibraryToolsMixin imported nothing gaia-agent-specific — it is general
'let the model manage its own skill library' capability, and its four trust
refusals are framework decisions a second agent would have re-derived. It
now lives in gaia.agents.tools.skill_library_tools, is composable by name
(KNOWN_TOOLS['skills']), and the old import path re-exports it.

GaiaAgent's code index was rooted at os.getcwd() — the same wrong cwd its
allowed_paths field documents rejecting (the daemon launches the sidecar
with cwd = the package directory), so code search was sandboxed to the
agent's own source tree and indexed it by default. It now shares
allowed_paths' scope. The base class also moves first in the MRO, matching
every other hub agent so a future mixin method can't silently win over
ChatAgent's.

setup.py's mcp comment is aligned with the block main merged in amd#2941, so
the branches no longer conflict on that hunk.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Dependency updates ready_for_ci Run CI workflows on draft PR without requesting review tests Test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(mcp): main's mcp dependency cap (<3.0) contradicts its own comment and allows an incompatible mcp 2.x install

2 participants