Skip to content

fix(connectors): saved MCP connectors pick up catalog updates - #6629

Merged
kovtcharov-amd merged 4 commits into
amd:mainfrom
eshitakundu:fix/4358-connector-catalog-rederive
Nov 4, 2026
Merged

kovtcharov-amd merged 4 commits into
amd:mainfrom
eshitakundu:fix/4358-connector-catalog-rederive

Conversation

@eshitakundu

@eshitakundu eshitakundu commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Connectors you already set up now pick up catalog fixes (a new version pin, command or env var name) the next time GAIA loads them, without reconnecting. GitHub connections saved before #4359 work again: their saved token is passed under the name the server reads.

Why

~/.gaia/mcp_servers.json kept the command, version pin and env names from when the user connected, so catalog fixes like #4356's pins never reached existing users until they ran gaia connectors configure again. After #4359 renamed the GitHub token variable, older GitHub connections send it as GITHUB_TOKEN, which the server ignores, so every call goes out anonymous. The connector's Test also reported the token as missing.

Linked issue

Closes #4358

Changes

  • Each catalog connector's command, args and env are rebuilt from the current catalog when the global mcp_servers.json loads. The user's own fields (disabled, timeout) are kept. Hand-added servers and a project-local mcp_servers.json are used as written.
  • A renamed env key (exactly one key gone and one new) reads the secret from the slot it was saved under. The connector's Test and get_credential find it there too, so the user isn't asked to reconfigure.
  • Updated the GitHub connector troubleshooting note and the pin-bump note in the dependency docs, which both said existing users had to reconfigure.
🔍 Technical details
  • Nothing is written back at load time, so configure / disconnect / set_enabled stay the only writers of the file (test_no_dual_writer). Since the daemon, Agent UI and CLI all read the file, loading also never races to write it.
  • The new env name points at the old keyring slot instead of copying the secret. The next configure or disconnect already deletes the old slot (fix(connectors): pass the GitHub token under the name the server reads #4359).
  • With more than one changed key it doesn't guess. It points at the new slots, and the existing "reconfigure" error appears.
  • Refs are only followed inside the connector's own gaia.connections:<id>: namespace.
  • get_credential and test read mcp_servers.json only when the new slot is empty, so a normal lookup (including Tavily web search) doesn't change.
  • Skipped when keyring isn't installed (base install). configure can't run without it, so no entry in the file came from the catalog.
  • Not covered: the C++ client (cpp/src/mcp_registry.cpp) reads the file on its own. It already refuses connector entries with $keyring env (feat(cpp): resolve $keyring credential references so connector-configured MCP servers work from C++ #2819), so it only matters there for the no-secret connectors (memory, git).

Test plan

  • python -m pytest tests/unit/connectors/test_catalog_rederive.py -q: 11 passed. The old-pin and renamed-token tests fail without the config.py change, and the Test / get_credential tests fail without the handler change.
  • python -m pytest tests/unit/mcp tests/unit/connectors tests/unit/test_mcp_and_agents_follow_gaia_home.py tests/unit/test_gaia_mcp_stub.py tests/unit/test_amd_gaia_urls.py -q: 1585 passed, 15 skipped
  • black, isort, flake8, pylint and bandit (repo settings from util/lint.py) on the changed files, util/check_added_lines.py, util/check_test_lane_coverage.py, and util/check_module_skips.py --workflow test_unit.yml --job unit-tests: all pass. I didn't finish a full util/lint.py --all or pytest tests/unit/ run on Windows. Both are left to CI.

Evidence

  • Agent exposed in the Agent UI: N/A, no UI change.

  • MCP tools / servers: a saved mcp-memory entry pinned to a version that doesn't exist, with the user's "timeout": 60, then gaia mcp tools mcp-memory:

    # main
    📡 Connecting to MCP server 'mcp-memory'...
    ❌ MCP server 'mcp-memory' not found
    
    # this branch
    📡 Connecting to MCP server 'mcp-memory'...
    🔧 Tools from 'mcp-memory' (9):
    🔹 create_entities
    🔹 create_relations
    🔹 add_observations
    ...
    

    The file on disk is byte-for-byte unchanged after the run.

  • CLI: a GitHub connection saved before fix(connectors): pass the GitHub token under the name the server reads #4359 (GITHUB_TOKEN env, token in the old keyring slot), then gaia connectors test mcp-github:

    # main
    mcp-github: FAIL  missing keyring entries: ['GITHUB_PERSONAL_ACCESS_TOKEN']
    
    # this branch
    mcp-github: OK  keyring_entries_present
    
  • HTTP API / REST: N/A, no route changed. The connector Test route calls the same handler method as the CLI above.

Checklist

  • I have linked a GitHub issue above (Closes #N / Fixes #N / Refs #N).
  • I have described why this change is being made, not just what changed.
  • I have run linting and tests locally (python util/lint.py --all, pytest tests/unit/). The lint tools ran on the changed files and the tests on tests/unit/mcp and tests/unit/connectors; see the Test plan.
  • I have attached real-world evidence matched to the surface I changed (see Evidence above), or marked each surface N/A.
  • I have updated documentation if user-visible behavior changed (see CONTRIBUTING.md).

Catalog fixes (a version pin, a new command, a renamed env var) never
reached connectors saved before them. Each catalog connector's command,
args and env are now rebuilt from the catalog when mcp_servers.json
loads, keeping the user's own settings, and a renamed env key reads the
secret from the keyring slot it was saved under.

Closes amd#4358
@github-actions github-actions Bot added documentation Documentation changes mcp MCP integration changes tests Test changes labels Nov 4, 2026
@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Verdict: Approve with suggestions

Connectors people already set up now pick up catalog fixes when GAIA loads them, so a version-pin bump or a renamed variable reaches them without reconnecting. GitHub connections saved before the token rename work again, and the file on disk is never rewritten. The logic is careful: it only treats a change as a rename when exactly one key changed, it never follows a reference into another connector's secrets, and it leaves hand-added servers and project-local files alone. The tests cover each of those cases.

One thing to consider before merging: if someone hand-edited a catalog connector's entry, say to add an extra environment variable or an argument, that edit is now silently replaced on every load. Keeping extra plain-text variables the catalog doesn't define would stop that from catching anyone out.

Real-world evidence

N/A: this job produced no evidence bundle. The PR description has its own before/after runs:

  • gaia mcp tools mcp-memory on an entry pinned to a version that doesn't exist: on main the server isn't found; on this branch it lists 9 tools, and the file on disk is unchanged afterwards.
  • gaia connectors test mcp-github on a token saved before the rename: on main it reports FAIL missing keyring entries; on this branch it reports OK keyring_entries_present.

Nothing was re-run here because the runner has no test environment, so this verdict rests on a static review plus the author's evidence.

🔍 Technical details

Issues

🟢 Hand-edited extras on a catalog entry are dropped (src/gaia/connectors/mcp_server.py:154-161). rederive_catalog_entries replaces env and args wholesale. configure only ever writes catalog keys, so normal entries are unaffected. A hand-added plain value is a different story: a GITHUB_HOST for GitHub Enterprise, or a --repository on mcp-git, now vanishes on every load with no message. Args belong to the catalog, so replacing them is defensible. For env, you could carry over plain-string values whose key isn't in spec.mcp_env_keys:

        rebuilt_env = {
            k: v
            for k, v in (entry.get("env") or {}).items()
            if k not in spec.mcp_env_keys and isinstance(v, str)
        }
        rebuilt_env.update(_rederived_env(spec, entry))
        rebuilt[connector_id] = {
            **entry,
            "command": spec.mcp_command,
            "args": list(spec.mcp_args),
            "env": rebuilt_env,
        }

If you'd rather the catalog own env completely, add one line to the dependency-management note saying hand edits to catalog entries are overwritten.

Checks I ran outside the diff

  • Sibling readers: MCPConfig has no write path, so the rebuilt entries can't leak back to disk. The Agent UI /api/mcp/servers route and MCPClientManager both read through MCPConfig and pick up the new behaviour. ui/routers/connectors.py:663 reads per-agent mcp_servers.json files directly, which is correct because those aren't catalog-owned. The C++ registry is called out in the PR.
  • Docs: no other page still says existing users must reconfigure to get a new pin. Both pages that said so are updated.
  • Tests: tests/unit/connectors/conftest.py forces an in-memory keyring, so the new tests never touch the real OS keyring.
  • Fail-loudly: _saved_secret falls back to the old slot only through the same one-rename rule, and a corrupt mcp_servers.json still raises ConnectorsError rather than reporting a missing key.

Strengths

  • The old secret is reached by pointing at its existing slot, not by copying it, so configure and disconnect stay the only writers and the existing stale-slot cleanup still applies.
  • The tests are aimed at the risky edges: no guessing with two renamed keys, no following a reference into another connector's namespace, project-local files left as written, and the file never rewritten.

eshitakundu and others added 3 commits November 5, 2026 01:20
A value someone added by hand, such as GITHUB_HOST for GitHub
Enterprise, was dropped on every load. Plain env values the catalog
doesn't define are now kept; the catalog's own keys are still rebuilt.

Refs amd#4358
Pins down how a saved catalog connector behaves when the catalog drops it,
switches its command, or shares an id prefix with another connector, and that
malformed saved entries don't break the load. Notes in the dependency docs that
hand edits to a catalog connector's command or args are replaced.
@kovtcharov-amd kovtcharov-amd added this to the v0.25.4 milestone Nov 4, 2026
@kovtcharov-amd
kovtcharov-amd added this pull request to the merge queue Nov 4, 2026
Merged via the queue into amd:main with commit bc46ec6 Nov 4, 2026
54 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Documentation changes mcp MCP integration changes tests Test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(connectors): already-configured MCP connectors never pick up catalog updates

2 participants