Repository navigation
fix(serve): make --listen "" reach native stdio transport - #1301
Merged
Merged
Conversation
`serve --listen ""` was documented as a stdio trigger, but loadConfig applied the flag and then called cfg.Validate(), which resets an empty Listen to 127.0.0.1:8080 — it cannot tell "no listen key in the file" (must default to HTTP) from "cleared on purpose". The process silently booted in HTTP mode; only `--listen :0` actually reached stdio. Map an explicit empty flag onto the ":0" sentinel that the server already recognises after validation. loadConfig is the only seam where the intent is knowable, so Validate()'s default stays intact for config files. Update the flag help text to document both spellings and add TestLoadConfig_ListenFlag (unset / explicit addr / :0 / "").
Deploying mcpproxy-docs with
|
| Latest commit: |
0582e96
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://c1999ae1.mcpproxy-docs.pages.dev |
| Branch Preview URL: | https://claude-great-gagarin-423949.mcpproxy-docs.pages.dev |
loader.go applies MCPPROXY_LISTEN even with an explicit config file, so an ambient value in the developer shell failed the "unset flag" case. Pin the env per case and add the two env interplay cases (unset flag keeps the env override; explicit --listen "" beats it).
Contributor
📦 Build ArtifactsWorkflow Run: View Run Available Artifacts
How to DownloadOption 1: GitHub Web UI (easiest)
Option 2: GitHub CLI gh run download 35324351915 --repo smart-mcp-proxy/mcpproxy-go
|
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Dumbris
added a commit
that referenced
this pull request
Sep 18, 2026
…gnature CI on PR #1300 failed to build cmd/mcpproxy on every platform: "assignment mismatch: 2 variables but loadConfig returns 3 values". Unrelated to this PR's instance-ID changes -- main itself is currently broken this way (#1299 changed loadConfig to also return a *serveConfigSaver, and the listen_flag_test.go added by #1301 wasn't updated for it). Discard the unused saver return to match the real signature. Co-Authored-By: Claude Sonnet 5 <[email protected]>
Dumbris
added a commit
that referenced
this pull request
Sep 18, 2026
…p file (#1300) * fix(docker): scope instance ID to data dir instead of a host-wide temp file GetInstanceID() persisted to a single filepath.Join(os.TempDir(), ...) file shared by every process a user runs on a host, so any two concurrent mcpproxy processes (a scratch dev instance next to the main app, two separate installs) silently got the SAME instance ID. That defeats com.mcpproxy.instance container-ownership labels used by manager.go's cleanup and by the ownership filter added in PR #1298 for same-host instances (cross-host-shared-daemon cases still work). Scope the ID to the process's data dir instead (cfg.DataDir, set once via core.SetInstanceDataDir from upstream.NewManager, the common construction point for every entry point) since concurrent instances on one host already require distinct data dirs -- BBolt locks config.db. Fall back to a fresh per-process UUID when no data dir is known yet. On first run under a data dir, adopt-then-retire the legacy shared file so pre-upgrade containers stay cleanable by whichever instance starts first, without letting every future data dir keep re-adopting the same shared ID. Co-Authored-By: Claude Sonnet 5 <[email protected]> * fix(docker): close legacy-instance-id adoption race found by cross-review codex gpt-5.6-sol review of the instance-ID fix (PR #1300) found that adoptLegacyInstanceID's read-then-remove let two concurrent processes both read the same legacy id before either deleted the file, recreating the very host-wide-shared-id bug the fix targets. Claim the legacy file via os.Rename to a process-unique path instead: rename atomically fails once another process has already claimed the source, so exactly one process adopts a given legacy id. Also fixes a test bug the same review caught: the subprocess helper tests never overrode legacyInstanceIDPath in the child process, so they could have adopted-and-deleted a real machine's actual pre-upgrade legacy file. Threads a scratch path through an env var instead. Adds a goroutine-race test (50x under -race) proving the claim is exclusive. Co-Authored-By: Claude Sonnet 5 <[email protected]> * fix(test): make legacy-id claim path unique per call, not just per PID Windows CI failed TestAdoptLegacyInstanceIDConcurrentClaimIsExclusive (#1300 windows-amd64 build): all 8 concurrent goroutines got 0 adopters instead of exactly 1. The test spawns racers as goroutines in one OS process, so they all share one os.Getpid() and therefore compute the identical claim destination -- a collision that can't happen in real usage (real racers are always separate processes with distinct PIDs). On Windows that collision made every racer's rename fail. Add an atomic per-call sequence number alongside the PID in the claim path, so it can never collide even when called concurrently within one process. No behavior change for the real (cross-process) case. Co-Authored-By: Claude Sonnet 5 <[email protected]> * fix(docker): use a random claim path and preserve claims on save failure Second codex gpt-5.6-sol review round on PR #1300. opencode's Copilot quota was still exhausted, so codex gpt-5.6-sol (the documented fallback) reviewed again. Findings: 1. adoptLegacyInstanceID removed the claimed legacy file unconditionally, even when the subsequent save to the new per-data-dir location failed -- silently losing the id on the next restart. Now the claim file is only removed after a successful save; on failure it's left in place so it isn't silently destroyed. 2. The PID+sequence claim-path suffix (from the previous round's Windows fix) doesn't guarantee cross-restart uniqueness -- PIDs get reused, and the review argued a stale claim file from a crash could collide with a later process's first claim. Go's os.Rename on Windows actually uses MOVEFILE_REPLACE_EXISTING (verified against the Go 1.26 stdlib source), so this wouldn't have caused a failure the way the review described, but using a random UUID instead of PID+sequence removes any theoretical collision outright and is simpler. 3. Test coverage: TestGetInstanceIDDistinctAcrossConcurrentProcesses ran its two subprocesses sequentially despite its name; and there was no test of the ACTUAL cross-process legacy-claim race (only an in-process goroutine simulation, which artificially shares one PID across racers). Added TestGetInstanceIDCrossProcessLegacyClaimIsExclusive (two real subprocesses racing over one seeded legacy file) and TestAdoptLegacyInstanceIDPreservesClaimWhenSaveFails, and made the existing "concurrent processes" test actually start both processes concurrently. Co-Authored-By: Claude Sonnet 5 <[email protected]> * fix(test): match TestLoadConfig_ListenFlag to loadConfig's 3-value signature CI on PR #1300 failed to build cmd/mcpproxy on every platform: "assignment mismatch: 2 variables but loadConfig returns 3 values". Unrelated to this PR's instance-ID changes -- main itself is currently broken this way (#1299 changed loadConfig to also return a *serveConfigSaver, and the listen_flag_test.go added by #1301 wasn't updated for it). Discard the unused saver return to match the real signature. Co-Authored-By: Claude Sonnet 5 <[email protected]> --------- Co-authored-by: Claude Sonnet 5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
mcpproxy serve --listen ""now boots in native stdio transport, as the flag was documented to do. Previously only--listen :0worked.Why
loadConfigapplied the--listenoverride and then calledcfg.Validate(), which resets an emptyListento127.0.0.1:8080.Validate()cannot distinguish "nolistenkey in the config file" (which must default to HTTP) from "cleared on purpose", so the process silently started in HTTP mode. Found during real-instance verification for Spec 107 PR-D.How
cmd/mcpproxy/main.goloadConfig: an explicit empty--listenis mapped to the":0"sentinel thatinternal/server/server.goalready treats as stdio. This is the only seam where "explicitly cleared" is knowable, soValidate()'s default for config files is untouched.""and":0".cmd/mcpproxy/listen_flag_test.gocovers unset flag → 8080 default, explicit address,:0, and"". The""case failed before the fix (got "127.0.0.1:8080").Verification
go test ./cmd/mcpproxyok;go vet+ gofmt clean.serve --listen "" --enable-socket=falseansweredinitializeover stdin and loggedtransport: stdiowith zerostreamable-httplines.github-copilot/gpt-5.6-sol): seam choice confirmed,:0never reachesnet.Listen/SplitHostPorton the serve path. One finding, verified as pre-existing and out of scope: any CLI--listenvalue (including:0, which already worked) is persisted intomcp_config.jsonby the API-key / startup-outcome saves on a fresh boot. Tracked separately.