Skip to content

fix(mcp): make loopover-mcp CLI failures respect --json - #6104

Closed
RealDiligent wants to merge 1 commit into
JSONbored:mainfrom
RealDiligent:fix/critical-issue-mcp-json-errors-5928
Closed

fix(mcp): make loopover-mcp CLI failures respect --json#6104
RealDiligent wants to merge 1 commit into
JSONbored:mainfrom
RealDiligent:fix/critical-issue-mcp-json-errors-5928

Conversation

@RealDiligent

Copy link
Copy Markdown
Contributor

Summary

  • Add packages/loopover-mcp/lib/cli-error.js mirroring @loopover/miner's { ok: false, error } contract
  • Wrap top-level runCli dispatch in try/catch so thrown errors never escape as raw Node stack traces
  • Extend mcp-cli harness with runExpectingFailure and tests for unknown command, missing --login, and unsupported --agent-profile failures with --json

Closes #5928

Test plan

  • npx vitest run test/unit/mcp-cli-basics.test.ts (21/21 pass)
  • npx vitest run test/unit/mcp-cli- (125/128 pass; 3 symlink rejection tests fail on Windows only — pre-existing)

@RealDiligent
RealDiligent requested a review from JSONbored as a code owner July 15, 2026 09:29
@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

Wrap top-level runCli dispatch in try/catch and mirror @loopover/miner's
cli-error contract so --json failures emit { ok: false, error } on stdout
instead of a raw Node stack trace.

Closes JSONbored#5928

Co-authored-by: Cursor <cursoragent@cursor.com>
@codecov

codecov Bot commented Jul 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.24%. Comparing base (0760e1f) to head (478b126).
⚠️ Report is 23 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6104   +/-   ##
=======================================
  Coverage   95.24%   95.24%           
=======================================
  Files         595      595           
  Lines       47035    47046   +11     
  Branches    15015    15015           
=======================================
+ Hits        44797    44808   +11     
  Misses       1493     1493           
  Partials      745      745           
Flag Coverage Δ
shard-1 44.01% <ø> (+<0.01%) ⬆️
shard-2 36.68% <ø> (+0.06%) ⬆️
shard-3 32.08% <ø> (+0.02%) ⬆️
shard-4 33.60% <ø> (+0.47%) ⬆️
shard-5 31.66% <ø> (-0.57%) ⬇️
shard-6 44.50% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 15, 2026
@loopover-orb

loopover-orb Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Caution

🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥

🛑 LoopOver review result - fixes required

Review updated: 2026-07-15 09:48:53 UTC

5 files · 1 AI reviewer · no blockers · readiness 80/100 · CI failing · blocked

🛑 Suggested Action - Fix Blockers

Review summary
This PR wraps the top-level CLI dispatch in bin/loopover-mcp.js in a try/catch so thrown errors are converted to the miner's established `{ ok: false, error }` JSON contract (via the new lib/cli-error.js) instead of leaking raw Node stack traces, mirroring the pattern already used in @​loopover/miner per test/unit/miner-cli.test.ts. The harness changes (runExpectingFailure, folding stdout into thrown Error messages) are correctly scoped support code for the new tests, and the new mcp-cli-basics.test.ts assertions exercise both the --json and plain-text failure paths for three distinct failure sources (unknown command, missing --login, unsupported agent profile). The change closes #5928 and is narrowly targeted at the stated bug.

Nits — 5 non-blocking
  • cli-error.js:22 `argsWantJson` only recognizes `--json`/`--json=...`; worth confirming this matches whatever flag-parsing convention the rest of loopover-mcp.js uses elsewhere so `--json` combined with other flag syntaxes isn't missed.
  • bin/loopover-mcp.js:591 if a command partially writes to stdout before throwing, the JSON failure object from `reportCliFailure` would be appended after that partial output, breaking the 'parseable JSON on stdout' guarantee for --json — worth confirming none of the wrapped commands stream partial output before failing.
  • test/unit/support/mcp-cli-harness.ts:29 the comment explaining why stdout is folded into the Error message is helpful, but the same fold-in logic is now duplicated across `run` and `runAsync`/`runExpectingFailure`; consider a shared helper to avoid drift.
  • Add a short code comment or test asserting that non-JSON-mode failures never touch stdout (already partially covered by the `plainFailure.stdout` assertion) to lock in the contract long-term.
  • Consider exporting a shared `foldStreamsIntoError` helper in mcp-cli-harness.ts used by both `run` and `runAsync` to reduce duplication.

CI checks failing

  • validate
  • validate-code
Signal Result Evidence
Code review ✅ No blockers 1 reviewer
Linked issue ✅ Linked #5928
Related work ⚠️ 2 scoped overlaps Top overlaps are listed below; lower-confidence bulk is hidden.
Change scope ❌ 8/20 High review scope from cached public metadata (1 linked issue).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 352 registered-repo PR(s), 170 merged, 29 issue(s).
Contributor context ✅ Confirmed Gittensor contributor RealDiligent; Gittensor profile; 352 PR(s), 29 issue(s).
Gate result ✅ Passing No configured blocker found.
Improvement ✅ Minor risk: clean · value: minor · LLM: moderate
Linked issue satisfaction

Addressed
The PR adds a cli-error.js module mirroring the miner's reportCliFailure/argsWantJson/describeCliError contract, wraps the top-level runCli dispatch in try/catch to route failures through it, and adds harness support plus tests covering unknown command, missing --login, and unsupported --agent-profile failures under --json (and confirms non-json stderr behavior is preserved).

Review context
Contributor next steps
  • Start here: Review top overlaps.
  • Then work through the remaining 2 steps in the Signals table above.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.
🧪 Chat with LoopOver

Ask LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.

  • @loopover ask &lt;question&gt; answers contribution-quality Q&A with source citations and freshness.
  • @loopover chat &lt;question&gt; answers in natural prose from cached decision-pack facts via local inference (maintainer/collaborator; read-only).
  • A plain-language @loopover mention with a real question is routed to the closest matching read-only command automatically — no exact syntax required.

Full command reference: https://gittensory.aethereal.dev/docs/loopover-commands

🧪 Experimental — new and may change.

🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed


💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →.

Checked by LoopOver, a quiet PR intelligence layer for OSS maintainers.

  • Re-run LoopOver review

@loopover-orb

loopover-orb Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

LoopOver is closing this pull request on the maintainer's behalf (CI is failing (validate, validate-code)). This is an automated maintenance action — to pursue this change, please open a new pull request with the issues resolved. Closed PRs may be analyzed later to improve review accuracy, but they are not automatically reopened or re-reviewed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(mcp): loopover-mcp CLI errors never respect --json, unlike @loopover/miner's cli-error contract

1 participant