Skip to content

Server url truncated by urllib in FastMCP #200

Closed

Description

@mconflitti-pbc

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.

Activity

  1. SOURABHMISHRA5221 commented on Jul 29, 2025

    @SOURABHMISHRA5221

    Hi @mconflitti-pbc, @Kludex!
    I've made the necessary changes to fix the issue. I'd appreciate it if you could review them.

  2. allenfeng8 commented on Oct 3, 2025

    @allenfeng8

    @mconflitti-pbc For the updates in the PR, do you think this issue should be closed now?

  3. mconflitti-pbc commented on Oct 3, 2025

    @mconflitti-pbc
    Author

    Yes. Given that SSE is deprecated, this is no longer urgent. If someone finds this is still affecting them for streamable http, they can reopen and address it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions