Add filtering functionality to server list endpoint (#374)
## Summary - Adds `updated_since`, `search`, and `version` query parameters to `GET /v0/servers` - Enables incremental synchronization via RFC3339 timestamp filtering - Provides simple substring search on server names - Supports latest version filtering with `version=latest` This implementation provides the core filtering capabilities needed for efficient registry synchronization and improved server discovery. Fixes #291 Fixes #135
This commit is contained in:
parent
be6c2d9142
commit
a85456a9b9
2 changed files with 262 additions and 13 deletions
|
|
@ -29,8 +29,8 @@ func NewRegistryService(db database.Database, cfg *config.Config) RegistryServic
|
|||
}
|
||||
}
|
||||
|
||||
// List returns registry entries with cursor-based pagination in flattened format
|
||||
func (s *registryServiceImpl) List(cursor string, limit int) ([]apiv0.ServerJSON, string, error) {
|
||||
// List returns registry entries with cursor-based pagination and optional filtering
|
||||
func (s *registryServiceImpl) List(filter *database.ServerFilter, cursor string, limit int) ([]apiv0.ServerJSON, string, error) {
|
||||
// Create a timeout context for the database operation
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
defer cancel()
|
||||
|
|
@ -40,8 +40,8 @@ func (s *registryServiceImpl) List(cursor string, limit int) ([]apiv0.ServerJSON
|
|||
limit = 30
|
||||
}
|
||||
|
||||
// Use the database's ListServers method with pagination
|
||||
serverRecords, nextCursor, err := s.db.List(ctx, nil, cursor, limit)
|
||||
// Use the database's ListServers method with pagination and filtering
|
||||
serverRecords, nextCursor, err := s.db.List(ctx, filter, cursor, limit)
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,13 +1,14 @@
|
|||
package service
|
||||
|
||||
import (
|
||||
"github.com/modelcontextprotocol/registry/internal/database"
|
||||
apiv0 "github.com/modelcontextprotocol/registry/pkg/api/v0"
|
||||
)
|
||||
|
||||
// RegistryService defines the interface for registry operations
|
||||
type RegistryService interface {
|
||||
// Retrieve all servers
|
||||
List(cursor string, limit int) ([]apiv0.ServerJSON, string, error)
|
||||
// Retrieve all servers with optional filtering
|
||||
List(filter *database.ServerFilter, cursor string, limit int) ([]apiv0.ServerJSON, string, error)
|
||||
// Retrieve a single server by registry metadata ID
|
||||
GetByID(id string) (*apiv0.ServerJSON, error)
|
||||
// Publish a server
|
||||
|
|
|
|||
Loading…
Reference in a new issue