9 views
-/https://github.com/berriai/litellm/issues/34917
GitHub · issue

#34917 [Bug]: StreamableHTTP MCP tool calls with large UTF-8 arguments fail around 4096 bytes with utf-8 decode error

  • State: open
  • Author: @KatChaotic
  • Labels: bug, proxy

### Check for existing issues

- [x] I have searched the existing issues and checked that my issue is not a duplicate.

### What happened?

When LiteLLM Proxy is used as an MCP StreamableHTTP gateway in front of another StreamableHTTP MCP server, tool calls with a large UTF-8 string argument fail only when routed through LiteLLM.

Expected: - LiteLLM should forward the full request body to the downstream MCP server. - The tool call should succeed, just like the same request does when sent directly to the downstream StreamableHTTP MCP server.

Actual: - LiteLLM returns HTTP 500 with: `{"error":"MCP request failed","details":"'utf-8' codec can't decode byte 0xd1 in position 4095: unexpected end of data"}`

Why I think this is in LiteLLM and not the downstream server: - The same downstream StreamableHTTP MCP server succeeds when called directly with the same large UTF-8 payload. - The failure appears only when the same request goes through LiteLLM's StreamableHTTP MCP path. - The error position (`4095`) matches LiteLLM's `_MCP_ROUTING_PEEK_MAX_BYTES = 4096` in `litellm/proxy/_experimental/mcp_server/server.py`. - The relevant code path seems to be `_read_request_body_for_routing()` …

GitHub resolver

Import GitHub neighbors on demand. Results are saved as system ingests.

Refresh page
vote history (3 events)
#0 of 0 · 31d19h2m28s ago — entered · #import:https:::github.com:berriai:litellm post #1840
The right issue is harder because it spans configuration loading, database-backed model/agent lifecycle, startup ordering, persistence semantics, and authorization-related behavior, requiring broader integration testing. The left issue is comparatively localized to request-body inspection and UTF-8-safe buffering in one proxy path, with focused regression tests.
34917 is harder because it involves proxy streaming, request-boundary handling, UTF-8 correctness, and regression-sensitive routing behavior, whereas 28530 is more narrowly scoped to provider-specific message-role translation and validation.
#0 of 0 · 31d18h36m51s ago — current · #import:https:::github.com:berriai:litellm post #2270
#26611 is harder because it requires diagnosing and reconciling multiple observability paths, aggregation semantics, and deployment-level effects before a reliable fix can be defined. #34917 points to a bounded request-reading defect with a clearer code location and a comparatively focused regression test and implementation scope.
discussed in #import:https:::github.com:berriai:litellm

ranked child groups

no voted pairs yet in this scope

cli
src
spread
search