-
Notifications
You must be signed in to change notification settings - Fork 614
[BUG]: set_gateway_state deletes tools on offlin to online transition for OAuth authorization_code gatewaysΒ #3788
Description
π Bug Summary
When an OAuth authorization_code gateway transitions from offline β online, set_gateway_state re-initializes the MCP connection without a valid OAuth token, receives an empty tool list, and deletes all existing tools, resources, prompts, and their virtual server associations as "stale."
This is a regression from PR #2537, which added a guard for this exact scenario in _refresh_gateway_tools_resources_prompts (line 4548) but missed the same pattern in set_gateway_state (line 2503-2562).
π§© Affected Component
Select the area of the project impacted:
-
mcpgateway- API -
mcpgateway- UI (admin panel) -
mcpgateway.wrapper- stdio wrapper - Federation or Transports
- CLI, Makefiles, or shell scripts
- Container setup (Docker/Podman/Compose)
- Other (explain below)
π Steps to Reproduce
- Register an MCP gateway with
auth_type=oauth,grant_type=authorization_code - Log in as a regular user (not
platform_admin_email), complete OAuth authorization, and fetch tools - Assign the tools to a virtual server
- Wait for health check cycle (~3 minutes) β health check fails because
platform_admin_emailhas no OAuth token for this gateway - Gateway goes offline (
reachable=False), all tools becomereachable=False - Now authenticate as
platform_admin_email(or manually setreachable=Truein DB) - Next health check succeeds β
set_gateway_state(reachable=True)triggers re-initialization - All tools, resources, prompts, and virtual server associations are deleted
π€ Expected Behavior
When set_gateway_state re-initializes an authorization_code gateway and receives an empty result (due to missing auth token), it should preserve existing tools instead of deleting them β the same behavior that _refresh_gateway_tools_resources_prompts already implements at line 4548:
π Logs / Error Output
Paste any relevant stack traces or logs here.
π§ Environment Info
You can retrieve most of this from the /version endpoint.
| Key | Value |
|---|---|
| Version or commit | 1.0.0-RC-2 |
| Runtime | Python 3.12.12, Gunicorn |
| Platform / OS | BottleRocket(EKS) |
| Container | Docker(EKS) |