Repository navigation
fix(mcp): report incomplete inject and remove operations - #1439
Conversation
|
No findings in the specified PR diff. The PR description satisfies the testing requirement: it records a build followed by representative real-CLI checks for both commands, covering dry runs, partial changes, preserved ownership records, and successful retries. Deferring extra provider/agent coverage to CI is acceptable. Review was read-only; I did not run, build, or install anything from the PR. |
SaulMoro
left a comment
There was a problem hiding this comment.
This was generated by AI during triage.
@ydflow Thanks, this works on macOS too. With the built CLI, the git provider, Claude and Cursor, and a broken ~/.claude.json:
- On
main,mcp injectandmcp remove, with and without--dry-run, exit 0 with a false success, "Already up to date" or "Nothing to remove". - Here they exit 1. They list the Cursor change, then say the operation is incomplete and how to retry.
- The broken file's bytes and its ownership record stay unchanged, and a rerun after repairing the file exits 0.
- A config that can't be read because of its permissions also exits 1.
pullwith the same broken config still exits 0 and reports the failed check, so it does not regress.
The other readers of unparsed (env commands, team scripts, pull, uninstall) stay consistent with this.
[P3 nit] When one tool was written and another skipped, the "Restart your AI tool session" hint is dropped (src/mcp-cmd.ts:150), although the written tool still needs a restart.
Verified at 9523c18: both new tests fail on main and pass here, also under a symlinked TMPDIR; tsc, lint, the related unit tests (459) and the e2e files that call mcp inject or mcp remove pass; CI is green. We agree with the CI review's "no findings".
Co-authored-by: ydflow <[email protected]>
Summary
With a malformed tool config such as
~/.claude.json,teamai mcp injectandteamai mcp removecan exit 0 and print success or "Already up to date" / "Nothing to remove", even though that tool was skipped. Both commands now consume the reconciler's existingunparsedresult, list any successful changes, report the operation as incomplete with a retry instruction, and exit 1, including with--dry-run.Type of Change
Test Plan
npm run buildnpx tsc --noEmitnpm run lintnpx vitest run src/__tests__/mcp-cmd.test.ts— 13 passed. New checks exercise both commands with/without writes and in normal/dry-run mode.npx vitest run --config vitest.e2e.config.ts src/__tests__/e2e/mcp-command-errors.test.ts src/__tests__/e2e/mcp-uninstall.test.ts --retry=0— 2 files, 5 passed. The new file was rerun after strengthening its ownership assertion — 2 passed.npx vitest run --maxWorkers=4on Windows was stopped after unrelated failures; the full local suite is not claimed to pass. Four representative failures were reproduced in a clean worktree at upstream703d1c93e66d32c73e13ea6fffb14f7a9bfaf5a4: token permission assertions observe0o666instead of0o600(two cases), a skill-install ACK fails, and creating a path-alias symlink fails withEPERM. This is not a claim that every full-suite failure has been individually classified. Linux/macOS validation is left to CI.Real-CLI regression scenario (Windows, offline git fixtures, Claude and Cursor config targets):
Before the runtime fix, both new CLI cases failed at step 2 because the commands returned 0. No real model or remote provider requests are needed for these fixtures; extra provider/agent combinations are left to CI.
Related Issues
Found while reviewing MCP delivery error handling on current main. No duplicate Issue/PR found in the searches performed for this change.
Notes for Reviewers
The reconciliation engine and its file/ownership writes are unchanged.
unparsedis produced byreconcileTargetsand already read by env commands and team scripts; this change adds two command consumers. Partial updates remain applied, andmcp removestill releases only git exclusions the existing cleanup proves clean. The English/Chinese sharing guides and setup management reference describe the exit status and retry behavior.Scripts that previously treated a skipped tool config as success will now receive a nonzero exit status. This is an intentional failure-reporting correction; repairing the named config and rerunning the command completes the operation.