User Agents

Web browsers and everyday web tech, explained

Fix Claude MCP Auth When Browser Won't Open

· 6 min read · Browsers

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

When Claude's Model Context Protocol (MCP) authentication fails because the browser won't open, you're usually dealing with a local callback URL issue, a missing browser handler, or a stuck OAuth flow. This guide walks you through manual fixes that get the auth code into Claude without relying on the automatic browser popup. You'll need terminal access, the ability to edit configuration files, and a way to copy text from your browser if you can open it manually.

What You'll Need

  • Terminal or command prompt access on the machine running Claude Desktop or the MCP server.
  • The MCP server's configuration file location (typically claude_desktop_config.json on macOS/Windows, or a project-level .mcp.json).
  • A web browser that can be opened manually (even if the automatic launch fails).
  • Basic familiarity with editing JSON files and running command-line tools.

Step-by-Step

  1. Identify the MCP server and its auth method. Check your MCP configuration file (e.g., claude_desktop_config.json) to see which servers are defined and whether they use OAuth, API keys, or other auth. Look for entries with "auth" or "oauth" fields.
  2. Check the server logs for the auth URL. Run the MCP server manually in a terminal (e.g., npx @modelcontextprotocol/server-github) and watch the output. When auth is needed, the server usually prints a URL like https://github.com/login/oauth/authorize?client_id=.... Copy that URL.
  3. Manually open the auth URL in your browser. Paste the URL into a browser you open yourself (Chrome, Firefox, Safari). If the browser refuses to open or the page doesn't load, try a different browser or use a private/incognito window.
  4. If the URL is a localhost callback, check the port. Many MCP servers use a redirect to http://localhost:PORT/callback. If the port is blocked or already in use, the browser will show a connection error. Change the port in the server's config or free the port by closing other processes.
  5. Use the manual code entry method. Some MCP servers (like GitHub or Google) allow you to copy the authorization code from the browser's address bar after you approve. Look for a code= parameter in the URL after redirect. Copy that code and paste it back into the terminal prompt where the server is waiting.
  6. If no code is displayed, check the server's documentation. Some servers use a device flow where you enter a code on a separate page. For example, GitHub's device flow shows a code like XXXX-XXXX that you enter at https://github.com/login/device. Follow that process manually.
  7. After auth, restart Claude and test. Once the server receives the token, it should save it locally (often in a .mcp-auth file or similar). Restart Claude Desktop or your MCP client and try the tool again. If it still fails, delete the saved token file and repeat the manual flow.
  8. If the browser never opens at all, set the default browser. On macOS, go to System Settings > Desktop & Dock > Default web browser. On Windows, go to Settings > Apps > Default apps. Choose a browser that is installed and working.
  9. For headless environments (SSH, Docker), use a CLI auth helper. If you're running Claude on a server, install a tool like mcp-auth-cli or use the --auth-browser flag (if supported) to force a manual copy-paste flow. Otherwise, you may need to run the auth on your local machine and transfer the token file.

Common Mistakes

  • Ignoring the redirect URI mismatch. The MCP server's registered redirect URI must exactly match what the browser tries to open. If you changed the port, the auth fails silently.
  • Copying the wrong code. Some OAuth flows show both an authorization code and an access token. Make sure you copy the one the server is asking for (usually the code).
  • Leaving the terminal waiting while you open the browser. The auth flow has a timeout (often 5–10 minutes). If you wait too long, the code expires and you must restart the flow.
  • Using a browser with strict privacy settings. Some browsers block third-party cookies or popups, which can break the OAuth redirect. Try a different browser or disable ad-blockers temporarily.
  • Not checking firewall or VPN. A VPN or firewall can block the localhost callback. Temporarily disable them to see if that's the issue.

Tips

  • Use the same browser profile that you normally use. Some OAuth providers remember your session, so using a fresh incognito window might require re-entering credentials.
  • Keep the terminal window visible. The server often prints the auth URL and waits for input. Don't close it.
  • If you're using a remote machine, forward the port. Use SSH port forwarding (ssh -L 8080:localhost:8080 user@remote) so the localhost callback reaches your local browser.
  • Save the auth URL to a note. If the browser fails to open, you can manually type the URL into a browser on another device, as long as the callback port is accessible.
  • Check for existing tokens. Sometimes the auth is already complete but the token file is corrupted. Delete it and re-auth.

Troubleshooting

  • Browser opens but shows "This site can't be reached". The localhost port is likely not listening. Check the server's output for the exact port and ensure nothing else is using it. Run lsof -i :PORT (macOS/Linux) or netstat -ano | findstr :PORT (Windows).
  • Auth URL opens but you get an "invalid redirect_uri" error. The MCP server's registered redirect URI doesn't match the one in the URL. Check the server's documentation for the correct redirect URI and update your config.
  • The server times out while waiting for the code. Restart the server and try again, but this time have the browser ready. If the issue persists, try the device flow if available.
  • Claude still says "authentication required" after successful auth. The token may not have been saved to the correct location. Look for a .mcp-auth file in the server's working directory and verify it contains the token. If not, check file permissions.
  • No URL is printed at all. The server may be using a pre-configured API key. Check your config for an apiKey field and set it manually.
  • Everything works but only once. Some servers require re-auth after a token expiry. Set up a refresh token or a longer expiry if possible.

Frequently Asked Questions

Why doesn't the browser open automatically when I run MCP auth?

Claude Desktop or the MCP client tries to launch the default browser, but if the default browser is missing, misconfigured, or the command fails silently, nothing opens. The server still prints the URL in the terminal, so you can open it manually.

Can I authenticate MCP without a browser at all?

Yes, if the server supports a device flow (like GitHub) or a manual code entry. Otherwise, you can use a headless browser tool like puppeteer to automate the flow, but that's more complex. For most users, manually opening the URL in a browser you control is the simplest workaround.

What is the redirect URI and why does it matter?

The redirect URI is the callback URL that the OAuth provider sends the user back to after approval. The MCP server must have this exact URI registered with the provider. If you change the port or host, the auth fails. Always use the exact URI shown in the server's docs.

How do I know if my MCP server uses OAuth or an API key?

Check the server's README or the configuration file. OAuth servers typically have fields like clientId, clientSecret, and authUrl. API key servers have a single apiKey field. If you're unsure, run the server and see if it prints an auth URL.

Can I use a different port for the callback?

Yes, but you must update both the MCP server's config and the registered redirect URI with your OAuth provider. For example, if you change from 8080 to 9090, update the provider's app settings to use http://localhost:9090/callback.

What if I'm using Claude Code in a terminal, not the desktop app?

The same principles apply. The MCP server will print the auth URL. If the browser doesn't open, copy the URL manually. For headless setups, use the --auth-browser manual flag if supported, or transfer the token file from a machine with a browser.