fastmcp icon indicating copy to clipboard operation
fastmcp copied to clipboard

url parts are getting missed on sse transport connection

Open kocsszi opened this issue 10 months ago • 0 comments

Description

INFO:mcp.client.sse:Connecting to SSE endpoint: https://dp-nonprod.msciapps.com/agents-and-tools/echo/sse INFO:httpx:HTTP Request: GET https://dp-nonprod.msciapps.com/agents-and-tools/echo/sse "HTTP/1.1 200 OK" INFO:mcp.client.sse:Received endpoint URL: https://dp-nonprod.msciapps.com/echo/messages/?session_id=869011a64fb949a89d32af5319ccd7ee INFO:mcp.client.sse:Starting post writer with endpoint URL: https://dp-nonprod.msciapps.com/echo/messages/?session_id=869011a64fb949a89d32af5319ccd7ee INFO:httpx:HTTP Request: POST https://dp-nonprod.msciapps.com/echo/messages/?session_id=869011a64fb949a89d32af5319ccd7ee "HTTP/1.1 404 Not Found" ERROR:mcp.client.sse:Error in post_writer: Client error '404 Not Found' for url 'https://dp-nonprod.msciapps.com/echo/messages/?session_id=869011a64fb949a89d32af5319ccd7ee' For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/404

The base url is not retrieved faithfully when doing the post part, a url part is missing and we get a path not exists error.

Example Code

import asyncio
import logging
from fastmcp import Client
from fastmcp.client.transports import (
    SSETransport, 
    PythonStdioTransport, 
    FastMCPTransport
)

async def main():
    # Connect to a server over SSE (common for web-based MCP servers)
    async with Client(SSETransport(url="https://dp-nonprod.msciapps.com/agents-and-tools/echo/sse")) as client:
        # Send a message to the server
        await client.send_message("Hello, server!")

        # Receive a message from the server
        message = await client.receive_message()
        print(message)

if __name__ == "__main__":
    logging.basicConfig(level=logging.INFO)
    asyncio.run(main())

Version Information

2.3.0

Additional Context

No response

kocsszi avatar May 09 '25 10:05 kocsszi