Skip to content

fix(cli): activity/tui/credential/security honor global --data-dir; extract shared loadCLIConfig#909

Merged
Dumbris merged 4 commits into
mainfrom
fix/908-cli-datadir-remaining
Jul 24, 2026
Merged

fix(cli): activity/tui/credential/security honor global --data-dir; extract shared loadCLIConfig#909
Dumbris merged 4 commits into
mainfrom
fix/908-cli-datadir-remaining

Conversation

@Dumbris

@Dumbris Dumbris commented Jul 24, 2026

Copy link
Copy Markdown
Member

Fixes #908.

What was actually broken

The issue's file list was partially stale — an audit of every config.Load() site showed connect, feedback, registry, security, status, and telemetry already applied the --data-dir override. The genuinely broken sites were:

  • activity_cmd.go — 3 inline loads (client, watch, export) with no override, so mcpproxy activity ... --data-dir D resolved the socket against the default data dir
  • tui_cmd.go — bare config.Load() feeding cfg.DataDir into socket.DetectSocketPath, so mcpproxy tui --data-dir D targeted the wrong daemon (same user-visible bug as token CLI ignores global --data-dir for daemon socket detection (missed by #854) #897)
  • credential_cmd.go — bare config.Load() in resolveCredentialBaseURL (Listen-only today, fixed for consistency)

Changes

  • New cmd/mcpproxy/cli_config.go: shared loadCLIConfig(explicitPath) — the "finally extract one shared loader" option from the issue — plus thin per-command loaders for activity/credential/security/tui
  • Collapsed the seven pattern-identical existing loaders (doctor, token, upstream, status, telemetry, feedback, connect) onto the shared helper (−140 lines of duplication). auth/call/code/tools keep their distinct home-dir-default + stat-check semantics; registry keeps its DefaultConfig fallback
  • tui DefaultConfig fallback path now also applies --data-dir
  • TestLoadersHonorGlobalDataDirFlag extended from 6 to 16 rows — every command loader is now covered, so no command can silently drift back to a bare load

Verification

  • go test ./cmd/mcpproxy/ — all pass (new rows watched failing first: 4 undefined loaders)
  • golangci-lint run --config .github/.golangci.yml ./cmd/mcpproxy/... — 0 issues
  • ./scripts/test-api-e2e.sh — 64 passed, 0 failed, 1 pre-existing skip

…xtract shared loadCLIConfig (#908)

Bare config.Load() in activity (3 sites), tui, credential, and the
security client ignored the global --data-dir flag, so daemon detection
(socket.DetectSocketPath) probed the default data dir — same class as
#854/#897/#907. connect/feedback/registry/security/status/telemetry
already carried the override; the issue's wider file list was stale.

Extract the repeated load-then-override pattern into loadCLIConfig and
collapse the pattern-identical loaders (doctor, token, upstream, status,
telemetry, feedback, connect) onto it. auth/call/code/tools keep their
distinct home-dir/stat semantics; registry keeps its DefaultConfig
fallback. TestLoadersHonorGlobalDataDirFlag now covers every command
loader (16 rows) so nothing can drift again.
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 24, 2026

Copy link
Copy Markdown

Deploying mcpproxy-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: db008a4
Status: ✅  Deploy successful!
Preview URL: https://1765b217.mcpproxy-docs.pages.dev
Branch Preview URL: https://fix-908-cli-datadir-remainin.mcpproxy-docs.pages.dev

View logs

@codecov-commenter

codecov-commenter commented Jul 24, 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 71.79487% with 11 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cmd/mcpproxy/tui_cmd.go 0.00% 5 Missing ⚠️
cmd/mcpproxy/activity_cmd.go 33.33% 2 Missing ⚠️
cmd/mcpproxy/cli_config.go 90.90% 1 Missing and 1 partial ⚠️
cmd/mcpproxy/security_cmd.go 0.00% 1 Missing ⚠️
cmd/mcpproxy/trust_cert_cmd.go 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@github-actions

github-actions Bot commented Jul 24, 2026

Copy link
Copy Markdown

📦 Build Artifacts

Workflow Run: View Run
Branch: fix/908-cli-datadir-remaining

Available Artifacts

  • archive-darwin-amd64 (28 MB)
  • archive-darwin-arm64 (25 MB)
  • archive-linux-amd64 (16 MB)
  • archive-linux-arm64 (15 MB)
  • archive-windows-amd64 (28 MB)
  • archive-windows-arm64 (25 MB)
  • frontend-dist-pr (0 MB)
  • installer-dmg-darwin-amd64 (22 MB)
  • installer-dmg-darwin-arm64 (20 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 30085651231 --repo smart-mcp-proxy/mcpproxy-go

Note: Artifacts expire in 14 days.

Dumbris added 3 commits July 24, 2026 13:10
credential_cmd.go is //go:build server, so the personal-edition build and
lint missed that loadCredentialConfig() removed the file's last config.
usage; only the CI Server Edition job caught it.
…n bad explicit --config (Codex round 1)

trust-cert used bare config.LoadFromFile(configFile), which with no -c
flag never read the default config file at all — so it ignored both
--data-dir and tls.certs_dir from ~/.mcpproxy/mcp_config.json when
resolving the certs dir. Route it through loadCLIConfig (test row 17).

tui now propagates a load error when --config was explicitly passed
instead of silently falling back to defaults; the implicit default-path
load keeps the fallback.
… (Codex round 2)

resolveCredentialBaseURL silently fell back to http://127.0.0.1:8080
when an explicitly passed --config failed to load; now it returns the
error (implicit default-path load keeps the fallback), mirroring the
tui fix. newCredentialClient and the four run functions propagate it.
@Dumbris
Dumbris merged commit 5a97240 into main Jul 24, 2026
38 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.

Remaining CLI commands ignore global --data-dir (same class as #854/#897)

2 participants