You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fixes#1224. The file-backed MCP refresh-token store now skips fchmod on Windows, where the supported Python version does not provide it. POSIX still requires fchmod(0600) and fails closed if that step fails. The login CLI reports token-store OSError as a clean failure instead of a traceback.
Verification
Added regression tests for Windows file save/load, POSIX chmod failure, and the CLI error message.
Ran isolated checks against the actual token-store and CLI modules: Windows save/load and POSIX fail-closed behavior passed; CLI emitted Login failed: cannot store token and returned 1.
python -m compileall -q on changed files and git diff --check passed.
PYTHONPATH=/tmp/opencre-app-deps:$PWD python -m unittest application.tests.mcp_auth_test -v passed: 16 tests (small missing dependencies installed only in a temporary path). The full suite and a native Windows run remain untested.
LLM Usage Considerations
Codex helped investigate the bug, write the fix and tests, and prepare this PR description. The behavior was checked with the stated tests. Independent review by the human contributor is pending; no claim of human validation is made.
No actionable comments were generated in the recent review.
Summary by CodeRabbit
Bug Fixes
Login now reports token-storage errors as login failures and returns a failure status.
Token saving now handles file permissions appropriately across Windows and other platforms. On non-Windows systems, permission-setting failures are reported rather than silently ignored.
Walkthrough
Token saving now skips os.fchmod on Windows and retains mode-setting error handling on other platforms. The login command reports OSError as a login failure.
This change lets MCP login save and refresh tokens on Windows by skipping the POSIX-only permission call. POSIX behavior is unchanged and still fails closed, and the login command now reports storage errors cleanly. No concrete merge-blocking defect was found. A native Windows run would be a useful follow-up check.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title "Fix MCP token file save on Windows" matches the main change: the file-backed MCP token store now skips fchmod on Windows so saves succeed there. It is specific and concise, and it names the…
Linked Issues check
Issue #1224 requires that MCP login store the refresh token with the file backend on Windows, that POSIX keep fail-closed mode-setting, and that the login CLI report token-store OSError cleanly. The r…
Out of Scope Changes check
The whole-PR diff against the merge base changes three files: application/mcp/token_store.py, application/mcp/cli.py, and application/tests/mcp_auth_test.py. The token_store.py and cli.py hunks implem…
Description check
The description states the PR purpose: skipping fchmod on Windows in the file-backed MCP refresh-token store, keeping fchmod(0600) with fail-closed behavior on POSIX, and making the login CLI report t…
Full details: Title check
Explanation
The title "Fix MCP token file save on Windows" matches the main change: the file-backed MCP token store now skips fchmod on Windows so saves succeed there. It is specific and concise, and it names the platform and component.
Full details: Linked Issues check
Explanation
Issue #1224 requires that MCP login store the refresh token with the file backend on Windows, that POSIX keep fail-closed mode-setting, and that the login CLI report token-store OSError cleanly. The reviewed diff addresses each point. In application/mcp/token_store.py, save() calls os.fchmod(fd, 0o600) only when sys.platform != 'win32'. On POSIX, an AttributeError or OSError from fchmod still closes the descriptor and raises OSError, so fail-closed behavior is kept. In application/mcp/cli.py, _login() catches (auth.AuthError, OSError), prints 'Login failed: ...', and returns 1. Refresh uses the same save path, so the Windows fix applies there too. The author reports regression tests for these cases in application/tests/mcp_auth_test.py. I did not run those tests. The repository test module could not start in the author's checkout, so the test results are reported but not independently confirmed.
Full details: Out of Scope Changes check
Explanation
The whole-PR diff against the merge base changes three files: application/mcp/token_store.py, application/mcp/cli.py, and application/tests/mcp_auth_test.py. The token_store.py and cli.py hunks implement #1224 directly. The token_store.py hunk also updates the related comment to describe the Windows ACL behavior. The test changes cover the Windows save path, POSIX chmod failure, and the CLI error message, which supports the issue requirements. No unrelated functional change was found in the inspected hunks.
Full details: Description check
Explanation
The description states the PR purpose: skipping fchmod on Windows in the file-backed MCP refresh-token store, keeping fchmod(0600) with fail-closed behavior on POSIX, and making the login CLI report token-store OSError cleanly. It also lists the tests added and the verification run. This matches the changeset (token_store.py, cli.py, mcp_auth_test.py), so the description is related and specific.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Reviewing files that changed from the base of the PR and between 6bc7a30 and fb0fe71.
Files selected for processing: 3
application/mcp/cli.py
application/mcp/token_store.py
application/tests/mcp_auth_test.py
Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.
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
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.
Summary
Fixes #1224. The file-backed MCP refresh-token store now skips
fchmodon Windows, where the supported Python version does not provide it. POSIX still requiresfchmod(0600)and fails closed if that step fails. The login CLI reports token-storeOSErroras a clean failure instead of a traceback.Verification
Login failed: cannot store tokenand returned 1.python -m compileall -qon changed files andgit diff --checkpassed.PYTHONPATH=/tmp/opencre-app-deps:$PWD python -m unittest application.tests.mcp_auth_test -vpassed: 16 tests (small missing dependencies installed only in a temporary path). The full suite and a native Windows run remain untested.LLM Usage Considerations
Codex helped investigate the bug, write the fix and tests, and prepare this PR description. The behavior was checked with the stated tests. Independent review by the human contributor is pending; no claim of human validation is made.