Add API endpoint to refresh the registry cache#5268
Merged
Conversation
Adds POST /api/v1beta/registry/{name}/refresh so API clients (e.g. the
UI) can force a refresh of the server-side registry cache without
restarting thv serve or waiting for the 1-hour TTL.
Mirrors the CLI's `thv registry list --refresh` behavior: type-asserts to
CachedAPIRegistryProvider and calls ForceRefresh().
Closes #5266
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5268 +/- ##
==========================================
+ Coverage 68.17% 68.25% +0.08%
==========================================
Files 618 618
Lines 63122 63205 +83
==========================================
+ Hits 43033 43143 +110
+ Misses 16878 16841 -37
- Partials 3211 3221 +10 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
peppescg
approved these changes
May 12, 2026
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.
Summary
When ToolHive is configured with a custom registry API (
registry_api_url),thv servecaches the registry data in memory for 1 hour. If the upstream registry changes during that window, API clients (like the UI) see stale data and have no way to ask for fresh data short of restarting the server.This adds
POST /api/v1beta/registry/{name}/refreshso the UI (or any API client) can force a refresh on demand. It does the same thing the CLI'sthv registry list --refreshalready does: type-asserts the provider toCachedAPIRegistryProviderand callsForceRefresh().Closes #5266
Type of change
Test plan
pkg/api/v1/registry_test.go:registry_unavailablecodetask lint-fixpassesDoes this introduce a user-facing change?
Yes — new API endpoint
POST /api/v1beta/registry/{name}/refresh(currently onlydefaultis supported). Returns{"status": "refreshed"}on success.🤖 Generated with Claude Code