Add Skills API client for registry extension#4173
Conversation
There was a problem hiding this comment.
Large PR Detected
This PR exceeds 1000 lines of changes and requires justification before it can be reviewed.
How to unblock this PR:
Add a section to your PR description with the following format:
## Large PR Justification
[Explain why this PR must be large, such as:]
- Generated code that cannot be split
- Large refactoring that must be atomic
- Multiple related changes that would break if separated
- Migration or data transformationAlternative:
Consider splitting this PR into smaller, focused changes (< 1000 lines each) for easier review and reduced risk.
See our Contributing Guidelines for more details.
This review will be automatically dismissed once you add the justification section.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #4173 +/- ##
==========================================
+ Coverage 69.22% 69.29% +0.07%
==========================================
Files 464 466 +2
Lines 46639 46774 +135
==========================================
+ Hits 32286 32414 +128
+ Misses 11880 11872 -8
- Partials 2473 2488 +15 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
8415d10 to
54d8a97
Compare
PR size has been reduced below the XL threshold. Thank you for splitting this up!
|
✅ PR size has been reduced below the XL threshold. The size review has been dismissed and this PR can now proceed with normal review. Thank you for splitting this up! |
54d8a97 to
b4e1ab2
Compare
The toolhive-registry-server exposes a Skills API as a ToolHive-specific extension under /v0.1/x/dev.toolhive/skills. This adds an HTTP client to query that API, following the same patterns as the existing server client. - Extract shared HTTP client builder and error types into shared.go so both the server client and new skills client reuse the same security controls (private IP policy, auth token injection, error handling with LimitReader) - Add SkillsClient interface with GetSkill, GetSkillVersion, ListSkills, SearchSkills, and ListSkillVersions methods - Add RegistryHTTPError with Unwrap() for structured 401/403 handling - Migrate existing server client to use the shared error type - Add comprehensive table-driven tests with httptest Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
b4e1ab2 to
97d4682
Compare
PR #4173 added SkillsClient for querying the registry's skills extension API. This wires that client into the registry provider layer so callers can discover skills through the same Provider interface used for servers. - Extend Provider interface with GetSkill, ListSkills, SearchSkills - Add default empty implementations on BaseProvider (inherited by Local/Remote providers that don't serve skills) - Add real implementations on APIRegistryProvider that delegate to the SkillsClient with appropriate timeouts - CachedAPIRegistryProvider inherits skills methods via embedding (uncached pass-through for now) - Regenerate mock provider Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
/v0.1/x/dev.toolhive/skills, but the toolhive client has no way to query it. This adds an HTTP client so that registry providers can discover skills.shared.goso both the existing server client and the new skills client reuse identical security controls (private IP policy, auth token injection viaauth.WrapTransport, error body size limits viaio.LimitReader).SkillsClientinterface withGetSkill,GetSkillVersion,ListSkills,SearchSkills, andListSkillVersionsmethods.RegistryHTTPErrorwithUnwrap()so 401/403 responses are detectable viaerrors.Is(err, ErrRegistryUnauthorized).RegistryHTTPErrortype for consistency.Type of change
Test plan
task test)task lint-fix)Changes
pkg/registry/api/shared.gobuildHTTPClienthelper,RegistryHTTPError/ErrRegistryUnauthorizederror types,newRegistryHTTPErrorhelperpkg/registry/api/skills_client.goSkillsClientinterface andmcpSkillsClientimplementation with auto-paginationpkg/registry/api/skills_client_test.gopkg/registry/api/client.gobuildHTTPClient()andnewRegistryHTTPError()from shared.goDoes this introduce a user-facing change?
No. This is an internal client library addition. A follow-up PR will wire it into
APIRegistryProvidervia aSkillsProviderinterface.Special notes for reviewers
SkillsClientfromClient: The skills API lives under/v0.1/x/dev.toolhive/(a ToolHive extension), not the core MCP Registry spec. Keeping them as separate interfaces avoids conflating two API contracts.auth.TokenSourceand wraps the transport identically to the server client. When registry auth is fully wired (PR Wire non-interactive registry auth for serve mode #4111), skills auth will work automatically.RegistryHTTPErrorwithUnwrap(): ReturnsErrRegistryUnauthorizedfor 401/403, enabling callers to useerrors.Is()without inspecting status codes directly.feat/registry-skills-provider) will addSkillsProviderinterface and implement it onAPIRegistryProvider/CachedAPIRegistryProvider.Generated with Claude Code