{{ message }}
Repository navigation
Conversation
mount_http() previously registered MCP HTTP endpoints with no auth dependencies when no AuthConfig was configured — any unauthenticated client could list and call MCP tools. Register a fail-closed dependency that rejects requests with 401 + WWW-Authenticate: Bearer when auth is not configured. Adopted from tadata-org#325 (original patch by @Daniyal0100101).
3 tasks done
Author
|
Thanks @Daniyal0100101! One small thing blocking this: the CI workflow run on my branch ended with \�ction_required\ (first-time/external contributor approval gate), so the required checks can't complete. Could you approve the run here — https://github.com/tadata-org/fastapi_mcp/actions/runs/33091255091 ? Once CI is green, this PR should be ready to merge (and it can supersede #325, whose author is happy to have it closed in favor of this one). |
This branch has not been deployed
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.

Adopted from #325 (original patch by @Daniyal0100101) — rebased onto current main and verified.
Why this is needed
Today, calling mount_http() on a FastApiMCP instance without an AuthConfig registers the MCP HTTP endpoints with zero auth dependencies. Any unauthenticated client can list and invoke every MCP tool the server exposes — there is no way to accidentally be secure here, it is open by default.
This PR makes the HTTP transport fail closed:
The real-transport test server fixture now passes an explicit permissive AuthConfig so the transport tests keep exercising the authenticated path.
Note: mount_sse() keeps its existing behavior in this PR, faithful to the original patch scope — happy to extend the same fail-closed guard to SSE as a follow-up if maintainers want it.
Verification
Credit to @Daniyal0100101 for the original report and patch in #325.