Overview
The HTTPS MCP server provides:- TLS/SSL encryption for secure communication
- OAuth2 authentication flow
- Self-signed certificate generation with X.509 attributes
- Bearer token validation
The Certificate Trust Challenge
Claude Code uses Node.js internally, which maintains its own certificate store separate from your system’s certificate store. Even if you trust a certificate in macOS Keychain or Windows Certificate Store, Node.js won’t recognize it. When connecting to an HTTPS server with a self-signed certificate:fetch failederrors in Claude Codeunable to verify the first certificateerrors- Connection failures despite browser access working
Solution: NODE_EXTRA_CA_CERTS
Tell Node.js about your certificate using theNODE_EXTRA_CA_CERTS environment variable.
Setup
1
Start the HTTPS Server
- Generate a self-signed certificate
- Save it to
~/Library/Application Support/codanna/certs/server.pem(macOS) - Display certificate details and fingerprint
2
Copy certificate to standard location
3
Configure MCP client
Add to
.mcp.json:4
Launch Claude Code with certificate trust
5
Verify connection
In Claude Code, use
/mcp to check status:Shell Alias
Add to~/.bashrc or ~/.zshrc:
System-wide Trust (macOS)
For system-wide trust (Node.js still requiresNODE_EXTRA_CA_CERTS):
OAuth Authentication Flow
The HTTPS server includes OAuth2:- Discovery:
/.well-known/oauth-authorization-server - Registration:
/oauth/register - Authorization:
/oauth/authorize - Token Exchange:
/oauth/token
Troubleshooting
”fetch failed” Error
Ensure you’re running Claude Code withNODE_EXTRA_CA_CERTS:
Certificate Already Exists
Delete existing certificates to regenerate:401 Unauthorized
The OAuth flow handles authentication automatically. If you see 401 errors:- Check server logs for Bearer token validation messages
- Ensure you’re using
"type": "http"in.mcp.json - Reconnect with
/mcpin Claude Code
Browser Works But Claude Code Doesn’t
Browsers use the system certificate store, but Node.js doesn’t. UseNODE_EXTRA_CA_CERTS.
Certificate Locations
On Windows, use forward slashes:
Production Alternatives
Self-signed certificates are for local development. For production:- Let’s Encrypt: Use certbot for free, valid certificates
- Reverse Proxy: Place nginx/caddy with valid certs in front
- Cloud Provider: Use managed certificates from AWS, GCP, Azure
- Corporate CA: Use your organization’s internal certificate authority
Next Steps
MCP Network
HTTP and HTTPS server modes for multiple clients.
MCP Persistent
Stdio transport — alternative to HTTPS for single-client setups.