Skip to content

fix(tray): forward --listen to the spawned core process - #1015

Open
electrolobzik wants to merge 2 commits into
smart-mcp-proxy:mainfrom
HaloCollar:fix/tray-forward-listen
Open

fix(tray): forward --listen to the spawned core process#1015
electrolobzik wants to merge 2 commits into
smart-mcp-proxy:mainfrom
HaloCollar:fix/tray-forward-listen

Conversation

@electrolobzik

Copy link
Copy Markdown
Contributor

Bug

mcpproxy-tray serve --listen 0.0.0.0:8181 silently drops the --listen flag on macOS (reproduced on tray v0.43.0):

  • The tray log shows the core spawned as /bin/zsh -l -c exec '/mcpproxy' 'serve' — no --listen.
  • lsof confirms the core then listens on the config-file value (default 127.0.0.1:8080); nothing ever opens the advertised port, so any tooling that probes it concludes the daemon is down.

Root cause

cmd/mcpproxy-tray/main.go never parses its own command line — serve --listen … is ignored entirely. On macOS resolveCoreURL() prefers the unix socket for tray↔core communication (#102), and buildCoreArgs() only derives --listen for TCP/HTTP core URLs, so on the socket path the core is spawned with no --listen at all and falls back to the config default.

Fix

  • New trayListenFromArgs() parses --listen/-l (both space and = forms) from the tray's argv; other args remain ignored as before. Malformed values (dangling flag, empty = form, value starting with -) are skipped and scanning continues to the first valid value.
  • buildCoreArgs() now always forwards an explicit CLI --listen to the spawned core's argv — including when the tray talks to the core over the socket/pipe, since the socket only covers tray↔core communication while the core must still open the advertised TCP address. Both the login-shell-wrapped spawn and the direct-exec fallback consume the same argv.
  • URL/env-derived --listen behavior for TCP endpoints is unchanged.

Tests

  • TestTrayListenFromArgs covers both flag forms plus the malformed-input regressions (--listen --config path, --listen= --listen :8181, dangling -l, continue-scan to a later valid --listen=:9090).
  • TestBuildCoreArgs_ForwardsCLIListenOverSocketEndpoint — regression: CLI listen forwarded over a socket endpoint; no --listen on socket endpoints without the flag.
  • CI on our fork built all platform artifacts (incl. darwin-arm64) green: fix(tray): forward --listen to the spawned core process HaloCollar/mcpproxy-go#7

🤖 Generated with Claude Code

Roman Chernyak and others added 2 commits August 20, 2026 20:20
The tray ignored its own command-line arguments entirely, so launching it
as `mcpproxy-tray serve --listen 0.0.0.0:8181` silently dropped the listen
address: on macOS the tray prefers the unix socket for tray<->core
communication, buildCoreArgs() only derived --listen for TCP/HTTP core
URLs, and the core was spawned as `mcpproxy serve` with no --listen at
all. The core then fell back to the config-file default (typically
127.0.0.1:8080) and the advertised port never opened. Observed live on
mcpproxy-tray v0.43.0 (tray log shows the shell-wrapped spawn without
--listen; lsof confirms the core listening on 8080 instead of 8181).

Fix: parse --listen/-l (space and = forms) from the tray's argv and always
forward it to the spawned core's argv, even when the tray talks to the
core over the socket/pipe — the socket only covers tray<->core
communication, while the core must still open the advertised TCP address.
URL/env-derived --listen behavior for TCP endpoints is unchanged.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@codecov-commenter

Copy link
Copy Markdown

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

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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