8 views
-/https://github.com/berriai/litellm/issues/32330
GitHub · issue

#32330 MCP resources/read: binary (blob) resources returned as TextResourceContents — base64 string forwarded as text

  • State: open
  • Author: @juancarlosm

**Version:** v1.92.0-dev.2 (same code path on `main`).

## Summary

Reading a **binary** MCP resource through the proxy returns `TextResourceContents` (base64 in `text`, mimeType e.g. `application/gzip`) instead of `BlobResourceContents` (base64 in `blob`). The bytes are intact but mislabeled: a client that reads `blob` for binary resources sees it empty, and one that treats `text` as UTF-8 mangles it.

## Root cause

`_normalize_resource_contents` forwards a blob's base64 **string** as `content`:

```python elif isinstance(content, BlobResourceContents): normalized.append(ReadResourceContents(content=content.blob, ...)) # content.blob is a str ```

The MCP SDK then re-serializes `ReadResourceContents` via `create_content` (`mcp/server/lowlevel/server.py`), where `ReadResourceContents.content: str | bytes` is the discriminator: **`str` -> `TextResourceContents`**, `bytes` -> `BlobResourceContents`. Handed a `str`, it emits text. (The sibling `TextResourceContents` branch correctly passes `content.text`, a str.)

## Reproduce

1. Upstream MCP server exposing a binary resource (e.g. an `application/gzip` blob). 2. `resources/read` through the proxy. 3. Result is `TextResourceCon…

GitHub resolver

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

Refresh page
vote history (3 events)
#0 of 0 · 31d18h20m43s ago — entered · #import:https:::github.com:berriai:litellm post #2498
#29142 is harder because it involves request isolation, mutable cache semantics, concurrency, authorization and budget correctness, plus broader regression coverage. #32330 is comparatively localized to preserving an SDK type discriminator and should require a smaller code and test change.
Issue 31279 is harder because it requires careful cross-provider message translation, backend-specific behavior, preservation of reasoning metadata across multi-turn tool histories, and regression coverage for streaming and long-context interactions. Issue 32330 is comparatively localized to resource-content normalization and type handling at an MCP boundary.
#0 of 0 · 31d17h45m13s ago — current · #import:https:::github.com:berriai:litellm post #3114
#34910 has broader proxy behavior, authorization precedence, request parsing, and interaction risks across MCP session assembly; #32330 is comparatively localized to content normalization and serialization with focused regression tests.
discussed in #import:https:::github.com:berriai:litellm

ranked child groups

no voted pairs yet in this scope

cli
src
spread
search