mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-07 02:59:05 +00:00
Merge f256b5b9b1 into 3c41392893
This commit is contained in:
commit
82eeac3cb6
2 changed files with 26 additions and 2 deletions
|
|
@ -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,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue