Description
Summary
After configuring an OAuth-protected HTTP MCP server (Nordic MCP at https://aidev.nordicsemi.com/mcp) in mcp.json, the following chain of issues made authentication far more difficult than it should be.
Steps to reproduce
- Added
nordic-mcp to mcp.json (HTTP type, no explicit auth fields)
- Restarted CodeWhale —
list_mcp_resources returned empty []
tool_search for nordic returned zero deferred tools
- Had to manually grep
~/.codewhale/logs/ to discover: 401 Unauthorized, bearer token expired
codewhale mcp list showed auth=not-logged-in
codewhale mcp connect nordic-mcp failed with 401 and exited — no hint to use login
- Foreground
codewhale mcp login nordic-mcp generated the authorization URL but was killed by exec_shell's 30-second timeout while waiting for the browser callback
- Finally ran
mcp login in background mode; user completed OAuth in the browser; credentials were stored successfully
Root issues
| # |
Issue |
Detail |
| 1 |
Stale token not auto-refreshed |
CodeWhale caches an expired bearer token, gets 401, and silently fails instead of clearing it and re-initiating OAuth |
| 2 |
Auth errors silently swallowed |
list_mcp_resources returns an empty array with no indication that authentication is required; user must dig through logs |
| 3 |
mcp connect doesn't trigger OAuth |
mcp connect receives 401 and exits immediately without suggesting mcp login |
| 4 |
mcp login times out in foreground |
OAuth requires manual browser interaction, so foreground execution is guaranteed to hit the timeout; no progress indicator or background-mode guidance |
| 5 |
mcp list shows auth=not-logged-in but doesn't auto-recover |
The client is aware of the unauthenticated state but takes no action |
Expected behavior
- On receiving 401, automatically clear the stale token and (in TUI) prompt the user to complete OAuth login
list_mcp_resources / list_mcp_resource_templates should return a human-readable error (e.g., {"error": "authentication_required", "server": "nordic-mcp"}) instead of an empty array when authentication fails
mcp connect should print a helpful message on 401: "This server requires OAuth authentication. Run codewhale mcp login <name>"
mcp login should print a clear status line after starting the local callback server ("Waiting for browser authorization…") and warn on prolonged inactivity rather than crashing
Description
Summary
After configuring an OAuth-protected HTTP MCP server (Nordic MCP at
https://aidev.nordicsemi.com/mcp) inmcp.json, the following chain of issues made authentication far more difficult than it should be.Steps to reproduce
nordic-mcptomcp.json(HTTP type, no explicit auth fields)list_mcp_resourcesreturned empty[]tool_searchfornordicreturned zero deferred tools~/.codewhale/logs/to discover:401 Unauthorized, bearer token expiredcodewhale mcp listshowedauth=not-logged-incodewhale mcp connect nordic-mcpfailed with 401 and exited — no hint to uselogincodewhale mcp login nordic-mcpgenerated the authorization URL but was killed byexec_shell's 30-second timeout while waiting for the browser callbackmcp loginin background mode; user completed OAuth in the browser; credentials were stored successfullyRoot issues
list_mcp_resourcesreturns an empty array with no indication that authentication is required; user must dig through logsmcp connectdoesn't trigger OAuthmcp connectreceives 401 and exits immediately without suggestingmcp loginmcp logintimes out in foregroundmcp listshowsauth=not-logged-inbut doesn't auto-recoverExpected behavior
list_mcp_resources/list_mcp_resource_templatesshould return a human-readable error (e.g.,{"error": "authentication_required", "server": "nordic-mcp"}) instead of an empty array when authentication failsmcp connectshould print a helpful message on 401: "This server requires OAuth authentication. Runcodewhale mcp login <name>"mcp loginshould print a clear status line after starting the local callback server ("Waiting for browser authorization…") and warn on prolonged inactivity rather than crashing