🤖 feat: redirect / to /mcp or /sse by Accept header & load settings from TOML#4
Merged
Falamarcao merged 3 commits intomainfrom Aug 9, 2025
Merged
🤖 feat: redirect / to /mcp or /sse by Accept header & load settings from TOML#4Falamarcao merged 3 commits intomainfrom
/ to /mcp or /sse by Accept header & load settings from TOML#4Falamarcao merged 3 commits intomainfrom
Conversation
…g and highlighting
…rom TOML - Added root route redirecting to MCP or SSE endpoints based on Accept header (fixed MCP Clients usage). - Centralized pyproject.toml value loading for VERSION, and description. ✅ Local Tests: all 116 tests passed successfully.
/ to /mcp or /sse by Accept header & load settings from TOML
FastApiMCP doesn't allow mounting at root `/`. MCP clients need to connect at root when using uvx, so we proxy requests dynamically to SSE and HTTP endpoints, handling methods and headers properly.
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.
Yes, this PR message was written by AI.
No, I’m not sorry.
Yes, the code is real.
And yes, all 116 tests pass — even the ones that hate me personally.
What’s actually changed?
✅ Smart root redirect
Hit
/? We check yourAcceptheader and redirect to/mcpor/sse— because nobody likes guessing the right endpoint like it’s a treasure hunt with no map.📦 Config from
pyproject.tomlVersion and description now loaded directly from
pyproject.toml. One source of truth. Zero magic strings. Maximum adulting.🎨 Logging with
RichBecause plain
print()is what happens when you give Python to someone with a deadline and low blood sugar.✨ Improved MCP proxy for root access
FastApiMCPworks best mounted under a subpath — which is great!But
uvx-based MCP clients expect to connect at/.So we added a proxy at root that forwards requests (with full headers and methods) to the right backend — no client changes needed.
Think of it as a multilingual tour guide for your HTTP requests.
✅ All 116 tests passed
Locally. On my machine. With Wi-Fi that doesn’t hate me (for once).