This commit is contained in:
Jupiter 2026-08-27 17:37:24 -05:00 • committed by GitHub
commit 82eeac3cb6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 26 additions and 2 deletions

View file

@ -5,6 +5,7 @@ LiteLLM MCP Server Routes
# pyright: reportInvalidTypeForm=false, reportArgumentType=false, reportOptionalCall=false
import asyncio
import base64
import contextlib
import contextvars
import hashlib
@ -487,7 +488,7 @@ if MCP_AVAILABLE:
elif isinstance(content, BlobResourceContents):
normalized.append(
ReadResourceContents(
content=content.blob,
content=base64.b64decode(content.blob),
mime_type=content.mimeType,
meta=meta,
)

View file

@ -1033,11 +1033,34 @@ def test_normalize_resource_contents_blob_with_metadata():
result = _normalize_resource_contents(contents)
assert len(result) == 1
assert result[0].content == "aGVsbG8="
assert result[0].content == b"hello"
assert result[0].mime_type == "image/png"
assert result[0].meta == meta
def test_normalize_resource_contents_decodes_blob_content_to_bytes():
try:
from litellm.proxy._experimental.mcp_server.server import (
_normalize_resource_contents,
)
except ImportError:
pytest.skip("MCP server not available")
contents = [
BlobResourceContents(
uri="https://example.com/archive.tar.gz",
blob="H4sIAAAAAAACAw==",
mimeType="application/gzip",
)
]
result = _normalize_resource_contents(contents)
assert len(result) == 1
assert result[0].content == b"\x1f\x8b\x08\x00\x00\x00\x00\x00\x02\x03"
assert result[0].mime_type == "application/gzip"
def test_normalize_resource_contents_preserves_empty_metadata():
"""Test that empty dict meta is preserved (truthiness bug fix)."""
try: