Skip to content

fix(tools): restore tool reachability status during gateway refresh#4499

Open
bogdanmariusc10 wants to merge 4 commits intomainfrom
4454-icacf-32-gihub-public-tools-are-currently-offline-in-stage
Open

fix(tools): restore tool reachability status during gateway refresh#4499
bogdanmariusc10 wants to merge 4 commits intomainfrom
4454-icacf-32-gihub-public-tools-are-currently-offline-in-stage

Conversation

@bogdanmariusc10
Copy link
Copy Markdown
Collaborator

🔗 Related Issue

Closes #4454
Jira Issue: https://jsw.ibm.com/browse/ICACF-32


📝 Summary

This PR fixes a critical bug where tools from registered gateways were appearing as offline even though the gateways were functional and successfully returning tools during health checks and refresh operations.

Problem: Tools have a reachable boolean field that tracks their availability. When tools were updated during gateway refresh operations (health checks, manual refresh, OAuth flows), the reachable field was never updated. This meant that if a tool was previously marked as reachable=False during a gateway failure, it would remain offline indefinitely, even after the gateway recovered and successfully returned the tool.

Solution: Modified gateway_service.py to ensure tools are marked as reachable when successfully fetched:

  1. _create_db_tool(): Explicitly set enabled=True and reachable=True for newly created tools
  2. _update_or_create_tools(): Added logic to mark existing tools as reachable=True when successfully fetched from gateway during refresh operations

Impact: Tools are now automatically restored to online status when gateways successfully return them, resolving the issue where users couldn't invoke tools despite having functional gateway connections.


🏷️ Type of Change

  • Bug fix
  • Feature / Enhancement
  • Documentation
  • Refactor
  • Chore (deps, CI, tooling)
  • Other (describe below)

🧪 Verification

Check Command Status
Lint suite make lint ✅ Pass
Unit tests make test ✅ Pass
Coverage ≥ 80% make coverage ✅ Pass

✅ Checklist

  • Code formatted (make black isort pre-commit)
  • Tests added/updated for changes (existing tests validate the fix)
  • Documentation updated (if applicable)
  • No secrets or credentials committed

📓 Notes

Root Cause Analysis

The issue was in the _update_or_create_tools() method. When tools were updated during gateway refresh/health checks:

  1. New tools were created via _create_db_tool() which didn't explicitly set reachable=True (relied on model default)
  2. Existing tools were updated at lines 4696-4713, but the reachable field was never updated
  3. If a tool was previously marked as reachable=False (e.g., during a gateway failure), it stayed offline even after successful gateway health checks and tool refreshes

The gateway's reachable status was correctly updated during health checks (gateway_service.py:3827), but the individual tools' reachable status was not propagated.

Code Changes

File: mcpgateway/services/gateway_service.py

Change 1 - New tool creation (lines 4584-4615):

return DbTool(
    # ... existing fields ...
    # Status fields - tools successfully fetched from gateway are reachable
    enabled=True,
    reachable=True,
    # ... rest of fields ...
)

Change 2 - Existing tool update (lines 4697-4700):

# Always mark tool as reachable when successfully fetched from gateway
if not existing_tool.reachable:
    existing_tool.reachable = True
    fields_to_update = True

User Impact

Before: Users reported tools showing as offline in the UI and receiving errors like:

ERROR: Tool 'github-com-read-tools-search-repositories' exists but is currently offline. 
Please verify if it is running.

After: Tools are automatically restored to online status when gateways successfully return them during any refresh operation (health checks, manual refresh, OAuth flows).

Tools were remaining offline even after successful gateway health checks
and tool refreshes because the reachable field was never updated during
the tool update process.

Changes:
- Set reachable=True for newly created tools in _create_db_tool()
- Update existing tools to reachable=True when successfully fetched
  during gateway refresh in _update_or_create_tools()

This ensures tools are automatically marked as online when gateways
successfully return them during health checks, manual refresh, or
OAuth flows.

Signed-off-by: Bogdan-Marius-Catanus <bogdan-marius.catanus@ibm.com>
@bogdanmariusc10 bogdanmariusc10 added ica ICA related issues MUST P1: Non-negotiable, critical requirements without which the product is non-functional or unsafe labels Apr 28, 2026
@bogdanmariusc10 bogdanmariusc10 added api REST API Related item release-fix Critical bugfix required for the release regression High priority regression labels Apr 28, 2026
Signed-off-by: Bogdan-Marius-Catanus <bogdan-marius.catanus@ibm.com>
@bogdanmariusc10 bogdanmariusc10 force-pushed the 4454-icacf-32-gihub-public-tools-are-currently-offline-in-stage branch from 902984a to a227c3a Compare April 28, 2026 12:05
bogdanmariusc10 and others added 2 commits April 29, 2026 10:36
Signed-off-by: Bogdan-Marius-Catanus <bogdan-marius.catanus@ibm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api REST API Related item ica ICA related issues MUST P1: Non-negotiable, critical requirements without which the product is non-functional or unsafe regression High priority regression release-fix Critical bugfix required for the release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ICACF-32] [Gihub public] Tools are currently offline in STAGE

1 participant