Skip to content

test(mcp): run the MCP client workflow tests offline in CI - #4350

Merged
kovtcharov-amd merged 25 commits into
amd:mainfrom
kovtcharov:claude/mcp-workflow-tests
Sep 26, 2026
Merged

kovtcharov-amd merged 25 commits into
amd:mainfrom
kovtcharov:claude/mcp-workflow-tests

Conversation

@kovtcharov

Copy link
Copy Markdown
Contributor

The only tests that run GAIA's MCP client against a real server were broken and ran in no CI lane. One still checked the gaia mcp add flow removed in #977. The other downloaded unpinned npm servers and broke when one renamed a tool. Both now start a small local server built on the official MCP SDK, so they download nothing and have no version to pin. They move from the allowlist into the offline-integration job.

Stacked on #4344. Merge that first. This PR removes the two allowlist entries #4344 adds, which drops its allowlisted count from 18 to 16.

  • Repaired, not deleted. Every other MCP client and connectors test mocks the server process. These are the only tests that exchange real JSON-RPC with a live server.
  • The workflow file now tests how users add a server today. gaia connectors configure stores the secret in the keyring and writes a reference to it. An agent loads the server, the secret reaches the server's environment, and gaia connectors disconnect removes the server again.

Test plan

  • Before: with Node on PATH, the old files fail 4 of 8 (the pre-feat(connectors): custom MCP server support (gaia connectors mcp) #977 config-write assertions and the renamed sequentialthinking tool)
  • After: pytest tests/mcp/test_mcp_cli_to_agent_workflow.py tests/mcp/test_mcp_sdk_integration.py passes 9 of 9 in about 3 s, offline, with GAIA_HOME/GAIA_DAEMON_HOME isolated, in a clean py3.12 venv with -e ".[api,mcp]"
  • Mutation check: stopping $keyring env resolution in the MCP client fails 2 of the new tests
  • The offline-integration lane's file list passes locally in one session: 468 passed, 11 skipped. tests/integration/test_files_router.py is left out because its file-search tests hang on this Mac. That is unrelated to this PR.
  • tests/unit/mcp + tests/unit/connectors pass: 1117 passed
  • python util/check_test_lane_coverage.py exits 0 (850 files, 16 allowlisted). black, isort, and pylint errors-only are clean on the changed files
  • Watch the Offline Integration Tests job go green on Linux

Fixes #4346

Kalin Ovtcharov added 4 commits September 25, 2026 00:40
Nine test files no CI lane runs had been failing silently against APIs and
contracts that changed underneath them. This brings them back to green
against current main so the next change can put them in a lane.

- test_sdk.py: assert the SDK surface that exists today (process_query via
  Agent.chat, the tool registry instead of the never-public execute_tool,
  openai_server's module-level app, Agent.STATE_* class constants, current
  RAGSDK/AudioClient/KokoroTTS methods, LLMClient as an ABC); drop the
  xfail DatabaseMixin block (it ships as gaia.database.mixin) and the
  placeholder docs-exist check.
- test_multi_caller_equivalence.py: send the X-Gaia-UI header on mutating
  calls and read /api/connectors' "connectors" shape.
- test_memory_integration.py: fresh installs are schema v4.
- test_memory_api_integration.py: consolidation is 503 until a chat session
  registers a consolidator, and runs it once one has.
- test_documents_router.py: two fixtures indexed for real and needed Lemonade.
- test_tui_control_e2e.py: give the pty a size and a TERM like a terminal.
- test_ui_email_scope_consent.py: the agent now declares microsoft_work too;
  drop three tests of the in-process /v1/email mount the UI no longer has.
- test_lemonade_embedded_lifecycle.py: llamacpp:cpu has no macOS build.
- test_email_mcp_stdio_parity.py: docstring said no Lemonade; triage uses it.
- test_vlm_integration.py: deleted. A script that returned booleans instead
  of asserting, so it could not fail, and it called a removed constructor arg.

Refs amd#4205
…blocking

43 test files ran in no CI lane, so they looked green on every PR whether
they worked or not, and nothing stopped the count from growing. Now every
test file is either run by a lane or listed with the reason CI can't run it,
and lint fails the moment a new file is neither.

- test_unit.yml gains an offline-integration job for the 23 files that need
  no Lemonade, live account or AMD hardware (with Go for the TUI e2e and the
  [mcp] extra for the SDK and MCP-server tests).
- test_email_agent_unit.yml runs test_ui_email_scope_consent.py.
- util/test_lane_allowlist.yml lists the 18 that need a live Lemonade
  Server, a real Gmail account, a self-hosted model runner, npm-fetched MCP
  servers, or are hand-run scripts, each with its reason.
- util/lint.py runs check_test_lane_coverage.py as a blocking check
  (--test-lanes, and part of --all); lint.yml re-runs when the allowlist
  changes.

Fixes amd#4205
The Agent UI wrote Document Library uploads and chat attachments to the real
~/.gaia even when GAIA_HOME pointed elsewhere, so the document and file router
tests left files in the developer's GAIA home on every run.

- The documents dir, the uploads dir and the static uploads mount now resolve
  GAIA_HOME at call time; the agent's writable scope follows the same dir.
- A relocated documents dir is added as a document root so reindexing a
  dropped file still works when GAIA_HOME is outside the home directory.
- A GAIA_HOME that is the home directory or above it is refused: the server
  deletes files in <GAIA_HOME>/documents as its own, and there that is the
  user's real Documents folder.
- The router tests run under a fake home with GAIA_HOME set elsewhere, and
  fail if anything appears under <home>/.gaia.

Fixes amd#4347
The only tests that drive GAIA's MCP client against a real server were
broken and ran in no lane: one still asserted the removed `gaia mcp add`
flow, the other fetched unpinned npm servers and broke on a tool rename.

Both now spawn a local stdio server built on the official MCP SDK, so
nothing is downloaded and there is no version to pin. The workflow file
follows today's path end to end: `gaia connectors configure` writes a
`$keyring` reference, an agent loads it, the secret reaches the server's
environment, and `gaia connectors disconnect` removes it. The manager file
covers connect, tool schemas, calls, tool errors, a server that cannot
start, and reload following the config file.

They move from the lane allowlist into the offline-integration job.

Fixes amd#4346
The file-search tests walked the real home directory, so on a developer
machine one test ran past two minutes, and the results depended on what
that user owned. Most assertions were hedged with "if found" because the
fixture lived under ~/.gaia, which the search skips as hidden.

The search tests now point HOME/USERPROFILE at a temp dir and write their
files into its Documents folder, so each one asserts the exact result.
The file runs in about 4 seconds with the real HOME set.

Refs amd#4205
# Conflicts:
#	tests/test_vlm_integration.py
…free box

Both files this PR repairs still failed in the offline lane, so the "534
passed" claim held only on the author's machine.

The memory test built its URL by interpolating a local-timezone stamp. At
a negative UTC offset the "-" is URL-safe and it passes; on a UTC runner
the "+00:00" decodes to a space, fromisoformat rejects it, and the
endpoint correctly 422s. Passing the stamp through the client's params
lets it percent-encode, and a second pinned +00:00 case means the test
now catches this from any timezone rather than only from UTC.

The TUI test set TERM to get color, but termenv treats any environment
with CI set as "not a TTY" before it looks at TERM or the pty, so
lipgloss dropped to the Ascii profile and rendered no escapes at all for
format=ansi to return. CLICOLOR_FORCE is the documented override, and
NO_COLOR outranks it, so both it and CLICOLOR are cleared.

Also resolves the merge with main: amd#4290 removed only one of this file's
three fallback_model uses, and VLMClient no longer takes that argument,
so the deletion stands.
…ew live-Lemonade suite

tests/test_ui_email_scope_consent.py was added to the email lane's pytest
command but not to its paths filters, so a PR editing only that file
still ran it nowhere -- while the new checker counted it as covered,
because the checker asks whether a lane names a file, not whether any
trigger reaches that lane. Listed in both the push and pull_request
blocks, next to the other individually-named tests/test_email_* entry.

Merging main brought tests/integration/test_lemonade_predownload_checks.py,
which the gate correctly flagged as run by no lane. It takes
require_lemonade, so it is allowlisted rather than wired offline.
uploads_dir() runs inside create_app(), which is not a request context, so
the new guard's HTTPException surfaced as a raw
"fastapi.exceptions.HTTPException: 500: ..." out of `gaia chat --ui`. The
user sees a stack trace for a mistake they could have fixed in one step.

It now raises UnsafeGaiaHomeError, and both launch paths -- `gaia chat --ui`
and `python -m gaia.ui.server` -- print the message and exit 64 (EX_USAGE,
the code gaia uninstall already uses for the same misconfiguration).

The structural test itself moves to gaia.config as
unsafe_gaia_home_reason(), which uninstall_command now calls instead of
keeping a second copy. Its messages, tiers and exit codes are unchanged;
it keeps its own identity/marker check on top. The UI copy had also
dropped the filesystem-root case, which it now inherits for free.

UnsafeGaiaHomeError moves to gaia.config alongside it and stays importable
from uninstall_command, where it was defined and is still imported from.
@kovtcharov-amd

Copy link
Copy Markdown
Collaborator

No problem found in this PR — its two red tests were inherited from #4343, not caused here, and both are now fixed. Merged the updated stack in, so this should go green on its own merits.

All 9 of the repaired MCP tests already passed in this PR's own lane run. The only failures were the memory and TUI tests from the bottom of the stack: one that only passed in a negative-UTC timezone, one that could never pass in CI at all. Details on #4343.

One number in the description needs a nudge: the allowlisted count is now 17, not 16. #4344 picked up a new live-Lemonade file from main, so this PR still removes exactly its own two entries — the base it subtracts from just moved.

🔍 Technical details

Merged claude/test-lane-blocking (which carries the updated claude/test-lane-triage + main) — clean, no conflicts. python util/check_test_lane_coverage.py after the merge:

[OK] 879 test file(s) across 7 root(s) are all named by a lane or allowlisted (78 workflow file(s) scanned, 17 allowlisted).

19 (#4344, including tests/integration/test_lemonade_predownload_checks.py from main) − 2 (removed here) = 17. util/lint.py --test-lanes passes.

Local run is not evidence here, and I want to be explicit about why. 7 of the 9 tests fail on my box with RuntimeError: Failed to connect to MCP server 'fixture': Server closed connection. That is not the server misbehaving — it is tests/mcp/fixtures/fixture_mcp_server.py dying at import before it can speak:

$ python tests/mcp/fixtures/fixture_mcp_server.py
ImportError: cannot import name 'MCPServer' from 'mcp.server'

My global env has mcp==1.27.0, below the mcp>=2.0.0,<3.0 floor the lane installs. Verified in a clean venv at the floor:

mcp 2.2.0 -> MCPServer imports OK

So the fixture server is correct and the lane is the real check — where all 9 passed. Worth knowing that a contributor below the floor gets a misleading "Server closed connection" rather than the ImportError, since the child's stderr is not surfaced.

Unrelated red: pr-review / run failed with no error in its log beyond credential teardown — bot infrastructure, matching the API rate-limit failures on the sibling PRs in this stack.

@github-actions github-actions Bot added documentation Documentation changes devops DevOps/infrastructure changes tests Test changes labels Sep 26, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Verdict: Approve

The rewrite is clean. Replacing the npx/uvx downloads with a local fixture server that speaks real JSON-RPC over stdio is the right approach — no version pins to rot, no network required, and the client is still exercised against an independently-implemented server. The search_root fixture properly sandboxes the home-directory walk that was causing hangs. The connectors-based workflow test tracks the actual user flow since #977.

Two minor observations (not merge blockers):

🟢 test_add_server_raises_when_server_cannot_start uses match="broken" — this works because the error includes the server name, but a bare pytest.raises(RuntimeError) paired with the list_servers() == [] assertion already proves the invariant without coupling to the message template.

🟢 The offline-integration job installs pymupdf directly (uv pip install --system … pymupdf) without a pin, while the rest of the suite uses whatever pyproject.toml resolves. Not a current problem, but worth aligning to avoid a divergence if PyMuPDF ships a breaking binary release.

🔍 Technical details

Error match: tests/mcp/test_mcp_sdk_integration.py:75 — "Failed to connect to MCP server 'broken'" does contain "broken", so the match holds. Risk is it survives an unrelated message-format change that happens to keep "broken" in the string.

pymupdf pin: test_unit.yml offline-integration install step — the existing unit-tests job picks the version from pyproject.toml via -e ".[dev]"; this job installs it loose. A one-line pymupdf==<same-pin> or moving it into the extras would close the gap.

@github-actions github-actions Bot added the cli CLI changes label Sep 26, 2026
# Conflicts:
#	.github/workflows/test_unit.yml
#	util/test_lane_allowlist.yml
@kovtcharov-amd
kovtcharov-amd added this pull request to the merge queue Sep 26, 2026
Merged via the queue into amd:main with commit 77cf8b1 Sep 26, 2026
25 of 28 checks passed
@kovtcharov-amd
kovtcharov-amd deleted the claude/mcp-workflow-tests branch September 26, 2026 04:54
github-merge-queue Bot pushed a commit that referenced this pull request Sep 28, 2026
…4353)

About 300 unit tests never ran in CI. Their files skip as a whole when a
hub wheel (`gaia_agent_chat`, `gaia_agent`, `gaia_agent_email`) or an
optional extra is missing. The unit lane lacks them, but it still names
the files, so the lane check counted them as covered. With this PR, each
file runs in a lane that installs what it needs, and a lane fails when a
file skips as a whole without an allowlist entry saying which lane runs
it.

Stacked on #4344. Merge #4343 and #4344 first.

- **The new guard runs inside each lane**, right after install. It
collects the job's own pytest commands in that lane's environment, so it
sees what the lane actually runs. It reports the skipping file by name.
This matters because a file that imports a skipping helper is otherwise
blamed on the helper's line: `test_chat_inline_web_ssrf.py` was hidden
that way.
- **Two moved files needed repairs to pass together.**
`test_chat_fix_contracts.py` picked up file tools leaked from earlier
tests. `test_chat_system_prompt_budget.py` evicted the chat agent module
at collection, so other files' patches stopped hitting it.
- **Two files stay allowlisted with no lane, for an owner to decide.**
`test_profilespec_characterization.py` has 11 golden rows that drifted,
and its docstring says golden updates need sign-off.
`test_tool_loader_token_budget.py` has 4 token and tool-count pins that
are stale, and even re-pinned, one ratio is over budget.

Overlaps: #4350 is also stacked on #4344 and edits the
offline-integration list and the allowlist, so expect a small conflict
there. #4038, #3721, #3669, #3812 and #3072 touch other parts of
`test_unit.yml` and `test_gaia_agent.yml`.

## Test plan
- [x] Before: `python util/check_module_skips.py --workflow
test_unit.yml --job unit-tests` with no `module_skips` entries reports
80 files skipping wholesale and exits 1
- [x] After: the guard exits 0 for all 7 guarded jobs, each run in a
clean py3.12 venv built from that job's install step
- [x] `python util/check_test_lane_coverage.py` and `python util/lint.py
--test-lanes` pass (31 module-skip entries verified)
- [x] New tests: `pytest tests/unit/test_check_module_skips.py
tests/unit/test_check_test_lane_coverage.py` passes 64. They include a
real `--collect-only` over a temp repo
- [x] Chat-lane files in the chat env: 421 passed. Before the two test
repairs, 2 failed when run together
- [x] Flagship-lane files in the gaia env: 59 passed.
`test_mcp2_server.py` plus the MCP transcript tests in the MCP env: 27
passed
- [x] Email unit lane's full command plus `test_synthetic_mbox.py`: 4980
passed
- [x] The 4 newly unskipped files in the unit job (docx, pptx,
reportlab, slack): 60 passed. Full `tests/unit/` in that env: 14509
passed, 23 failed. The failures are in 3 files (uninstall, CLI smoke,
Lemonade ASR) that also fail when run alone. They come from this Mac's
setup: `GAIA_HOME` isolated and `gaia` not on PATH. This PR changes no
code those files exercise
- [x] `actionlint` is clean on the 6 edited workflows. `black`, `isort`,
and `pylint --errors-only` are clean on the changed Python
- [ ] Watch the MCP lane's Windows leg run `test_mcp2_server.py` and the
guard. They were only run on macOS locally

Fixes #4206

---------

Co-authored-by: Kalin Ovtcharov <[email protected]>
Co-authored-by: Kalin Ovtcharov <[email protected]>
Co-authored-by: Ovtcharov <[email protected]>
Co-authored-by: Claude Opus 5 <[email protected]>
Co-authored-by: f <f@f>
Co-authored-by: probe <probe@local>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI changes devops DevOps/infrastructure changes documentation Documentation changes tests Test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test(mcp): two MCP workflow tests download unpinned servers and are broken

2 participants