fix(mcp): preserve concurrent OAuth manager refresh

This commit is contained in:
Teknium 2026-07-17 01:46:59 -07:00
parent cf3ae7c59c
commit 4dc2b7be0f
2 changed files with 16 additions and 1 deletions

View file

@ -11425,7 +11425,6 @@ def _run_dashboard_mcp_oauth(flow, cfg: dict) -> None:
reconnect_mcp_server(flow.server_name)
except Exception:
manager.evict(flow.server_name, hermes_home=flow.hermes_home)
storage.restore(backup, only_if_absent=True)
manager.restore_entry(
flow.server_name,

View file

@ -88,6 +88,22 @@ def test_manager_can_restore_removed_entry_after_failed_reauth(tmp_path, monkeyp
assert manager.get_or_build_provider("shared", "https://mcp.example", {}) is provider
def test_manager_restore_entry_preserves_newer_concurrent_entry(tmp_path, monkeypatch):
from tools.mcp_oauth_manager import MCPOAuthManager
monkeypatch.setenv("HERMES_HOME", str(tmp_path))
_set_interactive_stdin(monkeypatch)
manager = MCPOAuthManager()
old_provider = manager.get_or_build_provider("shared", "https://old.example", {})
old_entry = manager.remove("shared")
new_provider = manager.get_or_build_provider("shared", "https://new.example", {})
manager.restore_entry("shared", old_entry)
assert manager.get_or_build_provider("shared", "https://new.example", {}) is new_provider
assert new_provider is not old_provider
pytest.importorskip(
"mcp.client.auth.oauth2",
reason="MCP SDK 1.26.0+ required for OAuth support",