-
Notifications
You must be signed in to change notification settings - Fork 103
Fix provider search prioritization to show official providers first #179
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
base: main
Are you sure you want to change the base?
Fix provider search prioritization to show official providers first #179
Conversation
Fixes hashicorp#178 The search_providers tool was returning community providers before official ones in search results. For example, searching for 'keycloak' would show mrparkers/keycloak (community) before keycloak/keycloak (official). Changes made: 1. Enhanced search_providers.go to use Registry v2 provider list API - Fetches provider tier information (official/partner/community) - Implements tier-based sorting: official > partner > community - Maintains relevance-based sorting within each tier - Falls back to original behavior if provider list unavailable 2. Modified registry.go to support test overrides - Added SendRegistryCallFn variable for mocking in tests - Allows unit tests to run without network dependencies 3. Added unit tests: - sort_test.go: Tests tier-based sorting logic - search_providers_test.go: Integration test with mocked responses - Ensures prioritization works correctly and prevents regressions The implementation uses the existing Registry v2 API and maintains backward compatibility. Official and partner providers now appear first in search results, improving discoverability of authoritative providers.
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.
Pull Request Overview
This PR fixes provider search prioritization to display official providers before community providers in search results. The changes implement tier-based sorting using the Registry v2 API to fetch provider tier information and prioritize results accordingly.
Key changes:
- Enhanced search functionality to use Registry v2 provider list API for tier-based sorting
- Added test infrastructure with mocking capabilities for registry calls
- Implemented comprehensive unit tests for the new prioritization logic
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/tools/registry/sort_test.go | Unit test for tier-based sorting functionality |
| pkg/tools/registry/search_providers_test.go | Integration test verifying official provider prioritization |
| pkg/tools/registry/search_providers.go | Core implementation of enhanced provider search with tier-based sorting |
| pkg/client/registry.go | Added function variable for registry call mocking in tests |
| CHANGELOG.md | Documentation of the fix |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
Hi @koke1997 - the reason we didn't invoke the v2 APIs for could you try it on your end with MCP inspector and perhaps record a short demo if possible because it's timing out on my end |
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.
Requesting a test on MCP inspector ^^, with some tests covering keycloak, AWS, Azure & GCP providers
This commit addresses issue hashicorp#178 and optimizes the implementation from PR hashicorp#179 to avoid v2 API timeout issues. ## Problem When searching for providers by name (e.g., "keycloak"), the tool would not prioritize official providers over community ones, potentially returning mrparkers/keycloak before keycloak/keycloak. ## Previous PR hashicorp#179 Issue The original PR implementation made excessive API calls: - 1 v2 search call to find providers - N v1 calls to fetch docs for each provider - M v2 calls to getContentSnippet for each doc (major bottleneck) This caused timeouts as noted by maintainer gautambaghel. ## This Solution Optimized approach that minimizes API calls: 1. Use v2 API to search providers by name (1 call) 2. Use v1 API to fetch docs for each provider (N calls, includes tier info) 3. **Removed** getContentSnippet calls to eliminate the main bottleneck 4. Sort results by tier: official > partner > community 5. Graceful fallback to single-provider search if v2 API unavailable ## Key Benefits - Significantly fewer API calls (no per-doc snippet fetching) - Tier information already available in v1 API response - Backward compatible with fallback to single-provider mode - Clear tier-based prioritization in results ## Testing - Code compiles successfully - All unit tests pass - Ready for manual testing with keycloak, AWS, Azure, and GCP providers 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Fixes #178
The search_providers tool was returning community providers before official ones in search results. For example, searching for 'keycloak' would show mrparkers/keycloak (community) before keycloak/keycloak (official).
Changes made:
1. Enhanced search_providers.go to use Registry v2 provider list API
2. Modified registry.go to support test overrides
3. Added unit tests:
The implementation uses the existing Registry v2 API and maintains backward compatibility. Official and partner providers now appear first in search results, improving discoverability of authoritative providers.
Testing
All existing tests continue to pass, and new tests verify the prioritization logic works correctly.