Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion cmd/docker-mcp/commands/catalog_next.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func createCatalogNextCommand() *cobra.Command {
FromLegacyCatalog string
FromCommunityRegistry string
Servers []string
Exclude []string
IncludePyPI bool
}

Expand Down Expand Up @@ -91,13 +92,17 @@ When using --server without --from-profile, --from-legacy-catalog, or --from-com
return fmt.Errorf("--include-pypi can only be used when creating a catalog from a community registry")
}

if len(opts.Exclude) > 0 && opts.FromCommunityRegistry == "" {
return fmt.Errorf("--exclude can only be used when creating a catalog from a community registry")
}

dao, err := db.New()
if err != nil {
return err
}
registryClient := registryapi.NewClient()
ociService := oci.NewService()
return catalognext.Create(cmd.Context(), dao, registryClient, ociService, args[0], opts.Servers, opts.FromWorkingSet, opts.FromLegacyCatalog, opts.FromCommunityRegistry, opts.Title, opts.IncludePyPI)
return catalognext.Create(cmd.Context(), dao, registryClient, ociService, args[0], opts.Servers, opts.FromWorkingSet, opts.FromLegacyCatalog, opts.FromCommunityRegistry, opts.Title, opts.IncludePyPI, opts.Exclude)
},
}

Expand All @@ -108,6 +113,7 @@ When using --server without --from-profile, --from-legacy-catalog, or --from-com
flags.StringVar(&opts.FromCommunityRegistry, "from-community-registry", "", "Community registry hostname to fetch servers from (e.g. registry.modelcontextprotocol.io)")
flags.StringVar(&opts.Title, "title", "", "Title of the catalog")

flags.StringArrayVar(&opts.Exclude, "exclude", []string{}, "Server name to exclude from the catalog (can be specified multiple times, only valid with --from-community-registry)")
flags.BoolVar(&opts.IncludePyPI, "include-pypi", false, "Include PyPI servers when creating a catalog from a community registry")
cmd.Flags().MarkHidden("include-pypi") //nolint:errcheck

Expand Down
11 changes: 8 additions & 3 deletions pkg/catalog_next/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"github.com/docker/mcp-gateway/pkg/workingset"
)

func Create(ctx context.Context, dao db.DAO, registryClient registryapi.Client, ociService oci.Service, refStr string, servers []string, workingSetID string, legacyCatalogURL string, communityRegistryRef string, title string, includePyPI bool) error {
func Create(ctx context.Context, dao db.DAO, registryClient registryapi.Client, ociService oci.Service, refStr string, servers []string, workingSetID string, legacyCatalogURL string, communityRegistryRef string, title string, includePyPI bool, excludeServers []string) error {
telemetry.Init()
start := time.Now()
var success bool
Expand Down Expand Up @@ -49,7 +49,7 @@ func Create(ctx context.Context, dao db.DAO, registryClient registryapi.Client,
return fmt.Errorf("failed to create catalog from legacy catalog: %w", err)
}
} else if communityRegistryRef != "" {
catalog, err = createCatalogFromCommunityRegistry(ctx, registryClient, communityRegistryRef, includePyPI)
catalog, err = createCatalogFromCommunityRegistry(ctx, registryClient, communityRegistryRef, includePyPI, excludeServers)
if err != nil {
return fmt.Errorf("failed to create catalog from community registry: %w", err)
}
Expand Down Expand Up @@ -209,7 +209,7 @@ type communityRegistryResult struct {
skippedByType map[string]int
}

func createCatalogFromCommunityRegistry(ctx context.Context, registryClient registryapi.Client, registryRef string, includePyPI bool) (Catalog, error) {
func createCatalogFromCommunityRegistry(ctx context.Context, registryClient registryapi.Client, registryRef string, includePyPI bool, excludeServers []string) (Catalog, error) {
baseURL := "https://" + registryRef
servers, err := registryClient.ListServers(ctx, baseURL, "")
if err != nil {
Expand All @@ -221,6 +221,11 @@ func createCatalogFromCommunityRegistry(ctx context.Context, registryClient regi
var ociCount, remoteCount, pypiCount int

for _, serverResp := range servers {
if slices.Contains(excludeServers, serverResp.Server.Name) {
skippedByType["excluded"]++
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

super nit: "blocked" is maybe more explicit

continue
}

catalogServer, transformSource, err := legacycatalog.TransformToDocker(ctx, serverResp.Server, legacycatalog.WithAllowPyPI(includePyPI), legacycatalog.WithPyPIResolver(legacycatalog.DefaultPyPIVersionResolver()))
if err != nil {
if !errors.Is(err, legacycatalog.ErrIncompatibleServer) {
Expand Down
Loading
Loading