fix: preserve MCP token registration errors and failure exits - #210
Merged
Conversation
jwfing
reviewed
Sep 11, 2026
jwfing
left a comment
Member
There was a problem hiding this comment.
Summary
The implementation correctly distinguishes missing credentials from token/API failures and prevents incomplete explicit MCP registration from reporting success.
Requirements context
Intent was derived from the PR description, issue #209, repository development guidance, and the companion skill documentation PR. Together they require preserving API/transport errors, failing incomplete explicit token registration, retaining login retry and existing configurations, documenting token-creation permission, preserving agent identity/governance, and keeping optional OAuth discovery functional.
Findings
Critical
(none)
Suggestion
(none)
Information
- Software engineering / functionality:
mintMcpTokennow returnsnullonly when credentials are absent, validates successful responses, and allows API or transport exceptions to reach the command guard. Required-registration checks correctly set a failure exit, while interactive retry remains outside the token-error catch (src/commands/setup.ts:227-235,src/commands/setup.ts:452-475). - Explicit non-Claude
--mcp-tokenrequests are rejected before configuration writes, while absent-Claude OAuth auto-detection remains optional (src/commands/mcp.ts:120-130). Unit coverage exercises API/transport errors, malformed responses, existing registrations, partial multi-client setup, post-login denial, and unsupported client combinations (test/mcp-token.test.ts:27-113). - The subprocess regression verifies the real CLI’s HTTP 403 reporting, signed agent request, exit status, lack of registration writes, and absence of credential disclosure (
test/mcp-token-cli.test.ts:53-75). - Security: No authorization bypass was introduced. Token creation continues through the authenticated API client, agent governance errors propagate unchanged, and token values are not added to diagnostic output (
src/commands/setup.ts:227-233,src/commands/setup.ts:256-267). No new dependencies or new untrusted-input execution paths were added. - Performance: No performance-relevant issues found; the change adds only constant-time status checks and response validation around an existing one-shot API request (
src/commands/setup.ts:227-235,src/commands/setup.ts:278-283). git diff --checkis clean, and both Linux and Windows checks passed for the reviewed head. Local typecheck/tests could not start because this read-only checkout lacks installed dependencies (tscis unavailable).
Verdict
Approved: no Critical, Suggestion, security, or performance findings.
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.
A signed-in agent requesting
--mcp-tokencould receive403 unclassified_agent_action, be told to log in again, and exit 0 without registering MCP. Preserve token-creation errors and return a failure when explicit Claude registration is incomplete, including when another client's OAuth entry was installed.Token minting now distinguishes absent credentials from API/transport failures. The interactive login retry remains available, but token errors after successful login no longer enter the browser-login catch. Existing registrations stay untouched, OAuth auto-detection still skips absent Claude installations, and
--mcp-tokenwith an explicitly different client is rejected before writing configuration.Agent governance is unchanged: the CLI reports the denial and does not retry as a human. This fixes error reporting, not the separate OAuth continuation issue.
Validation:
npm run typecheckand all 899 tests / 60 files pass on Node 22.22.1 in an isolated, unauthenticated test copy. The new subprocess regression exercises the real CLI with a loopback platform and verifies signed agent requests, HTTP 403 in stderr, exit 1, and no registration write; missing login, post-login denial, existing config, and partial setup are also covered. An independent read-only review found no actionable issues.Closes #209. Companion skill guidance: InsForge/instacloud-skills#88
Summary by cubic
Fixes
--mcp-tokenregistration so token-creation errors are preserved and incomplete Claude registration now exits with a failure instead of a false success.Bug Fixes
--mcp-tokenwith a non-Claude agent is rejected before any config is written.Written for commit 0d911c7. Summary will update on new commits.