@@ -368,6 +368,7 @@ func workingsetServerCommand() *cobra.Command {
368368 cmd .AddCommand (listServersCommand ())
369369 cmd .AddCommand (addServerCommand ())
370370 cmd .AddCommand (removeServerCommand ())
371+ cmd .AddCommand (updateServerCommand ())
371372
372373 return cmd
373374}
@@ -410,29 +411,95 @@ func addServerCommand() *cobra.Command {
410411
411412func removeServerCommand () * cobra.Command {
412413 var names []string
414+ var servers []string
413415
414416 cmd := & cobra.Command {
415- Use : "remove <profile-id> --name <name1> --name <name2 > ..." ,
417+ Use : "remove <profile-id> [ --name <name1> ...] [--server <uri1 > ...] " ,
416418 Aliases : []string {"rm" },
417419 Short : "Remove MCP servers from a profile" ,
418- Long : "Remove MCP servers from a profile by server name." ,
419- Example : ` # Remove servers by name
420+ Long : "Remove MCP servers from a profile by server name or server URI ." ,
421+ Example : ` # Remove by name
420422 docker mcp profile server remove dev-tools --name github --name slack
421423
422- # Remove a single server
423- docker mcp profile server remove dev-tools --name github` ,
424+ # Remove by URI (same as used for add)
425+ docker mcp profile server remove dev-tools --server catalog://mcp/docker-mcp-catalog/github+slack
426+
427+ # Remove by direct image reference
428+ docker mcp profile server remove dev-tools --server docker://mcp/github:latest
429+
430+ # Mix multiple URIs
431+ docker mcp profile server remove dev-tools --server catalog://mcp/docker-mcp-catalog/github --server docker://custom-server:latest` ,
424432 Args : cobra .ExactArgs (1 ),
425433 RunE : func (cmd * cobra.Command , args []string ) error {
434+ // Validation: can't specify both
435+ if len (names ) > 0 && len (servers ) > 0 {
436+ return fmt .Errorf ("cannot specify both --name and --server flags" )
437+ }
438+ if len (names ) == 0 && len (servers ) == 0 {
439+ return fmt .Errorf ("must specify either --name or --server flag" )
440+ }
441+
426442 dao , err := db .New ()
427443 if err != nil {
428444 return err
429445 }
446+
447+ // If servers provided, resolve to names first
448+ if len (servers ) > 0 {
449+ registryClient := registryapi .NewClient ()
450+ ociService := oci .NewService ()
451+ names , err = workingset .ResolveServerURIsToNames (cmd .Context (), dao , registryClient , ociService , servers )
452+ if err != nil {
453+ return fmt .Errorf ("failed to resolve server URIs: %w\n Hint: Use --name flag with server names from 'docker mcp profile show %s'" , err , args [0 ])
454+ }
455+ }
456+
430457 return workingset .RemoveServers (cmd .Context (), dao , args [0 ], names )
431458 },
432459 }
433460
434461 flags := cmd .Flags ()
435462 flags .StringArrayVar (& names , "name" , []string {}, "Server name to remove (can be specified multiple times)" )
463+ flags .StringArrayVar (& servers , "server" , []string {}, "Server URI to remove - same format as add command (can be specified multiple times)" )
464+
465+ return cmd
466+ }
467+
468+ func updateServerCommand () * cobra.Command {
469+ var addServers []string
470+ var removeServers []string
471+
472+ cmd := & cobra.Command {
473+ Use : "update <profile-id> [--add <uri1> --add <uri2> ...] [--remove <uri1> --remove <uri2> ...]" ,
474+ Short : "Update servers in a profile (add and remove atomically)" ,
475+ Long : "Atomically add and remove MCP servers in a single operation. Both operations are applied together or fail together." ,
476+ Example : ` # Add and remove servers in one atomic operation
477+ docker mcp profile server update dev-tools --add catalog://mcp/docker-mcp-catalog/github --remove catalog://mcp/docker-mcp-catalog/slack
478+
479+ # Add multiple servers while removing others
480+ docker mcp profile server update my-profile --add docker://server1:latest --add docker://server2:latest --remove docker://old-server:latest
481+
482+ # Mix different URI types
483+ docker mcp profile server update dev-tools --add catalog://mcp/docker-mcp-catalog/github --add http://registry.modelcontextprotocol.io/v0/servers/71de5a2a-6cfb-4250-a196-f93080ecc860 --remove docker://old:latest` ,
484+ Args : cobra .ExactArgs (1 ),
485+ RunE : func (cmd * cobra.Command , args []string ) error {
486+ if len (addServers ) == 0 && len (removeServers ) == 0 {
487+ return fmt .Errorf ("must specify at least one --add or --remove flag" )
488+ }
489+
490+ dao , err := db .New ()
491+ if err != nil {
492+ return err
493+ }
494+ registryClient := registryapi .NewClient ()
495+ ociService := oci .NewService ()
496+ return workingset .UpdateServers (cmd .Context (), dao , registryClient , ociService , args [0 ], addServers , removeServers )
497+ },
498+ }
499+
500+ flags := cmd .Flags ()
501+ flags .StringArrayVar (& addServers , "add" , []string {}, "Server URI to add: https:// (MCP Registry) or docker:// (Docker Image) or catalog:// (Catalog). Can be specified multiple times." )
502+ flags .StringArrayVar (& removeServers , "remove" , []string {}, "Server URI to remove - same format as add. Can be specified multiple times." )
436503
437504 return cmd
438505}
0 commit comments