Description
Describe the bug
URL parts are being omitted on SSE client session connect.
INFO:mcp.client.sse:Connecting to SSE endpoint: https://url-part1.url-part2.com/route1/route2/sse
INFO:httpx:HTTP Request: GET https://url-part1.url-part2.com/route1/route2/sse "HTTP/1.1 200 OK"
INFO:mcp.client.sse:Received endpoint URL: https://url-part1.url-part2.com/route2/messages/?session_id=a2bd62740b69466c8b27043ccda2513f
INFO:mcp.client.sse:Starting post writer with endpoint URL: https://url-part1.url-part2.com/route2/messages/?session_id=a2bd62740b69466c8b27043ccda2513f
To Reproduce
import asyncio
import logging
from fastmcp import Client
from fastmcp.client.transports import (
SSETransport
)
sse_url = "https://url-part1.url-part2.com/route1/route2/sse"
async def main():
# Connect to a server over SSE (common for web-based MCP servers)
async with Client(SSETransport(url=sse_url)) as client:
# Send a message to the server
result = await client.list_tools()
print(result)
if __name__ == "__main__":
logging.basicConfig(level=logging.INFO)
asyncio.run(main())
Expected behavior
route1 is not omitted
Desktop (please complete the following information):
- OS: Ubuntu
- Version 1.9.0
Additional context
issue stems from:
.venv/lib/python3.12/site-packages/mcp/client/sse.py line 66