fix(tools): restore tool reachability status during gateway refresh#4499
Open
bogdanmariusc10 wants to merge 4 commits intomainfrom
Open
fix(tools): restore tool reachability status during gateway refresh#4499bogdanmariusc10 wants to merge 4 commits intomainfrom
bogdanmariusc10 wants to merge 4 commits intomainfrom
Conversation
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>
Signed-off-by: Bogdan-Marius-Catanus <bogdan-marius.catanus@ibm.com>
902984a to
a227c3a
Compare
…ly-offline-in-stage
Signed-off-by: Bogdan-Marius-Catanus <bogdan-marius.catanus@ibm.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🔗 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
reachableboolean field that tracks their availability. When tools were updated during gateway refresh operations (health checks, manual refresh, OAuth flows), thereachablefield was never updated. This meant that if a tool was previously marked asreachable=Falseduring a gateway failure, it would remain offline indefinitely, even after the gateway recovered and successfully returned the tool.Solution: Modified
gateway_service.pyto ensure tools are marked as reachable when successfully fetched:_create_db_tool(): Explicitly setenabled=Trueandreachable=Truefor newly created tools_update_or_create_tools(): Added logic to mark existing tools asreachable=Truewhen successfully fetched from gateway during refresh operationsImpact: 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
🧪 Verification
make lintmake testmake coverage✅ Checklist
make black isort pre-commit)📓 Notes
Root Cause Analysis
The issue was in the
_update_or_create_tools()method. When tools were updated during gateway refresh/health checks:_create_db_tool()which didn't explicitly setreachable=True(relied on model default)reachablefield was never updatedreachable=False(e.g., during a gateway failure), it stayed offline even after successful gateway health checks and tool refreshesThe gateway's
reachablestatus was correctly updated during health checks (gateway_service.py:3827), but the individual tools'reachablestatus was not propagated.Code Changes
File:
mcpgateway/services/gateway_service.pyChange 1 - New tool creation (lines 4584-4615):
Change 2 - Existing tool update (lines 4697-4700):
User Impact
Before: Users reported tools showing as offline in the UI and receiving errors like:
After: Tools are automatically restored to online status when gateways successfully return them during any refresh operation (health checks, manual refresh, OAuth flows).