Repository navigation
fix(mcp): report a missing agent CLI instead of crashing - #181
Merged
Merged
Conversation
`secfoo mcp sync` called `gemini` or `agent` through subprocess without checking that the binary exists, so a missing CLI raised FileNotFoundError and printed a traceback. Check PATH first and return one failed SyncResult that names the missing CLI. For `agent`, this happens before the Cursor config is written. Co-Authored-By: Claude Haiku 5.5 <[email protected]>
On Windows npm installs gemini/agent as a .cmd shim. shutil.which finds it via PATHEXT, but subprocess.run with a bare "gemini" does not, so the new installed-check passed and sync still raised FileNotFoundError. Route the three CLI calls through _run_cli(), which launches the resolved path (same approach as BaseAdapter.run). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Leaderboard update
cnYui now has 3 points (rank #11). 22 more to reach Bronze. |
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.
Closes #169
What does this change, and why?
secfoo mcp sync --agent geminiand--agent agentcall thegemini/agentCLI throughsubprocess.runwithout checking that it is installed. When the binary is missing, the sync crashes with aFileNotFoundErrortraceback instead of the one-line failure the CLI already knows how to print.This change checks
shutil.whichfirst and returns a single failedSyncResultthat names the missing CLI, so the command exits 1 with a clear message. Foragent, the check runs before the Cursormcp.jsonis created or written, so nothing is changed when the CLI is absent.Scope is limited to these two entry points. The gemini and agent code paths are otherwise unchanged. PR #180 also edits
sync_cursor(non-objectmcp.json); the two changes touch different lines and may need a trivial rebase.Testing
pytest tests/test_mcp.py: 15 passed, including two new tests (test_sync_gemini_reports_missing_cli_instead_of_crashing,test_sync_cursor_reports_missing_cli_before_writing_config). An autouse fixture makes the existing sync tests assume the CLIs are on PATH, so they keep exercising the same behavior.ruff check src/secfoo/mcp.py tests/test_mcp.py: the same 3PLW1510findings (subprocess.runwithoutcheck=) as onmain; no new findings.pytest testson Windows: 1904 passed, 18 failed, 4 skipped. I ran the failing modules on an unmodifiedmaincheckout and they fail there too (skill packs, memory, port guard, web dashboards, adversarial eval). One adversarial-eval test is flaky: it passed alone on this branch and failed alone onmain. None of these failures relate tomcp.py.🤖 Generated with Claude Code