fix(cli): login over HTTPS + suggest last-used email #78
Reference in New Issue
Block a user
Delete Branch "fix/login-https-and-email-suggest"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes
mcpctl logincrashing with "JSON Parse error: Unexpected EOF" when mcpdUrl uses https.Root cause
auth.tsusednode:httpunconditionally withport: url.port. Anhttps://mcpdUrl (no explicit port) connected to the ingress on :80, got a 301 redirect with an empty body (status < 400 so the error guard passed), thenJSON.parse('')threw.api-client.ts(used byget servers) already picked https/443 correctly — only the auth commands had the bug.Changes
api-client.ts.parseJsonResponse()guard: non-JSON <400 body -> clear "Invalid response from mcpd" error instead of a raw SyntaxError.loginsuggests the previously-used email (same mcpd) so Enter reuses it after a session expires.Tests
default*request fns: valid JSON, empty body, HTML redirect body, https driver selection.🤖 Generated with Claude Code
auth.ts talked to mcpd over node:http unconditionally with port:url.port, so an https:// mcpdUrl connected to the ingress on :80, got a 301 redirect with an empty body (status < 400), and JSON.parse('') crashed login with "Unexpected end of JSON input". api-client.ts already handled this; the auth commands did not. - All 4 auth request fns now pick https/443 and the TLS driver from the URL protocol, mirroring api-client.ts. - parseJsonResponse() guard turns any non-JSON <400 body into a clear "Invalid <ctx> response from mcpd" error instead of a raw SyntaxError. - login now suggests the previously-used email (when a session for the same mcpd exists) so pressing Enter reuses it after a session expires. - Regression tests drive the real default* request fns against a local HTTP server (valid JSON, empty body, HTML redirect body, https driver selection) and cover the email-suggestion behaviour. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>