Skip to content

remove auth gate for start - #2

Merged
nathanBurg merged 1 commit into
mainfrom
fix/mcp-server-auth-gate
Feb 24, 2026
Merged

remove auth gate for start#2
nathanBurg merged 1 commit into
mainfrom
fix/mcp-server-auth-gate

Conversation

@nathanBurg

Copy link
Copy Markdown
Contributor

Problem

When the MCP server is launched by an AI client (e.g. Claude Code via plugin), requireAuth() in startMcpServer throws AuthRequiredError and triggers process.exit(1) before the MCP handshake completes. The client sees a silent Connection closed error and never discovers any tools:

MCP server "plugin:githits:githits": Connection failed after 1467ms: MCP error -32000: Connection closed

This makes the Claude Code plugin completely non-functional for any user who hasn't already run githits login out-of-band.

Root Cause

requireAuth() was designed for interactive CLI commands where exiting with an auth message makes sense. For the MCP server, it kills the long-running process before the client can communicate with it — there's no opportunity to report the auth error back through the protocol.

Fix

Remove requireAuth() from startMcpServer and the corresponding AuthRequiredError catch blocks from both action handlers. Auth enforcement is not removed — it is already handled per-request by RefreshingGitHitsService.withTokenRefresh(), which throws AuthenticationError when no token is available. withErrorHandling() catches this and returns a structured isError tool result that the AI client can act on (e.g. running githits login automatically).

Changes

  • src/commands/mcp.ts — Remove requireAuth call from startMcpServer, remove try/catch (AuthRequiredError) from both .action() handlers, remove unused imports
  • src/commands/mcp.test.ts — Replace "throws AuthRequiredError on auth failure" test with "starts successfully without a valid token" test
  • package.json — Bump version to 0.1.2

Related

See companion PR in githits-claude-code-plugin which updates SKILL.md to instruct Claude to auto-run githits login when it receives an auth error from a tool call.

@nathanBurg
nathanBurg merged commit f564b49 into main Feb 24, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants