You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Python MCP SDK: Incorrect handling of absolute paths in SSE endpoint URLs leads to incorrect URL construction. #585
Describe the bug
When the MCP server, connected via SSE, returns an endpoint event with a data value that starts with / (e.g., /mcp/message?sessionId=...), the SDK appears to be using this absolute path directly without considering the base URL of the initial SSE connection. This results in the client attempting to access an incorrect URL.
Possible Root Cause:
Relevant Code Snippet (from langchain-mcp-adapters/client.py - for context):
urllib.parse.urljoin treats paths starting with / as absolute paths, causing it to discard the path component of the base URL (http://my.mcp-server.com/weather/sse) and only use the hostname.
Suggested Solution
When the server returns an endpoint URL starting with /, the SDK should treat it as a path to be appended to the path of the initial SSE connection URL, rather than a completely new absolute path relative to the server root. This might involve checking if sse_data starts with / and adjusting the base URL used in the URL joining process accordingly.
Activity
kavinkumar807 commentedon Apr 25, 2025
@footuser Debugging the issue will raise PR for it