fix(transport): add optional bearer token authentication for HTTP transport#162
Merged
Merged
Conversation
…nsport The HTTP transport had no built-in way to require authentication. Add an optional MCP_AUTH_TOKEN that, when set, requires 'Authorization: Bearer <token>' on requests to the MCP endpoint, verified in constant time (digest compare, safe for non-ASCII input) via a TokenVerifier plugged into FastMCP's auth layer. Empty or whitespace-only tokens are normalized to unset. Defaults are unchanged (stdio transport, 127.0.0.1 bind, no token), so existing deployments are unaffected; HTTP without a token logs a warning. README documents the option and recommends terminating TLS at a reverse proxy or gateway. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Contributor
Vulnerability Scan: PassedImage: No vulnerabilities found. Commit: ea97f49 |
ltucker
approved these changes
Jun 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds an optional
MCP_AUTH_TOKENfor the HTTP transport. When set, requests to the MCP endpoint must presentAuthorization: Bearer <token>, verified in constant time via aTokenVerifierplugged into FastMCP's auth layer. Defaults are unchanged (stdio transport,127.0.0.1bind, no token), so existing deployments are unaffected; running HTTP without a token logs a warning at startup.The README documents the option in the Docker examples and recommends terminating TLS at a reverse proxy or gateway when exposing the endpoint. Tests cover the 401/200 auth gate, empty/whitespace-token normalization, env and CLI wiring, and secret redaction.
🤖 Generated with Claude Code