-
Notifications
You must be signed in to change notification settings - Fork 458
configurable auto refresh for automatic tools/prompts/resources sync during health checks #1950
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Thanks for the PR β it covers health-check auto-refresh. For REQ-002 we still need manual refresh API, per-gateway intervals, list_changed event handling, and full tool spec sync (annotations/outputSchema). Tracking those gaps in #1984. |
91499e8 to
eca342c
Compare
β¦sync Add configurable feature to automatically sync gateway tools, resources, and prompts with the database during health checks. When enabled: - Fetches latest tools/resources/prompts from MCP servers - Compares against database state - Performs add/update/delete operations only when changes detected - Tracks updates per-type (tools/resources/prompts) for precise cache invalidation - Only deletes MCP-discovered items (health_check, oauth, federation, update, MCP) - Preserves user-created entries (api, ui, None/legacy) during cleanup - Allows empty server responses to clear stale items (except for auth_code OAuth) - Passes pre-authenticated headers from health check to avoid duplicate OAuth token fetch - Invalidates relevant caches per-gateway for efficiency - Uses fresh_db_session() to avoid holding DB connections during HTTP calls Configuration: - AUTO_REFRESH_SERVERS=false (disabled by default) - Reduces load on MCP servers when disabled Closes #1910, #172 Signed-off-by: Mihai Criveti <[email protected]>
eca342c to
5b0ba9b
Compare
Code Review ChangesRebased onto main, squashed 7 commits into 1, and addressed the following issues: Fixes Applied
Key Implementation Details
Files Changed
All tests pass. |
crivetimihai
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved - created [FEATURE REQUEST]: Full tool list/spec refresh (polling + API + list_changed) #1984 for remaining features
β¨ Feature / Enhancement PR
π Epic / Issue
Closes #1910, #172
π Summary (1-2 sentences)
Added configurable
AUTO_REFRESH_SERVERSfeature that automatically syncs gateway tools, resources, and prompts with the database during health checks. When enabled, the system detects changes from MCP servers and performs add/update/delete operations only when necessary.The tools, prompts, and resources are compared against those stored in the database, and any required add, update, or delete operations are performed.
π§ Usage
Enable via environment variable:
π§ͺ Checks
make lintpassesmake testpassesπ Notes (optional)
flowchart TD A[Health Check Loop] -->|Every HEALTH_CHECK_INTERVAL| B{Gateway Healthy?} B -->|No| C[Handle Failure] B -->|Yes| D{AUTO_REFRESH_SERVERS?} D -->|No| E[Update last_seen] D -->|Yes| F[Fetch tools from MCP Server] F --> G{Any Changes?} G -->|No| E G -->|Yes| H[Sync DB: Add/Update/Delete] H --> I[Invalidate Caches] I --> E