Overview
Hevy HTTP MCP uses bearer token authentication to protect the MCP endpoint from unauthorized access. Every request to/mcp must include your MCP_API_KEY in the Authorization header.
How Authentication Works
The server implements a custom authentication handler that:- Checks for the
Authorizationheader in incoming requests - Extracts the token (supports both
Bearer <token>format and raw token) - Validates the token against the configured
MCP_API_KEY - Returns appropriate error responses for missing or invalid tokens
Authentication Flow
Here’s the authentication implementation from the server:Authorization Header Formats
The server accepts two formats for theAuthorization header:
- Bearer Token (Recommended)
- Raw Token
Standard bearer token format:This is the recommended format and is used by most MCP clients.
Response Codes
Returned when the
Authorization header is missing from the request.Returned when the provided API key doesn’t match the configured
MCP_API_KEY.Authentication successful. The request proceeds to the MCP tool handler.
Testing Authentication
You can test authentication using curl:Valid Request
Missing Header
Invalid Key
Security Considerations
Key Management
-
Generate strong keys: Use at least 32 characters of random data
-
Never commit keys: The
.envfile is gitignored by default. Keep it that way. -
Rotate regularly: Change your
MCP_API_KEYperiodically or if compromised - Use environment variables: Never hardcode keys in client configurations that might be shared
Network Security
This server uses HTTP, not HTTPS. For production deployments, place it behind a reverse proxy (nginx, Caddy) with TLS enabled.
- Local development: Binding to
127.0.0.1(default) only accepts connections from your machine - Remote access: If using
HOST=0.0.0.0, ensure you’re behind a firewall or VPN - Production: Always use HTTPS in production environments to encrypt the
Authorizationheader in transit
Access Scopes
When authentication succeeds, the server assigns these scopes to the authenticated client:MCP_API_KEY grants full access.
Hevy API Key Security
Your
HEVY_API_KEY is never exposed to MCP clients. It’s only used server-side when making requests to api.hevyapp.com.- Client → MCP Server: Authenticated with
MCP_API_KEY - MCP Server → Hevy API: Authenticated with
HEVY_API_KEY
- Clients never see your Hevy API credentials
- You can revoke MCP client access without changing your Hevy API key
- Multiple clients can share one MCP server with a single
MCP_API_KEY