claude-code - 💡(How to fix) Fix Linear MCP OAuth fails with "Invalid client" — metadata-URL clientId + ephemeral loopback port [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#47185Fetched 2026-04-13 05:39:12
View on GitHub
Comments
1
Participants
2
Timeline
6
Reactions
0
Author
Timeline (top)
labeled ×5commented ×1

Linear MCP (https://mcp.linear.app/mcp) rejects Claude Code's OAuth authorize request with:

Invalid client. The clientId provided does not match to this client.

Every new session requires re-authentication because no refresh token is ever obtained (auth never completes). Clearing mcpOAuth from the keychain, removing/re-adding the server, and revoking the app in Linear all fail to fix it.

Error Message

From ~/Library/Caches/claude-cli-nodejs/<project>/mcp-logs-linear-server/*.jsonl:

{"debug":"No client info found"}
{"debug":"Token expired without refresh token"}
{"debug":"Authorization URL: https://mcp.linear.app/authorize?response_type=code&client_id=https%3A%2F%2Fclaude.ai%2Foauth%2Fclaude-code-client-metadata&...&redirect_uri=http%3A%2F%2Flocalhost%3A53076%2Fcallback&..."}
{"debug":"Scopes in URL: NOT FOUND"}
{"debug":"Error during auth completion: AuthenticationCancelledError: Authentication was cancelled"}

Browser lands on Linear's /authorize page showing the "Invalid client" error before the user can consent.

Root Cause

Every new session requires re-authentication because no refresh token is ever obtained (auth never completes). Clearing mcpOAuth from the keychain, removing/re-adding the server, and revoking the app in Linear all fail to fix it.

Code Example

client_id=https://claude.ai/oauth/claude-code-client-metadata

---

{
  "redirect_uris": ["http://localhost/callback", "http://127.0.0.1/callback"],
  ...
}

---

redirect_uri=http://localhost:53076/callback

---

{"debug":"No client info found"}
{"debug":"Token expired without refresh token"}
{"debug":"Authorization URL: https://mcp.linear.app/authorize?response_type=code&client_id=https%3A%2F%2Fclaude.ai%2Foauth%2Fclaude-code-client-metadata&...&redirect_uri=http%3A%2F%2Flocalhost%3A53076%2Fcallback&..."}
{"debug":"Scopes in URL: NOT FOUND"}
{"debug":"Error during auth completion: AuthenticationCancelledError: Authentication was cancelled"}
RAW_BUFFERClick to expand / collapse

Description

Linear MCP (https://mcp.linear.app/mcp) rejects Claude Code's OAuth authorize request with:

Invalid client. The clientId provided does not match to this client.

Every new session requires re-authentication because no refresh token is ever obtained (auth never completes). Clearing mcpOAuth from the keychain, removing/re-adding the server, and revoking the app in Linear all fail to fix it.

Environment

  • Claude Code: 2.1.104
  • macOS 25.3.0 (Darwin)
  • MCP server: https://mcp.linear.app/mcp (http transport)

Root cause (suspected)

Claude Code uses the Client ID Metadata Document spec — sending its metadata URL as the client_id:

client_id=https://claude.ai/oauth/claude-code-client-metadata

That metadata doc declares:

{
  "redirect_uris": ["http://localhost/callback", "http://127.0.0.1/callback"],
  ...
}

But Claude Code sends an ephemeral loopback port in the actual authorize request:

redirect_uri=http://localhost:53076/callback

Linear advertises client_id_metadata_document_supported: true and appears to do strict matching of redirect_uri against the declared list, which doesn't include a port. Per RFC 8252 §7.3, servers MUST allow any port for loopback redirect URIs — but it's ambiguous how this interacts with the Client ID Metadata Document draft.

Either:

  • Claude's metadata doc should declare http://localhost:*/callback (or equivalent port-wildcard form), or
  • Claude should send port-less loopback URIs, or
  • Linear should honor RFC 8252's port-wildcard rule here.

Logs

From ~/Library/Caches/claude-cli-nodejs/<project>/mcp-logs-linear-server/*.jsonl:

{"debug":"No client info found"}
{"debug":"Token expired without refresh token"}
{"debug":"Authorization URL: https://mcp.linear.app/authorize?response_type=code&client_id=https%3A%2F%2Fclaude.ai%2Foauth%2Fclaude-code-client-metadata&...&redirect_uri=http%3A%2F%2Flocalhost%3A53076%2Fcallback&..."}
{"debug":"Scopes in URL: NOT FOUND"}
{"debug":"Error during auth completion: AuthenticationCancelledError: Authentication was cancelled"}

Browser lands on Linear's /authorize page showing the "Invalid client" error before the user can consent.

Steps to reproduce

  1. claude mcp add --transport http linear-server https://mcp.linear.app/mcp
  2. /mcp → authenticate Linear
  3. Browser shows "Invalid client. The clientId provided does not match to this client."

Related

  • #28256 — MCP OAuth token refresh not persisting (Notion) — same shape
  • #5706 — Missing token refresh mechanism for MCP
  • #38102, #26675 — MCP OAuth DCR/clientId handling

extent analysis

TL;DR

The most likely fix is to modify the redirect_uri in the authorize request to match the declared list in the Client ID Metadata Document, possibly by removing the ephemeral port or using a port-wildcard form.

Guidance

  • Verify that the redirect_uri sent in the authorize request matches one of the declared redirect_uris in the Client ID Metadata Document.
  • Consider modifying Claude Code to send a port-less loopback URI, such as http://localhost/callback, to align with the declared metadata.
  • Alternatively, update the Client ID Metadata Document to include a port-wildcard form, such as http://localhost:*/callback, although this may not be supported by Linear.
  • Review the related issues (#28256, #5706, #38102, #26675) to ensure that the OAuth token refresh mechanism is properly implemented and persisted.

Example

No code snippet is provided as the issue is more related to the configuration and interaction between Claude Code and Linear's OAuth implementation.

Notes

The ambiguity in the interaction between the Client ID Metadata Document draft and RFC 8252 §7.3 may require further clarification or support from Linear to resolve the issue.

Recommendation

Apply a workaround by modifying the redirect_uri in the authorize request to match the declared list in the Client ID Metadata Document, as this is the most direct and feasible solution given the current information.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix Linear MCP OAuth fails with "Invalid client" — metadata-URL clientId + ephemeral loopback port [1 comments, 2 participants]