Skip to content

404 Not Found Error when Establishing SSE Connection via MCP Python SDK #507

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

Open
chi2liu opened this issue Apr 14, 2025 · 3 comments
Open

Comments

@chi2liu
Copy link

chi2liu commented Apr 14, 2025

Describe the bug
A clear and concise description of what the bug is.

Description​​
When attempting to establish SSE connection with MCP Python SDK (v1.6.0), encountering persistent 404 errors on critical endpoints:

mcp = FastMCP("Demo", debug=True, log_level="DEBUG", message_path="/abcd/abcd/messages/")

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

[04/14/25 09:45:51] DEBUG Setting up SSE connection sse.py:87

                DEBUG    session_uri:                             sse.py:106

                          /abcd/abcd/messages/?session_id
                         =b5b93f9d4088442fa3edb1c679a7a922

                DEBUG    Created new session with ID:             sse.py:109
                         b5b93f9d-4088-442f-a3ed-b1c679a7a922

                DEBUG    Starting SSE response task               sse.py:136

                DEBUG    Yielding read and write streams          sse.py:139

INFO: 100.67.30.95:57894 - "GET /sse HTTP/1.1" 200 OK

                DEBUG    Starting SSE writer                      sse.py:116

                DEBUG    Sent endpoint event:                     sse.py:119
                          /abcd/abcd/messages/?session_id
                         =b5b93f9d4088442fa3edb1c679a7a922

                DEBUG    chunk: b'event: endpoint\r\ndata:        sse.py:156
                         /abcd/abcd/messages/?session_id
                         =b5b93f9d4088442fa3edb1c679a7a922\r\n\r\
                         n'

INFO: 10.183.49.44:60168 - "GET /prometheus HTTP/1.1" 404 Not Found

INFO: 100.67.31.17:49088 - "POST /messages/?session_id=b5b93f9d4088442fa3edb1c679a7a922 HTTP/1.1" 404 Not
Found

                DEBUG    Got event: http.disconnect. Stop         sse.py:177

                         streaming.

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

@rkondra-eightfold
Copy link

rkondra-eightfold commented Apr 16, 2025

can you please share

  • How are you running the server?
  • client code

The url here is incorrect ...

INFO: 100.67.31.17:49088 - "POST /messages/?session_id=b5b93f9d4088442fa3edb1c679a7a922 HTTP/1.1" 404 Not
Found

might be related: #524

@MarshallEriksen-shaomingyang
Copy link

MarshallEriksen-shaomingyang commented Apr 21, 2025

I have same wrong, I use fastapi mount mcpserver

fastmcp = FastMCP(
                self.server_config.get("name", "MCP Server"), message_path="/mcp/messages/"
            )
FastApi.mount(path="/mcp", app=self.main_server.sse_app())``` 
But client request shows Client error '404 Not Found' for url 'http://localhost:ip/mcp/messages/?session_id=115273056f3b4d11b2ed15010211ecda' 

@mpereira
Copy link

mpereira commented May 6, 2025

I'm also running into this.

fast-agent-mcp==0.2.21
fastapi-mcp==0.3.3
mcp[cli]==1.7.1

For folks using fastapi-mcp, the cause might be that you're using uvicorn workers: tadata-org/fastapi_mcp#56

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

4 participants