Skip to content

[Bug]: MCP SSE is failing with "Unexpected message" #1316

@betterthanever2

Description

@betterthanever2

crawl4ai version

0.7.0

Expected Behavior

When called upon, MCP SSE server responds properly

Current Behavior

MCP server is added to Claude Code and shows as "connected", however, trying to use it results in Error: All connection attempts failed

Snippet of the docker compose logs is below.

I'm trying to use the mcp for getting markdown of a webpage, no additional params.

Is this reproducible?

Yes

Inputs Causing the Bug

I was using "https://www.numberanalytics.com/blog/advanced-propaganda-detection", but pretty sure URL has nothing to do with this

Steps to Reproduce

Code snippets

OS

Linux/Docker

Python version

3.11

Browser

No response

Browser version

No response

Error logs & Screenshots (if applicable)

crawl4ai  | [2025-07-17 17:57:40 +0000] [13] [ERROR] Exception in ASGI application
crawl4ai  |   + Exception Group Traceback (most recent call last):
crawl4ai  |   |   File "/usr/local/lib/python3.12/site-packages/starlette/_utils.py", line 77, in collapse_excgroups
crawl4ai  |   |     yield
crawl4ai  |   |   File "/usr/local/lib/python3.12/site-packages/starlette/middleware/base.py", line 183, in __call__
crawl4ai  |   |     async with anyio.create_task_group() as task_group:
crawl4ai  |   |                ^^^^^^^^^^^^^^^^^^^^^^^^^
crawl4ai  |   |   File "/usr/local/lib/python3.12/site-packages/anyio/_backends/_asyncio.py", line 772, in __aexit__
crawl4ai  |   |     raise BaseExceptionGroup(
crawl4ai  |   | ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception)
crawl4ai  |   +-+---------------- 1 ----------------
crawl4ai  |     | Traceback (most recent call last):
crawl4ai  |     |   File "/usr/local/lib/python3.12/site-packages/uvicorn/protocols/http/h11_impl.py", line 403, in run_asgi
crawl4ai  |     |     result = await app(  # type: ignore[func-returns-value]
crawl4ai  |     |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
crawl4ai  |     |   File "/usr/local/lib/python3.12/site-packages/uvicorn/middleware/proxy_headers.py", line 60, in __call__
crawl4ai  |     |     return await self.app(scope, receive, send)
crawl4ai  |     |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
crawl4ai  |     |   File "/usr/local/lib/python3.12/site-packages/fastapi/applications.py", line 1054, in __call__
crawl4ai  |     |     await super().__call__(scope, receive, send)
crawl4ai  |     |   File "/usr/local/lib/python3.12/site-packages/starlette/applications.py", line 113, in __call__
crawl4ai  |     |     await self.middleware_stack(scope, receive, send)
crawl4ai  |     |   File "/usr/local/lib/python3.12/site-packages/starlette/middleware/errors.py", line 186, in __call__
crawl4ai  |     |     raise exc
crawl4ai  |     |   File "/usr/local/lib/python3.12/site-packages/starlette/middleware/errors.py", line 164, in __call__
crawl4ai  |     |     await self.app(scope, receive, _send)
crawl4ai  |     |   File "/usr/local/lib/python3.12/site-packages/starlette/middleware/base.py", line 182, in __call__
crawl4ai  |     |     with recv_stream, send_stream, collapse_excgroups():
crawl4ai  |     |                                    ^^^^^^^^^^^^^^^^^^^^
crawl4ai  |     |   File "/usr/local/lib/python3.12/contextlib.py", line 158, in __exit__
crawl4ai  |     |     self.gen.throw(value)
crawl4ai  |     |   File "/usr/local/lib/python3.12/site-packages/starlette/_utils.py", line 83, in collapse_excgroups
crawl4ai  |     |     raise exc
crawl4ai  |     |   File "/usr/local/lib/python3.12/site-packages/starlette/middleware/base.py", line 185, in __call__
crawl4ai  |     |     await response(scope, wrapped_receive, send)
crawl4ai  |     |   File "/usr/local/lib/python3.12/site-packages/starlette/middleware/base.py", line 223, in __call__
crawl4ai  |     |     async for chunk in self.body_iterator:
crawl4ai  |     |   File "/usr/local/lib/python3.12/site-packages/starlette/middleware/base.py", line 169, in body_stream
crawl4ai  |     |     assert message["type"] == "http.response.body", f"Unexpected message: {message}"
crawl4ai  |     |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
crawl4ai  |     | AssertionError: Unexpected message: {'type': 'http.response.start', 'status': 200, 'headers': [(b'content-length', b'4'), (b'content-type', b'application/json')]}
crawl4ai  |     +------------------------------------
crawl4ai  |
crawl4ai  | During handling of the above exception, another exception occurred:
crawl4ai  |
crawl4ai  | Traceback (most recent call last):
crawl4ai  |   File "/usr/local/lib/python3.12/site-packages/uvicorn/protocols/http/h11_impl.py", line 403, in run_asgi
crawl4ai  |     result = await app(  # type: ignore[func-returns-value]
crawl4ai  |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
crawl4ai  |   File "/usr/local/lib/python3.12/site-packages/uvicorn/middleware/proxy_headers.py", line 60, in __call__
crawl4ai  |     return await self.app(scope, receive, send)
crawl4ai  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
crawl4ai  |   File "/usr/local/lib/python3.12/site-packages/fastapi/applications.py", line 1054, in __call__
crawl4ai  |     await super().__call__(scope, receive, send)
crawl4ai  |   File "/usr/local/lib/python3.12/site-packages/starlette/applications.py", line 113, in __call__
crawl4ai  |     await self.middleware_stack(scope, receive, send)
crawl4ai  |   File "/usr/local/lib/python3.12/site-packages/starlette/middleware/errors.py", line 186, in __call__
crawl4ai  |     raise exc
crawl4ai  |   File "/usr/local/lib/python3.12/site-packages/starlette/middleware/errors.py", line 164, in __call__
crawl4ai  |     await self.app(scope, receive, _send)
crawl4ai  |   File "/usr/local/lib/python3.12/site-packages/starlette/middleware/base.py", line 182, in __call__
crawl4ai  |     with recv_stream, send_stream, collapse_excgroups():
crawl4ai  |                                    ^^^^^^^^^^^^^^^^^^^^
crawl4ai  |   File "/usr/local/lib/python3.12/contextlib.py", line 158, in __exit__
crawl4ai  |     self.gen.throw(value)
crawl4ai  |   File "/usr/local/lib/python3.12/site-packages/starlette/_utils.py", line 83, in collapse_excgroups
crawl4ai  |     raise exc
crawl4ai  |   File "/usr/local/lib/python3.12/site-packages/starlette/middleware/base.py", line 185, in __call__
crawl4ai  |     await response(scope, wrapped_receive, send)
crawl4ai  |   File "/usr/local/lib/python3.12/site-packages/starlette/middleware/base.py", line 223, in __call__
crawl4ai  |     async for chunk in self.body_iterator:
crawl4ai  |   File "/usr/local/lib/python3.12/site-packages/starlette/middleware/base.py", line 169, in body_stream
crawl4ai  |     assert message["type"] == "http.response.body", f"Unexpected message: {message}"
crawl4ai  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
crawl4ai  | AssertionError: Unexpected message: {'type': 'http.response.start', 'status': 200, 'headers': [(b'content-length', b'4'), (b'content-type', b'application/json')]}
crawl4ai  | 2025-07-17 17:57:43,378 - mcp.server.lowlevel.server - INFO - Processing request of type ListToolsRequest
crawl4ai  | 2025-07-17 17:57:43,389 - mcp.server.lowlevel.server - INFO - Processing request of type ListResourcesRequest
crawl4ai  | 2025-07-17 17:58:35,778 - mcp.server.lowlevel.server - INFO - Processing request of type CallToolRequest

Metadata

Metadata

Assignees

No one assigned

    Labels

    🐞 BugSomething isn't working🩺 Needs TriageNeeds attention of maintainers

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions