Skip to content

fix: make server add create-only across REST, MCP and Web UI (UX-01) - #1570

Merged
Dumbris merged 4 commits into
mainfrom
fix/qa070-ux01-create-only-add-core
Oct 11, 2026
Merged

Dumbris merged 4 commits into
mainfrom
fix/qa070-ux01-create-only-add-core

Conversation

@Dumbris

@Dumbris Dumbris commented Oct 11, 2026

Copy link
Copy Markdown
Member

Impact

Adding a server whose name already exists silently replaced it: args/env/quarantine reset, created timestamp reset, tool approvals dropped (Web UI Manual add and MCP upstream_servers add; REST/CLI had a racy check-then-write).

Cause

Server.AddServer and MCP add checked existence, then upserted via SaveUpstreamServer; MCP add did not check at all. configWithAppendedServer appended a second same-name entry.

Minimal scope (UX-01 only)

  • storage: BoltDB.CreateUpstream / Manager.CreateUpstreamServer do the existence check and put in one bbolt tx, returning storage.ErrUpstreamExists. SaveUpstreamServer upsert is untouched.
  • Server.createServer: runtime-config + storage check, create and copy-on-write config publish under one mutex. Used by Server.AddServer (REST, CLI via REST, registry, import) and MCP add. Error text stays server '%s' already exists.
  • MCP duplicate add returns an isError result naming update/patch, with no side effects before the check.
  • configWithAppendedServer replaces a same-name entry.
  • import: rename onto an existing name is reported as skipped already_exists; post-add failures are reported in failed/skipped instead of swallowed.
  • Not touched: removal, reload, supervisor, transport, OAuth, PATCH/update commit paths.

Compatibility

REST 409 text, upstream add --if-not-exists (exit 0), registry ErrDuplicateName all keep matching already exists. No schema changes to built-in tools, no new dependencies.

Verification

  • go test -race ./internal/storage -run CreateUpstream; go test -race ./internal/server -run 'HandleAddUpstream|ConfigWithAppendedServer|ServerAddServer_CreateOnly'; go test -race ./internal/httpapi -run RunImport
  • CI-shaped race run of server/httpapi/storage/runtime with the unit-tests.yml -skip regex: ok
  • golangci-lint run --config .github/.golangci.yml [--build-tags server] --new-from-rev=origin/main ./...: 0 issues
  • Live on a rebuilt scratch daemon (big profile): duplicate via Web UI Manual form, REST (409), MCP (isError), CLI (exit 1; --if-not-exists exit 0), import all leave args/created/quarantine/tools/connection unchanged; 40 parallel REST creates x3, 12 parallel MCP, mixed REST+MCP each yield exactly one success; restart persists with no duplicates.

Supersedes #1553.

Known follow-ups (out of scope)

#1558 #1559 #1560 #1561 #1562 #1563 #1564 #1565 #1566 #1567 #1568 #1569

🤖 Generated with Claude Code

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

@github-actions

github-actions Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

📦 Build Artifacts

Workflow Run: View Run
Branch: fix/qa070-ux01-create-only-add-core

Available Artifacts

  • archive-darwin-amd64 (31 MB)
  • archive-darwin-arm64 (28 MB)
  • archive-linux-amd64 (19 MB)
  • archive-linux-arm64 (17 MB)
  • archive-windows-amd64 (31 MB)
  • archive-windows-arm64 (27 MB)
  • frontend-dist-pr (0 MB)
  • installer-dmg-darwin-amd64 (27 MB)
  • installer-dmg-darwin-arm64 (24 MB)
  • smart-mcp-proxymcpproxy-goZ2NCIH.dockerbuild (0 MB)

How to Download

Option 1: GitHub Web UI (easiest)

  1. Go to the workflow run page linked above
  2. Scroll to the bottom "Artifacts" section
  3. Click on the artifact you want to download

Option 2: GitHub CLI

gh run download 38116021230 --repo smart-mcp-proxy/mcpproxy-go

Note: Artifacts expire in 14 days.

@codecov-commenter

codecov-commenter commented Oct 11, 2026 •

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 87.78626% with 16 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/server/config_cow.go 88.00% 4 Missing and 2 partials ⚠️
internal/server/mcp.go 73.68% 3 Missing and 2 partials ⚠️
internal/server/server.go 40.00% 3 Missing ⚠️
internal/storage/bbolt.go 80.00% 1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@Dumbris
Dumbris merged commit 8eda436 into main Oct 11, 2026
45 checks passed
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