Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
0fd5b94
added support for metadata
Mar 21, 2026
b223dc9
fix: PR review - meta truthiness, BlobResourceContents mimeType, add …
Mar 21, 2026
19af722
pyproject to .25
Mar 22, 2026
f626587
feat(teams): resolve access group models/MCPs/agents in team endpoints
ryan-crabbe-berri Apr 2, 2026
bbe708b
perf(teams): single-pass access group resolution + asyncio.gather in …
ryan-crabbe-berri Apr 2, 2026
59b0910
docs: add default_team_params to config reference and update examples
ryan-crabbe-berri Apr 2, 2026
c19a63e
docs: clarify that models sub-field only applies to SSO auto-created …
ryan-crabbe-berri Apr 2, 2026
f0bd334
fix: lazy import get_access_object to break cyclic import + short-cir…
ryan-crabbe-berri Apr 2, 2026
5a8f910
add: making organizations a select instead of read only badges
ryan-crabbe-berri Apr 3, 2026
1bb726a
fix(ui): only send organization_id when changed and use raw initial v…
ryan-crabbe-berri Apr 3, 2026
cd7b262
fix(ui): add paginated team search to usage page filter
ryan-crabbe-berri Apr 3, 2026
1533f68
fix(ui): fix imports and update placeholder for team multi select
ryan-crabbe-berri Apr 3, 2026
96b660b
fix(ui): wire team_id filter to key alias dropdown on Virtual Keys tab
ryan-crabbe-berri Apr 3, 2026
1521004
Merge pull request #25114 from BerriAI/litellm_fix-virtual-keys-team-…
ryan-crabbe-berri Apr 3, 2026
0575c3f
Merge pull request #25107 from BerriAI/litellm_fix-team-id-search-filter
ryan-crabbe-berri Apr 3, 2026
20077fe
Merge pull request #25095 from BerriAI/litellm_fix-ui-update-org-teams
ryan-crabbe-berri Apr 3, 2026
eb780a8
Merge pull request #25032 from BerriAI/litellm_docs-default-team-params
ryan-crabbe-berri Apr 3, 2026
38f6c94
fix(tests): correct mock targets in TestResolveAccessGroupResources
ryan-crabbe-berri Apr 3, 2026
ea32cb5
fix: use direct attribute access with or [] fallback in _resolve_acce…
ryan-crabbe-berri Apr 3, 2026
3bdd042
fix(ui): remove model source legend from team detail view
ryan-crabbe-berri Apr 3, 2026
bb03a11
fix(ui): add missing access_group fields to TeamData.team_info type
ryan-crabbe-berri Apr 3, 2026
93369bf
perf(teams): batch-fetch access groups in single DB query
ryan-crabbe-berri Apr 4, 2026
0331fb5
Merge pull request #25027 from BerriAI/litellm_add-access-group-to-model
ryan-crabbe-berri Apr 4, 2026
ce219fc
refactor(proxy): extract helpers to fix PLR0915 violations
ryan-crabbe-berri Apr 4, 2026
866c4a2
test(ui): update tests to match new team_id / access-group signatures
ryan-crabbe-berri Apr 4, 2026
c495acd
fix(ui): send null (not '') for cleared organization_id on team update
ryan-crabbe-berri Apr 4, 2026
ad203dc
poetry
ryan-crabbe-berri Apr 4, 2026
ad81892
Merge remote-tracking branch 'origin/main' into litellm_ryan-march-31
ryan-crabbe-berri Apr 4, 2026
76c0591
chore: regen poetry.lock for litellm-proxy-extras 0.4.64 bump
ryan-crabbe-berri Apr 4, 2026
fa9e3d8
Merge pull request #25119 from BerriAI/litellm_ryan-march-31
yuneng-berri Apr 4, 2026
1e414b5
chore: update Next.js build artifacts (2026-04-04 17:55 UTC, node v22…
yuneng-berri Apr 4, 2026
c898edb
Merge pull request #25136 from BerriAI/ui_build_apr4
yuneng-berri Apr 4, 2026
12fa28f
Merge branch 'main' into litellm_metadata_for_mcp
shivamrawat1 Apr 4, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ commands:
# conflicts with transitive dep pins like openai<2 and pydantic>=2.11.5)
pip install "pytest-mock==3.12.0" "pytest==7.3.1" "pytest-retry==1.6.3" \
"pytest-asyncio==0.21.1" "respx==0.22.0" "hypercorn==0.17.3" \
"pydantic==2.11.0" "mcp==1.25.0" "requests-mock>=1.12.1" \
"pydantic==2.11.0" "mcp==1.26.0" "requests-mock>=1.12.1" \
"responses==0.25.7" "pytest-xdist==3.6.1" "pytest-timeout==2.2.0" \
"pytest-cov==5.0.0" "semantic_router==0.1.10" "fastapi-offline==1.7.3" \
"a2a" "parameterized>=0.9.0"
Expand Down Expand Up @@ -1184,7 +1184,7 @@ jobs:
pip install "pytest-asyncio==0.21.1"
pip install "respx==0.22.0"
pip install "pydantic==2.11.0"
pip install "mcp==1.25.0"
pip install "mcp==1.26.0"
pip install "pytest-xdist==3.6.1"
# Run pytest and generate JUnit XML report
- run:
Expand Down Expand Up @@ -1627,7 +1627,7 @@ jobs:
pip install "respx==0.22.0"
pip install "hypercorn==0.17.3"
pip install "pydantic==2.11.0"
pip install "mcp==1.25.0"
pip install "mcp==1.26.0"
pip install "requests-mock>=1.12.1"
pip install "responses==0.25.7"
pip install "pytest-xdist==3.6.1"
Expand Down Expand Up @@ -1967,7 +1967,7 @@ jobs:
pip install "pytest-asyncio==0.21.1"
pip install "pytest-cov==5.0.0"
pip install "tomli==2.2.1"
pip install "mcp==1.25.0"
pip install "mcp==1.26.0"
- run:
name: Run tests
command: |
Expand Down
2 changes: 1 addition & 1 deletion .circleci/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ google-cloud-aiplatform==1.43.0
google-cloud-iam==2.19.1
fastapi-sso==0.16.0
uvloop==0.21.0
mcp==1.25.0 # for MCP server
mcp==1.26.0 # for MCP server
semantic_router==0.1.10 # for auto-routing with litellm
fastuuid==0.12.0
responses==0.25.7 # for proxy client tests
Expand Down
49 changes: 29 additions & 20 deletions litellm/proxy/_experimental/mcp_server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,34 @@ class ListMCPToolsRestAPIResponseObject(MCPTool):
mcp_info: Optional[MCPInfo] = None
model_config = ConfigDict(arbitrary_types_allowed=True)

def _normalize_resource_contents(contents: list) -> List[ReadResourceContents]:
Comment thread
shivamrawat1 marked this conversation as resolved.
Resolved
"""Normalize ResourceContents to ReadResourceContents, preserving meta (MCP 1.26.0+)."""
normalized: List[ReadResourceContents] = []
for content in contents:
meta = getattr(content, "meta", None)
if meta is None and hasattr(content, "model_dump"):
d = content.model_dump()
meta = d.get("meta")
if meta is None:
meta = d.get("_meta")
if isinstance(content, TextResourceContents):
normalized.append(
ReadResourceContents(
content=content.text,
mime_type=content.mimeType,
meta=meta,
)
)
elif isinstance(content, BlobResourceContents):
normalized.append(
ReadResourceContents(
content=content.blob,
mime_type=content.mimeType,
meta=meta,
)
)
Comment thread
shivamrawat1 marked this conversation as resolved.
Resolved
return normalized
Comment thread
shivamrawat1 marked this conversation as resolved.
Resolved
Comment thread
shivamrawat1 marked this conversation as resolved.
Resolved

########################################################
############ Initialize the MCP Server #################
########################################################
Expand Down Expand Up @@ -630,26 +658,7 @@ async def read_resource(url: AnyUrl) -> list[ReadResourceContents]:
raw_headers=raw_headers,
)

normalized_contents: List[ReadResourceContents] = []
for content in read_resource_result.contents:
if isinstance(content, TextResourceContents):
text_content: TextResourceContents = content
normalized_contents.append(
ReadResourceContents(
content=text_content.text,
mime_type=text_content.mimeType,
)
)
elif isinstance(content, BlobResourceContents):
blob_content: BlobResourceContents = content
normalized_contents.append(
ReadResourceContents(
content=blob_content.blob,
mime_type=None,
)
)

return normalized_contents
return _normalize_resource_contents(read_resource_result.contents)

########################################################
############ End of MCP Server Routes ##################
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ pynacl = {version = "^1.5.0", optional = true}
websockets = {version = "^15.0.1", optional = true}
boto3 = { version = "^1.40.76", optional = true }
redisvl = {version = "^0.4.1", optional = true, markers = "python_version >= '3.9' and python_version < '3.14'"}
mcp = {version = ">=1.25.0,<2.0.0", optional = true, python = ">=3.10"}
mcp = {version = ">=1.26.0,<2.0.0", optional = true, python = ">=3.10"}
Comment thread
shivamrawat1 marked this conversation as resolved.
Resolved
a2a-sdk = {version = "^0.3.22", optional = true, python = ">=3.10"}
litellm-proxy-extras = {version = "^0.4.58", optional = true}
rich = {version = "^13.7.1", optional = true}
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ google-cloud-aiplatform==1.133.0 # for vertex ai calls
google-cloud-iam==2.19.1 # for GCP IAM Redis authentication
google-genai==1.37.0
anthropic[vertex]==0.54.0
mcp==1.25.0 ; python_version >= "3.10" # for MCP server
mcp==1.26.0 ; python_version >= "3.10" # for MCP server
# google-generativeai removed - deprecated, replaced by google-genai (line 21)
async_generator==1.10.0 # for async ollama calls
langfuse==2.59.7 # for langfuse self-hosted logging
Expand Down
111 changes: 106 additions & 5 deletions tests/test_litellm/proxy/_experimental/mcp_server/test_mcp_server.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import asyncio
from datetime import datetime, timedelta
from typing import Optional
from unittest.mock import AsyncMock, MagicMock, patch

import pytest
from fastapi import HTTPException
from mcp import ReadResourceResult, Resource
from mcp.types import Prompt, ResourceTemplate, TextResourceContents
from mcp.types import BlobResourceContents, Prompt, ResourceTemplate, TextResourceContents

from litellm.proxy._types import (
LiteLLM_MCPServerTable,
Expand Down Expand Up @@ -413,6 +412,111 @@ async def test_mcp_read_resource_success():
assert result is read_result


def test_normalize_resource_contents_passes_metadata():
"""Test that _normalize_resource_contents preserves meta from ResourceContents (MCP 1.26.0+)."""
try:
from litellm.proxy._experimental.mcp_server.server import (
_normalize_resource_contents,
)
except ImportError:
pytest.skip("MCP server not available")

meta = {"version": "1.0", "source": "test"}
contents = [
TextResourceContents(
uri="https://example.com/resource",
text="hello world",
mimeType="text/plain",
meta=meta,
)
]

result = _normalize_resource_contents(contents)

assert len(result) == 1
assert result[0].content == "hello world"
assert result[0].mime_type == "text/plain"
assert result[0].meta == meta


def test_normalize_resource_contents_blob_with_metadata():
"""Test that _normalize_resource_contents preserves meta for BlobResourceContents."""
try:
from litellm.proxy._experimental.mcp_server.server import (
_normalize_resource_contents,
)
except ImportError:
pytest.skip("MCP server not available")

meta = {"encoding": "base64"}
contents = [
BlobResourceContents(
uri="https://example.com/image.png",
blob="aGVsbG8=",
mimeType="image/png",
meta=meta,
)
]

result = _normalize_resource_contents(contents)

assert len(result) == 1
assert result[0].content == "aGVsbG8="
assert result[0].mime_type == "image/png"
assert result[0].meta == meta


def test_normalize_resource_contents_preserves_empty_metadata():
"""Test that empty dict meta is preserved (truthiness bug fix)."""
try:
from litellm.proxy._experimental.mcp_server.server import (
_normalize_resource_contents,
)
except ImportError:
pytest.skip("MCP server not available")

empty_meta: dict = {}
contents = [
TextResourceContents(
uri="https://example.com/resource",
text="hi",
mimeType="text/plain",
meta=empty_meta,
)
]

result = _normalize_resource_contents(contents)

assert len(result) == 1
assert result[0].meta == empty_meta
assert result[0].meta is not None
assert result[0].meta == {}


def test_normalize_resource_contents_without_metadata():
"""Test that _normalize_resource_contents works when meta is absent (backward compat)."""
try:
from litellm.proxy._experimental.mcp_server.server import (
_normalize_resource_contents,
)
except ImportError:
pytest.skip("MCP server not available")

contents = [
TextResourceContents(
uri="https://example.com/resource",
text="hello",
mimeType="text/plain",
)
]

result = _normalize_resource_contents(contents)

assert len(result) == 1
assert result[0].content == "hello"
assert result[0].meta is None
Comment thread
shivamrawat1 marked this conversation as resolved.
Resolved


@pytest.mark.asyncio
async def test_mcp_read_resource_multiple_servers_error():
try:
Expand Down Expand Up @@ -707,8 +811,6 @@ async def test_concurrent_initialize_session_managers():
"""Test that concurrent calls to initialize_session_managers don't cause race conditions."""
try:
from litellm.proxy._experimental.mcp_server.server import (
_INITIALIZATION_LOCK,
_SESSION_MANAGERS_INITIALIZED,
initialize_session_managers,
)
except ImportError:
Expand Down Expand Up @@ -1426,7 +1528,6 @@ async def test_list_tools_with_team_tool_permissions_inheritance():
)
from litellm.proxy._types import (
LiteLLM_ObjectPermissionTable,
LiteLLM_TeamTable,
UserAPIKeyAuth,
)
except ImportError:
Expand Down
Loading