Skip to content

Fix profile/catalog server add to upsert and allow positional args on remove#417

Merged
cutecatfann merged 2 commits intomainfrom
upsert_server
Feb 23, 2026
Merged

Fix profile/catalog server add to upsert and allow positional args on remove#417
cutecatfann merged 2 commits intomainfrom
upsert_server

Conversation

@cutecatfann
Copy link
Contributor

What I did

  • Profile and catalog server add now upserts. Adding a server whose name already exists replaces it instead of erroring (profiles) or silently skipping (catalogs). This removes the need to manually remove-then-add when updating a server from a newer catalog version.
  • server remove accepts positional args. Server names can now be passed as positional arguments (docker mcp profile server remove dev-tools github grafana) in addition to the existing --name flag. Both styles can be mixed in a single command.

Test Plan
Ran new tests locally and they passed

mcp-gateway % go test -count=1 -v ./pkg/workingset/... -run 'TestAddServerUpsert|TestRemoveServersCombined'
=== RUN   TestRemoveServersCombinedNames
Created profile test-set with 2 servers
Removed 2 server(s) from profile test-set
--- PASS: TestRemoveServersCombinedNames (0.01s)
=== RUN   TestAddServerUpsertReplacesExisting
Created profile test-set with 1 servers
Replaced server My Image in profile test-set
Added 1 server(s) to profile test-set (replaced 1)
--- PASS: TestAddServerUpsertReplacesExisting (0.01s)
=== RUN   TestAddServerUpsertPreservesOtherServers
Created profile test-set with 2 servers
Replaced server My Image in profile test-set
Added 1 server(s) to profile test-set (replaced 1)
--- PASS: TestAddServerUpsertPreservesOtherServers (0.01s)
=== RUN   TestAddServerUpsertFromCatalog
Added 1 server(s) to profile test-set
Replaced server catalog-server-1 in profile test-set
Added 1 server(s) to profile test-set (replaced 1)
--- PASS: TestAddServerUpsertFromCatalog (0.01s)
PASS
ok  	github.com/docker/mcp-gateway/pkg/workingset	0.447s
mcp-gateway % go test -count=1 -v ./pkg/catalog_next/... -run 'TestAddServersUpsert'
=== RUN   TestAddServersUpsert
=== RUN   TestAddServersUpsert/upsert_replaces_existing
Replaced server existing-server in catalog test/upsert-catalog:latest
Added 1 server(s) to catalog 'test/upsert-catalog:latest' (replaced 1)
=== RUN   TestAddServersUpsert/upsert_preserves_other_servers
Replaced server existing-server in catalog test/upsert-catalog2:latest
Added 1 server(s) to catalog 'test/upsert-catalog2:latest' (replaced 1)
--- PASS: TestAddServersUpsert (0.02s)
    --- PASS: TestAddServersUpsert/upsert_replaces_existing (0.00s)
    --- PASS: TestAddServersUpsert/upsert_preserves_other_servers (0.00s)
PASS
ok  	github.com/docker/mcp-gateway/pkg/catalog_next	0.541s

Manual testing of the new upsert functionality
Testing server upsert

mcp-gateway % docker mcp profile server add upsert_test --server catalog://mcp/docker-mcp-catalog/github
Added 1 server(s) to profile upsert_test
mcp-gateway % docker mcp profile server add upsert_test --server catalog://mcp/docker-mcp-catalog/github
Replaced server github in profile upsert_test
Added 1 server(s) to profile upsert_test (replaced 1)

Testing catalog upsert

mcp-gateway % docker mcp catalog create test/my-catalog:v1 --title "Test Catalog" --server catalog://mcp/docker-mcp-catalog/github
Catalog test/my-catalog:v1 created
mcp-gateway % docker mcp catalog server add test/my-catalog:v1 --server catalog://mcp/docker-mcp-catalog/github
Replaced server github in catalog test/my-catalog:v1
Added 1 server(s) to catalog 'test/my-catalog:v1' (replaced 1)

Testing new remove server functionality

mcp-gateway % docker mcp profile create --name remove_test
Created profile remove_test with 0 servers
mcp-gateway % docker mcp profile server add remove_test --server catalog://mcp/docker-mcp-catalog/github
Added 1 server(s) to profile remove_test
mcp-gateway % docker mcp profile server add remove_test --server catalog://mcp/docker-mcp-catalog/grafana
Added 1 server(s) to profile remove_test
mcp-gateway % docker mcp profile server remove remove_test github
Removed 1 server(s) from profile remove_test
mcp-gateway % docker mcp profile server remove remove_test --name grafana ### Old way still works
Removed 1 server(s) from profile remove_test

Testing remove from catalogs

mcp-gateway % docker mcp catalog create test/remove-cat:v1 --title "Remove Test" --server catalog://mcp/docker-mcp-catalog/github --server catalog://mcp/docker-mcp-catalog/grafana
Catalog test/remove-cat:v1 created
mcp-gateway % docker mcp catalog server remove test/remove-cat:v1 github
Removed 1 server(s) from catalog 'test/remove-cat:v1'
mcp-gateway % docker mcp catalog server remove test/remove-cat:v1 --name grafana
Removed 1 server(s) from catalog 'test/remove-cat:v1'

Mixed remove from catalogs

mcp-gateway % docker mcp profile create --name mixed_test
Created profile mixed_test with 0 servers
mcp-gateway % docker mcp profile server add mixed_test --server --server catalog://mcp/docker-mcp-catalog/github
accepts 1 arg(s), received 2
mcp-gateway % docker mcp profile server add mixed_test --server catalog://mcp/docker-mcp-catalog/github
Added 1 server(s) to profile mixed_test
mcp-gateway % docker mcp profile server add mixed_test --server catalog://mcp/docker-mcp-catalog/grafana
Added 1 server(s) to profile mixed_test
mcp-gateway % docker mcp profile server remove mixed_test github --name grafana
Removed 2 server(s) from profile mixed_test
mcp-gateway %

@cutecatfann cutecatfann requested a review from a team as a code owner February 18, 2026 19:46
@cutecatfann cutecatfann self-assigned this Feb 18, 2026
Copy link
Collaborator

@slimslenderslacks slimslenderslacks left a comment

Choose a reason for hiding this comment

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

awesome!

@cutecatfann cutecatfann merged commit fdb82a0 into main Feb 23, 2026
8 checks passed
@cutecatfann cutecatfann deleted the upsert_server branch February 23, 2026 16:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants