-
Notifications
You must be signed in to change notification settings - Fork 1.2k
sse_client
fails if URL is not on the root path
#563
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
The setup is a bit strange here, but setting the mcp = FastMCP(
sse_path=f"/mcp/sse",
message_path=f"/mcp/messages/",
) python-sdk/src/mcp/server/fastmcp/server.py Lines 75 to 76 in babb477
|
As far as I understand, the main use case is to have multiple MCP servers managed within a single Starlette/FastAPI server. Here, setting app1 = FastMCP(
sse_path="/app1/sse",
message_path="/app1/message/",
)
app2 = FastMCP(
sse_path="/app2/sse",
message_path="/app2/message/",
)
# Only exposes app1
container_app = Starlette(
routes=[
Mount(path="/", app=app1.sse_app()),
Mount(path="/", app=app2.sse_app()),
]
) When connecting to app1, the proper path is returned in
IMO the right solution is not in the client but within FastMCP. I remember seeing a thread on the proper implementation somewhere, I'l link back when I find it. |
One more - looks like there is already a PR open for the proper fix: #540 |
Describe the bug
This line is the problem:
python-sdk/src/mcp/client/sse.py
Line 64 in babb477
urljoin
discards the whole path, meaning that ifurl
ishttp://localhost:8000/mcp/sse
andsse.data
is/messages/?session_id=123
we getendpoint_url == "http://localhost:8000/messages/?session_id=123"
instead ofhttp://localhost:8000/mcp/messages/?session_id=123
To Reproduce
sse_client
as per the tutorialExpected behavior
endpoint_url
should contain the suffix ofurl
with/sse
stripped instead of the whole path being stripped.The text was updated successfully, but these errors were encountered: