Skip to content
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

Server url truncated by urllib in FastMCP #200

Open
mconflitti-pbc opened this issue Feb 10, 2025 · 0 comments
Open

Server url truncated by urllib in FastMCP #200

mconflitti-pbc opened this issue Feb 10, 2025 · 0 comments

Comments

@mconflitti-pbc
Copy link

Describe the bug
When using urllib url joining, this truncates server urls paths when combining /messages/ set in the transport object.

sse = SseServerTransport("/messages/")

For example, if joining http://localhost:8000/some/path/to/sse with /messages/, it will output: http://localhost:8000/messages/ instead of honoring the path.

Removing the leading slash fixes this.

This was found in the situation where my server was being proxied and accessed at a subpath. afaict, there is no explicit reason to keep the leading slash. This is also something that could be addressed in #194 since a dev could then customize the server setup more easily.

To Reproduce

from urllib.parse import urljoin

url = "http://localhost:8000/some/path/to/sse"
sse_data = "/messages/?session_id=123"

endpoint_url = urljoin(url, sse_data)
assert endpoint_url == "http://localhost:8000/messages/?session_id=123"

####

url = "http://localhost:8000/some/path/to/sse"
sse_data = "messages/?session_id=123"

endpoint_url = urljoin(url, sse_data)
assert endpoint_url == "http://localhost:8000/some/path/to/messages/?session_id=123"

Expected behavior
A clear and concise description of what you expected to happen.
I would expect this to join the route to the end of the url instead of truncating it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant