Add interactive OAuth login flow#36
Open
itz4blitz wants to merge 1 commit into
Open
Conversation
itz4blitz
marked this pull request as ready for review
July 12, 2026 15:16
itz4blitz
force-pushed
the
justin/oauth-login
branch
from
July 12, 2026 15:31
2cf60ac to
01f7f44
Compare
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.
Summary
Adds an interactive OAuth login so the server can authenticate to Linear without anyone pasting a long-lived API key. This is a standalone change off
main.Auth flow
auth loginruns an OAuth 2.0 authorization-code flow againsthttps://linear.app/oauth/authorizewith PKCE (S256) and a randomstate, using a loopback callback server on127.0.0.1(default port 8734, overridable with--redirect-port; must match a registered redirect URI). The client id/secret come from--client-id/--client-secretorLINEAR_OAUTH_CLIENT_ID/LINEAR_OAUTH_CLIENT_SECRET.Storage and security
~/.config/mcp-linear/credentials.json($XDG_CONFIG_HOMEandMCP_LINEAR_CONFIG_DIRhonored), file mode 0600 inside a 0700 directory, written atomically (temp file + rename).auth statusshows only a masked suffix, and OAuth HTTP errors are sanitized to the HTTP status.auth logoutrevokes the access token best-effort and deletes the local file even when revocation fails (e.g. offline).Precedence
--tokenCLI flagLINEAR_API_TOKEN/LINEAR_API_KEYenvironment variablesmcp-linear auth login(used asLinearClient({ accessToken }))Explicit credentials always win over the store, so existing setups are completely unaffected. This also composes cleanly with #34: if #34 merges, its explicit OAuth-token flags simply take precedence above the stored credentials, and a trivial rebase slots the store fallback below them.
Verification
npx jest: 33 suites, 228 tests passing (58 cover the auth modules and config precedence: PKCE, state mismatch, store permissions, corrupt-store tolerance, refresh rotation persistence, no secrets in output, credential precedence). Tests perform no network I/O and write only under temp dirs viaMCP_LINEAR_CONFIG_DIR.npm run build,npm run test:mcp-smoke(185 tools, 6 resources, 4 prompts),npm pack --dry-run, andgit diff --checkall pass.auth,auth status,auth logout, missing-credential server startup) and booted the MCP server end-to-end from a seeded credential store with no token in the environment.No tool definitions or handlers are touched, and there is no package version bump.