[Bug]: mcp_bridge: httpx default 5s timeout causes isError on slow LLM-backed endpoints
crawl4ai version
0.8.0
Expected Behavior
The MCP tool call should return the processed markdown content successfully, regardless of how long the LLM-backed endpoint takes to respond. The MCP bridge should wait for the server to finish and relay the result back to the client.
Current Behavior
When an LLM-backed endpoint (e.g. GET /md?filter=llm) takes longer than 5 seconds to respond, the MCP bridge raises an httpx.TimeoutException due to the default 5-second timeout on httpx.AsyncClient(). This exception is not caught by the existing except httpx.HTTPStatusError handler and propagates to the MCP framework, which returns isError: true with an empty text body — even though the crawl4ai server completed the request successfully.
The failure is intermittent: it only occurs when the LLM response time exceeds ~5 seconds, making it appear as a random/flaky error.
Is this reproducible?
Yes
Inputs Causing the Bug
- MCP tool: md
- Parameter filter=llm (any LLM-backed content filter)
- Any URL where the LLM processing time exceeds ~5 seconds (depends on model speed, page length, and server load)
- Example: a moderately long web page crawled with LLMContentFilter using a slower or remote LLM model
The bug is not tied to a specific URL — it reproduces on any page where the LLM takes longer than the hardcoded 5-second httpx default timeout.
Steps to Reproduce
1. Start the crawl4ai Docker server with an LLM provider configured (e.g. OpenAI, Anthropic).
2. Connect an MCP client (e.g. Claude Desktop) to the crawl4ai MCP bridge.
3. Call the md MCP tool with filter=llm on any moderately long web page:
url: https://example.com/some-long-article
filter: llm
4. Observe that the MCP tool returns isError: true with empty content.
5. Check the crawl4ai server logs — the request completed successfully (e.g. fit_md_len=2076), confirming the server finished but the bridge
timed out before receiving the response.
Note: The issue is intermittent. It reproduces reliably when the LLM response takes longer than ~5 seconds. Using a slower model or a longer page
increases the chance of triggering it.
Code snippets
# BEFORE (buggy)
# httpx.AsyncClient() uses a default 5-second timeout.
# When the LLM takes longer, httpx raises TimeoutException.
# This is NOT a subclass of HTTPStatusError, so it is never caught —
# it propagates to the MCP framework as isError: true with empty text.
async with httpx.AsyncClient() as client:
try:
r = await client.get(url, params=kwargs)
...
except httpx.HTTPStatusError:
# TimeoutException does NOT match here — it bypasses this handler
...
# AFTER (fixed)
# timeout=None disables the client-side timeout entirely.
# The crawl4ai server manages its own internal timeouts.
async with httpx.AsyncClient(timeout=None) as client:
try:
r = await client.get(url, params=kwargs)
...
except httpx.HTTPStatusError:
...
OS
Linux
Python version
3.13
Browser
No response
Browser version
No response
Error logs & Screenshots (if applicable)
No response
fixed. it's on the develop branch
thx