Skip to main content
FastMCP supports HTTPS for secure connections by providing SSL certificate options. This guide covers setting up HTTPS for development and production.

Quick start

Enable HTTPS by providing SSL certificate options:
The server will start with HTTPS on https://localhost:8443/mcp.

SSL options

string
required
Path to the SSL certificate file (PEM format)
string
required
Path to the SSL private key file (PEM format)
string
Path to the CA certificate for mutual TLS authentication (optional)

Development setup

For local development and testing, you can generate self-signed certificates:
1

Generate self-signed certificates

Use OpenSSL to create a self-signed certificate:
This creates:
  • key.pem - Private key
  • cert.pem - Self-signed certificate valid for 365 days
2

Configure your server

3

Accept self-signed certificate

When connecting from a client, you’ll need to accept the self-signed certificate warning. This is normal for development.
Never use self-signed certificates in production. They don’t provide proper authentication and are vulnerable to man-in-the-middle attacks.

Production setup

For production, use certificates from a trusted Certificate Authority (CA).

Using Let’s Encrypt

Let’s Encrypt provides free SSL certificates:
1

Install Certbot

2

Obtain certificate

Certificates will be saved to:
  • /etc/letsencrypt/live/your-domain.com/fullchain.pem (certificate)
  • /etc/letsencrypt/live/your-domain.com/privkey.pem (private key)
3

Configure server

4

Set up auto-renewal

Let’s Encrypt certificates expire after 90 days. Set up automatic renewal:

Using commercial certificates

If you have certificates from a commercial CA (DigiCert, GlobalSign, etc.):

Mutual TLS (mTLS)

For enhanced security, require clients to present valid certificates:
1

Generate client certificates

2

Configure server with CA

3

Connect with client certificate

Clients must present a certificate signed by the specified CA to connect.

Complete example

Here’s a production-ready HTTPS server with proper error handling:

Security best practices

1

Use strong cipher suites

Configure Node.js to use strong cipher suites:
2

Keep certificates secure

  • Store private keys with restricted permissions (chmod 600)
  • Never commit certificates to version control
  • Use environment variables for certificate paths
  • Consider using a secrets management service (AWS Secrets Manager, HashiCorp Vault)
3

Enable HSTS

Force HTTPS connections using HTTP Strict Transport Security:
4

Monitor certificate expiration

Set up alerts to renew certificates before they expire:

Troubleshooting

Verify the file paths are correct and the files exist:
This usually means:
  • The certificate and key don’t match
  • The certificate is invalid or expired
  • Wrong certificate format (should be PEM)
Verify certificate and key match:
The MD5 hashes should match.
Browsers and clients will warn about self-signed certificates. For development:
  • Accept the warning (temporary)
  • Add certificate to system trust store (better)
For production, always use certificates from a trusted CA.

Next steps

Production Deployment

Learn about production deployment best practices

Authentication

Add authentication to your HTTPS server