Fixing token_expired When Connecting MCP Inspector to Salesforce Hosted MCP Servers
If you are testing Salesforce Hosted MCP Servers locally using @modelcontextprotocol/inspector , you will likely hit two frustrating roadblocks before seeing a single tool schema:
Salesforce rejects plain http://127.0.0.1 callback URLs.
Once you get HTTPS working and complete OAuth, MCP Inspector immediately fails with Auth challenge: token_expired and Unexpected: auth() returned AUTHORIZED without authorization code - even though your network tab shows tokens arriving cleanly.
Here is the exact local HTTPS setup and the one Salesforce OAuth checkbox that fixes the handshake loop.
Step 1: Serve MCP Inspector over Local HTTPS with mkcert
Salesforce strictly enforces HTTPS on external callback URLs (only exempting http://localhost in narrow contexts, while rejecting [http://127.0.0.1](http://127.0.0.1) , which MCP Inspector binds to by default).
Use mkcert to generate a locally trusted certificate for 127.0.0.1 and pass…