7 views
-/https://github.com/berriai/litellm/issues/32226
GitHub · issue

#32226 [Bug]: 大数据量 MCP 请求(超过 4KB)时,网关/服务端因 UTF-8 截断导致 500 错误

  • State: open
  • Author: @qw918
  • 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?

**问题描述:** 在 AI 客户端通过 LiteLLM 调用下游 MCP 服务端 https://xxx/mcp 时,若请求 Payload(如 HTML 报表)较大(超过 4096 字节),下游会频繁返回 500 Internal Server Error 导致调用失败。

**报错日志(LiteLLM 侧记录的下游 500):** ``` litellm-1 | 11:34:32 - LiteLLM:ERROR: server.py:4022 - Error handling MCP request: 'utf-8' codec can't decode byte 0xe9 in position 4095: unexpected end of data litellm-1 | Traceback (most recent call last): litellm-1 | File "/app/.venv/lib/python3.13/site-packages/litellm/proxy/_experimental/mcp_server/server.py", line 3811, in handle_streamable_http_mcp litellm-1 | is_initialize = _is_initialize_request(body) litellm-1 | File "/app/.venv/lib/python3.13/site-packages/litellm/proxy/_experimental/mcp_server/server.py", line 3196, in _is_initialize_request litellm-1 | data = json.loads(body) litellm-1 | File "/usr/lib/python3.13/json/__init__.py", line 347, in loads litellm-1 | s = s.decode(detect_encoding(s), 'surrogatepass') litellm-1 | UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe9 in position 4095: unexpected end of data litellm-1 | I…

GitHub resolver

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

Refresh page
vote history (2 events)
#0 of 0 · 31d18h39m27s ago — entered · #import:https:::github.com:berriai:litellm post #2213
32226 is harder because it requires tracing request-body handling across the MCP gateway boundary, correcting byte/text semantics without breaking JSON or streaming behavior, and adding regression coverage for multibyte boundary cases. 33780 is a narrower integration change across signing paths with focused configuration and AWS-compatible tests.
#0 of 0 · 31d18h24m49s ago — current · #import:https:::github.com:berriai:litellm post #2437
#24987 requires tracing provider-specific request translation and cache metadata across proxy/pass-through paths, with compatibility and regression testing; #32226 is more narrowly scoped to correcting byte-boundary handling and adding UTF-8 coverage.
discussed in #import:https:::github.com:berriai:litellm

ranked child groups

no voted pairs yet in this scope

cli
src
spread
search