From 20c3a0ffe4d34c39e6e02897c7ec17f3340b539f Mon Sep 17 00:00:00 2001 From: Lucky Lodhi Date: Sun, 18 Jan 2026 18:27:27 +0000 Subject: [PATCH 01/20] fixed litellm params --- litellm/main.py | 54 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 51 insertions(+), 3 deletions(-) diff --git a/litellm/main.py b/litellm/main.py index 969cf55a3d6..fb7b0bf8b4a 100644 --- a/litellm/main.py +++ b/litellm/main.py @@ -565,6 +565,10 @@ async def acompletion( model=model, custom_llm_provider=custom_llm_provider, api_base=completion_kwargs.get("base_url", None), + litellm_params=litellm.types.router.LiteLLM_Params( + model=model, + use_litellm_proxy=kwargs.get("use_litellm_proxy", False), + ), ) fallbacks = fallbacks or litellm.model_fallbacks @@ -1291,6 +1295,10 @@ def completion( # type: ignore # noqa: PLR0915 custom_llm_provider=custom_llm_provider, api_base=api_base, api_key=api_key, + litellm_params=litellm.types.router.LiteLLM_Params( + model=model, + use_litellm_proxy=kwargs.get("use_litellm_proxy", False), + ), ) if not _should_allow_input_examples( @@ -4368,6 +4376,10 @@ async def aembedding(*args, **kwargs) -> EmbeddingResponse: model=model, custom_llm_provider=custom_llm_provider, api_base=kwargs.get("api_base", None), + litellm_params=litellm.types.router.LiteLLM_Params( + model=model, + use_litellm_proxy=kwargs.get("use_litellm_proxy", False), + ), ) # Await normally @@ -4553,6 +4565,10 @@ def embedding( # noqa: PLR0915 custom_llm_provider=custom_llm_provider, api_base=api_base, api_key=api_key, + litellm_params=litellm.types.router.LiteLLM_Params( + model=model, + use_litellm_proxy=kwargs.get("use_litellm_proxy", False), + ), ) if dynamic_api_key is not None: @@ -5688,6 +5704,10 @@ def text_completion( # noqa: PLR0915 model=model, # type: ignore custom_llm_provider=custom_llm_provider, api_base=api_base, + litellm_params=litellm.types.router.LiteLLM_Params( + model=model, # type: ignore + use_litellm_proxy=kwargs.get("use_litellm_proxy", False), + ), ) if custom_llm_provider == "huggingface": @@ -5978,6 +5998,10 @@ async def amoderation( custom_llm_provider=custom_llm_provider, api_base=optional_params.api_base, api_key=optional_params.api_key, + litellm_params=litellm.types.router.LiteLLM_Params( + model=model or "", + use_litellm_proxy=kwargs.get("use_litellm_proxy", False), + ), ) except litellm.BadRequestError: # `model` is optional field for moderation - get_llm_provider will throw BadRequestError if model is not set / not recognized @@ -6043,7 +6067,12 @@ async def atranscription(*args, **kwargs) -> TranscriptionResponse: func_with_context = partial(ctx.run, func) _, custom_llm_provider, _, _ = get_llm_provider( - model=model, api_base=kwargs.get("api_base", None) + model=model, + api_base=kwargs.get("api_base", None), + litellm_params=litellm.types.router.LiteLLM_Params( + model=model, + use_litellm_proxy=kwargs.get("use_litellm_proxy", False), + ), ) # Await normally @@ -6147,6 +6176,10 @@ def transcription( custom_llm_provider=custom_llm_provider, api_base=api_base, api_key=api_key, + litellm_params=litellm.types.router.LiteLLM_Params( + model=model, + use_litellm_proxy=kwargs.get("use_litellm_proxy", False), + ), ) # type: ignore if dynamic_api_key is not None: @@ -6322,7 +6355,12 @@ async def aspeech(*args, **kwargs) -> HttpxBinaryResponseContent: func_with_context = partial(ctx.run, func) _, custom_llm_provider, _, _ = get_llm_provider( - model=model, api_base=kwargs.get("api_base", None) + model=model, + api_base=kwargs.get("api_base", None), + litellm_params=litellm.types.router.LiteLLM_Params( + model=model, + use_litellm_proxy=kwargs.get("use_litellm_proxy", False), + ), ) # Await normally @@ -6373,7 +6411,13 @@ def speech( # noqa: PLR0915 model_info = kwargs.get("model_info", None) shared_session = kwargs.get("shared_session", None) model, custom_llm_provider, dynamic_api_key, api_base = get_llm_provider( - model=model, custom_llm_provider=custom_llm_provider, api_base=api_base + model=model, + custom_llm_provider=custom_llm_provider, + api_base=api_base, + litellm_params=litellm.types.router.LiteLLM_Params( + model=model, + use_litellm_proxy=kwargs.get("use_litellm_proxy", False), + ), ) # type: ignore kwargs.pop("tags", []) @@ -6883,6 +6927,10 @@ async def ahealth_check( custom_llm_provider=custom_llm_provider_from_params, api_base=api_base_from_params, api_key=api_key_from_params, + litellm_params=litellm.types.router.LiteLLM_Params( + model=model, + use_litellm_proxy=model_params.get("use_litellm_proxy", False), + ), ) if model in litellm.model_cost and mode is None: mode = litellm.model_cost[model].get("mode") From 30f2c094015685f90b9cd07145a9934fddd1d1c5 Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Mon, 19 Jan 2026 07:33:05 +0900 Subject: [PATCH 02/20] feat: mcp version up 1.21.2 -> 1.25.0 --- poetry.lock | 22 +++++----------------- pyproject.toml | 2 +- 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/poetry.lock b/poetry.lock index b76f9c30f00..5a3b6b84870 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 2.2.0 and should not be changed by hand. +# This file is automatically @generated by Poetry 2.1.4 and should not be changed by hand. [[package]] name = "aiofiles" @@ -2191,8 +2191,6 @@ files = [ {file = "greenlet-3.2.4-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:c2ca18a03a8cfb5b25bc1cbe20f3d9a4c80d8c3b13ba3df49ac3961af0b1018d"}, {file = "greenlet-3.2.4-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:9fe0a28a7b952a21e2c062cd5756d34354117796c6d9215a87f55e38d15402c5"}, {file = "greenlet-3.2.4-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:8854167e06950ca75b898b104b63cc646573aa5fef1353d4508ecdd1ee76254f"}, - {file = "greenlet-3.2.4-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:f47617f698838ba98f4ff4189aef02e7343952df3a615f847bb575c3feb177a7"}, - {file = "greenlet-3.2.4-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:af41be48a4f60429d5cad9d22175217805098a9ef7c40bfef44f7669fb9d74d8"}, {file = "greenlet-3.2.4-cp310-cp310-win_amd64.whl", hash = "sha256:73f49b5368b5359d04e18d15828eecc1806033db5233397748f4ca813ff1056c"}, {file = "greenlet-3.2.4-cp311-cp311-macosx_11_0_universal2.whl", hash = "sha256:96378df1de302bc38e99c3a9aa311967b7dc80ced1dcc6f171e99842987882a2"}, {file = "greenlet-3.2.4-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:1ee8fae0519a337f2329cb78bd7a8e128ec0f881073d43f023c7b8d4831d5246"}, @@ -2202,8 +2200,6 @@ files = [ {file = "greenlet-3.2.4-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:2523e5246274f54fdadbce8494458a2ebdcdbc7b802318466ac5606d3cded1f8"}, {file = "greenlet-3.2.4-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:1987de92fec508535687fb807a5cea1560f6196285a4cde35c100b8cd632cc52"}, {file = "greenlet-3.2.4-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:55e9c5affaa6775e2c6b67659f3a71684de4c549b3dd9afca3bc773533d284fa"}, - {file = "greenlet-3.2.4-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:c9c6de1940a7d828635fbd254d69db79e54619f165ee7ce32fda763a9cb6a58c"}, - {file = "greenlet-3.2.4-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:03c5136e7be905045160b1b9fdca93dd6727b180feeafda6818e6496434ed8c5"}, {file = "greenlet-3.2.4-cp311-cp311-win_amd64.whl", hash = "sha256:9c40adce87eaa9ddb593ccb0fa6a07caf34015a29bf8d344811665b573138db9"}, {file = "greenlet-3.2.4-cp312-cp312-macosx_11_0_universal2.whl", hash = "sha256:3b67ca49f54cede0186854a008109d6ee71f66bd57bb36abd6d0a0267b540cdd"}, {file = "greenlet-3.2.4-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:ddf9164e7a5b08e9d22511526865780a576f19ddd00d62f8a665949327fde8bb"}, @@ -2213,8 +2209,6 @@ files = [ {file = "greenlet-3.2.4-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:3b3812d8d0c9579967815af437d96623f45c0f2ae5f04e366de62a12d83a8fb0"}, {file = "greenlet-3.2.4-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:abbf57b5a870d30c4675928c37278493044d7c14378350b3aa5d484fa65575f0"}, {file = "greenlet-3.2.4-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:20fb936b4652b6e307b8f347665e2c615540d4b42b3b4c8a321d8286da7e520f"}, - {file = "greenlet-3.2.4-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:ee7a6ec486883397d70eec05059353b8e83eca9168b9f3f9a361971e77e0bcd0"}, - {file = "greenlet-3.2.4-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:326d234cbf337c9c3def0676412eb7040a35a768efc92504b947b3e9cfc7543d"}, {file = "greenlet-3.2.4-cp312-cp312-win_amd64.whl", hash = "sha256:a7d4e128405eea3814a12cc2605e0e6aedb4035bf32697f72deca74de4105e02"}, {file = "greenlet-3.2.4-cp313-cp313-macosx_11_0_universal2.whl", hash = "sha256:1a921e542453fe531144e91e1feedf12e07351b1cf6c9e8a3325ea600a715a31"}, {file = "greenlet-3.2.4-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:cd3c8e693bff0fff6ba55f140bf390fa92c994083f838fece0f63be121334945"}, @@ -2224,8 +2218,6 @@ files = [ {file = "greenlet-3.2.4-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:23768528f2911bcd7e475210822ffb5254ed10d71f4028387e5a99b4c6699671"}, {file = "greenlet-3.2.4-cp313-cp313-musllinux_1_1_aarch64.whl", hash = "sha256:00fadb3fedccc447f517ee0d3fd8fe49eae949e1cd0f6a611818f4f6fb7dc83b"}, {file = "greenlet-3.2.4-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:d25c5091190f2dc0eaa3f950252122edbbadbb682aa7b1ef2f8af0f8c0afefae"}, - {file = "greenlet-3.2.4-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:6e343822feb58ac4d0a1211bd9399de2b3a04963ddeec21530fc426cc121f19b"}, - {file = "greenlet-3.2.4-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:ca7f6f1f2649b89ce02f6f229d7c19f680a6238af656f61e0115b24857917929"}, {file = "greenlet-3.2.4-cp313-cp313-win_amd64.whl", hash = "sha256:554b03b6e73aaabec3745364d6239e9e012d64c68ccd0b8430c64ccc14939a8b"}, {file = "greenlet-3.2.4-cp314-cp314-macosx_11_0_universal2.whl", hash = "sha256:49a30d5fda2507ae77be16479bdb62a660fa51b1eb4928b524975b3bde77b3c0"}, {file = "greenlet-3.2.4-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:299fd615cd8fc86267b47597123e3f43ad79c9d8a22bebdce535e53550763e2f"}, @@ -2233,8 +2225,6 @@ files = [ {file = "greenlet-3.2.4-cp314-cp314-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:b4a1870c51720687af7fa3e7cda6d08d801dae660f75a76f3845b642b4da6ee1"}, {file = "greenlet-3.2.4-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:061dc4cf2c34852b052a8620d40f36324554bc192be474b9e9770e8c042fd735"}, {file = "greenlet-3.2.4-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:44358b9bf66c8576a9f57a590d5f5d6e72fa4228b763d0e43fee6d3b06d3a337"}, - {file = "greenlet-3.2.4-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:2917bdf657f5859fbf3386b12d68ede4cf1f04c90c3a6bc1f013dd68a22e2269"}, - {file = "greenlet-3.2.4-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:015d48959d4add5d6c9f6c5210ee3803a830dce46356e3bc326d6776bde54681"}, {file = "greenlet-3.2.4-cp314-cp314-win_amd64.whl", hash = "sha256:e37ab26028f12dbb0ff65f29a8d3d44a765c61e729647bf2ddfbbed621726f01"}, {file = "greenlet-3.2.4-cp39-cp39-macosx_11_0_universal2.whl", hash = "sha256:b6a7c19cf0d2742d0809a4c05975db036fdff50cd294a93632d6a310bf9ac02c"}, {file = "greenlet-3.2.4-cp39-cp39-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:27890167f55d2387576d1f41d9487ef171849ea0359ce1510ca6e06c8bece11d"}, @@ -2244,8 +2234,6 @@ files = [ {file = "greenlet-3.2.4-cp39-cp39-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:c9913f1a30e4526f432991f89ae263459b1c64d1608c0d22a5c79c287b3c70df"}, {file = "greenlet-3.2.4-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:b90654e092f928f110e0007f572007c9727b5265f7632c2fa7415b4689351594"}, {file = "greenlet-3.2.4-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:81701fd84f26330f0d5f4944d4e92e61afe6319dcd9775e39396e39d7c3e5f98"}, - {file = "greenlet-3.2.4-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:28a3c6b7cd72a96f61b0e4b2a36f681025b60ae4779cc73c1535eb5f29560b10"}, - {file = "greenlet-3.2.4-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:52206cd642670b0b320a1fd1cbfd95bca0e043179c1d8a045f2c6109dfe973be"}, {file = "greenlet-3.2.4-cp39-cp39-win32.whl", hash = "sha256:65458b409c1ed459ea899e939f0e1cdb14f58dbc803f2f93c5eab5694d32671b"}, {file = "greenlet-3.2.4-cp39-cp39-win_amd64.whl", hash = "sha256:d2e685ade4dafd447ede19c31277a224a239a0a1a4eca4e6390efedf20260cfb"}, {file = "greenlet-3.2.4.tar.gz", hash = "sha256:0dca0d95ff849f9a364385f36ab49f50065d76964944638be9691e1832e9f86d"}, @@ -3357,15 +3345,15 @@ files = [ [[package]] name = "mcp" -version = "1.22.0" +version = "1.25.0" description = "Model Context Protocol SDK" optional = true python-versions = ">=3.10" groups = ["main"] markers = "python_version >= \"3.10\" and extra == \"proxy\"" files = [ - {file = "mcp-1.22.0-py3-none-any.whl", hash = "sha256:bed758e24df1ed6846989c909ba4e3df339a27b4f30f1b8b627862a4bade4e98"}, - {file = "mcp-1.22.0.tar.gz", hash = "sha256:769b9ac90ed42134375b19e777a2858ca300f95f2e800982b3e2be62dfc0ba01"}, + {file = "mcp-1.25.0-py3-none-any.whl", hash = "sha256:b37c38144a666add0862614cc79ec276e97d72aa8ca26d622818d4e278b9721a"}, + {file = "mcp-1.25.0.tar.gz", hash = "sha256:56310361ebf0364e2d438e5b45f7668cbb124e158bb358333cd06e49e83a6802"}, ] [package.dependencies] @@ -7981,4 +7969,4 @@ utils = ["numpydoc"] [metadata] lock-version = "2.1" python-versions = ">=3.9,<4.0" -content-hash = "2d6b3d8d44919c29315b5e645befbf745a276714a2454c563d460a6a001b90af" +content-hash = "7c9f917a46adc0d0b57dbc48cbdc3622551aa733d86909da1be87773c2857694" diff --git a/pyproject.toml b/pyproject.toml index d6242b27786..d80d442be26 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -58,7 +58,7 @@ pynacl = {version = "^1.5.0", optional = true} websockets = {version = "^15.0.1", optional = true} boto3 = {version = "1.36.0", optional = true} redisvl = {version = "^0.4.1", optional = true, markers = "python_version >= '3.9' and python_version < '3.14'"} -mcp = {version = "^1.21.2", optional = true, python = ">=3.10"} +mcp = {version = ">=1.25.0,<2.0.0", optional = true, python = ">=3.10"} litellm-proxy-extras = {version = "0.4.23", optional = true} rich = {version = "13.7.1", optional = true} litellm-enterprise = {version = "0.1.27", optional = true} From c4013a34b8949c61ae498e2b6ab675052179e2f0 Mon Sep 17 00:00:00 2001 From: Lucky Lodhi Date: Mon, 19 Jan 2026 17:20:18 +0000 Subject: [PATCH 03/20] fix tool call for ollama - #19357 --- litellm/litellm_core_utils/prompt_templates/common_utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/litellm/litellm_core_utils/prompt_templates/common_utils.py b/litellm/litellm_core_utils/prompt_templates/common_utils.py index a8b8b207de4..7790fb83361 100644 --- a/litellm/litellm_core_utils/prompt_templates/common_utils.py +++ b/litellm/litellm_core_utils/prompt_templates/common_utils.py @@ -1071,9 +1071,9 @@ def _extract_reasoning_content(message: dict) -> Tuple[Optional[str], Optional[s """ message_content = message.get("content") if "reasoning_content" in message: - return message["reasoning_content"], message["content"] + return message["reasoning_content"], message_content elif "reasoning" in message: - return message["reasoning"], message["content"] + return message["reasoning"], message_content elif isinstance(message_content, str): return _parse_content_for_reasoning(message_content) return None, message_content From 74d3b1129068a96ebaac69bf06475dcde8fe1f85 Mon Sep 17 00:00:00 2001 From: Lucky Lodhi Date: Mon, 19 Jan 2026 17:38:29 +0000 Subject: [PATCH 04/20] undid changes --- litellm/main.py | 56 ++++--------------------------------------------- 1 file changed, 4 insertions(+), 52 deletions(-) diff --git a/litellm/main.py b/litellm/main.py index fb7b0bf8b4a..ae27b4145b3 100644 --- a/litellm/main.py +++ b/litellm/main.py @@ -565,10 +565,6 @@ async def acompletion( model=model, custom_llm_provider=custom_llm_provider, api_base=completion_kwargs.get("base_url", None), - litellm_params=litellm.types.router.LiteLLM_Params( - model=model, - use_litellm_proxy=kwargs.get("use_litellm_proxy", False), - ), ) fallbacks = fallbacks or litellm.model_fallbacks @@ -1295,10 +1291,6 @@ def completion( # type: ignore # noqa: PLR0915 custom_llm_provider=custom_llm_provider, api_base=api_base, api_key=api_key, - litellm_params=litellm.types.router.LiteLLM_Params( - model=model, - use_litellm_proxy=kwargs.get("use_litellm_proxy", False), - ), ) if not _should_allow_input_examples( @@ -4376,10 +4368,6 @@ async def aembedding(*args, **kwargs) -> EmbeddingResponse: model=model, custom_llm_provider=custom_llm_provider, api_base=kwargs.get("api_base", None), - litellm_params=litellm.types.router.LiteLLM_Params( - model=model, - use_litellm_proxy=kwargs.get("use_litellm_proxy", False), - ), ) # Await normally @@ -4565,10 +4553,6 @@ def embedding( # noqa: PLR0915 custom_llm_provider=custom_llm_provider, api_base=api_base, api_key=api_key, - litellm_params=litellm.types.router.LiteLLM_Params( - model=model, - use_litellm_proxy=kwargs.get("use_litellm_proxy", False), - ), ) if dynamic_api_key is not None: @@ -5704,10 +5688,6 @@ def text_completion( # noqa: PLR0915 model=model, # type: ignore custom_llm_provider=custom_llm_provider, api_base=api_base, - litellm_params=litellm.types.router.LiteLLM_Params( - model=model, # type: ignore - use_litellm_proxy=kwargs.get("use_litellm_proxy", False), - ), ) if custom_llm_provider == "huggingface": @@ -5998,10 +5978,6 @@ async def amoderation( custom_llm_provider=custom_llm_provider, api_base=optional_params.api_base, api_key=optional_params.api_key, - litellm_params=litellm.types.router.LiteLLM_Params( - model=model or "", - use_litellm_proxy=kwargs.get("use_litellm_proxy", False), - ), ) except litellm.BadRequestError: # `model` is optional field for moderation - get_llm_provider will throw BadRequestError if model is not set / not recognized @@ -6067,12 +6043,7 @@ async def atranscription(*args, **kwargs) -> TranscriptionResponse: func_with_context = partial(ctx.run, func) _, custom_llm_provider, _, _ = get_llm_provider( - model=model, - api_base=kwargs.get("api_base", None), - litellm_params=litellm.types.router.LiteLLM_Params( - model=model, - use_litellm_proxy=kwargs.get("use_litellm_proxy", False), - ), + model=model, api_base=kwargs.get("api_base", None) ) # Await normally @@ -6176,10 +6147,6 @@ def transcription( custom_llm_provider=custom_llm_provider, api_base=api_base, api_key=api_key, - litellm_params=litellm.types.router.LiteLLM_Params( - model=model, - use_litellm_proxy=kwargs.get("use_litellm_proxy", False), - ), ) # type: ignore if dynamic_api_key is not None: @@ -6355,12 +6322,7 @@ async def aspeech(*args, **kwargs) -> HttpxBinaryResponseContent: func_with_context = partial(ctx.run, func) _, custom_llm_provider, _, _ = get_llm_provider( - model=model, - api_base=kwargs.get("api_base", None), - litellm_params=litellm.types.router.LiteLLM_Params( - model=model, - use_litellm_proxy=kwargs.get("use_litellm_proxy", False), - ), + model=model, api_base=kwargs.get("api_base", None) ) # Await normally @@ -6411,13 +6373,7 @@ def speech( # noqa: PLR0915 model_info = kwargs.get("model_info", None) shared_session = kwargs.get("shared_session", None) model, custom_llm_provider, dynamic_api_key, api_base = get_llm_provider( - model=model, - custom_llm_provider=custom_llm_provider, - api_base=api_base, - litellm_params=litellm.types.router.LiteLLM_Params( - model=model, - use_litellm_proxy=kwargs.get("use_litellm_proxy", False), - ), + model=model, custom_llm_provider=custom_llm_provider, api_base=api_base ) # type: ignore kwargs.pop("tags", []) @@ -6927,10 +6883,6 @@ async def ahealth_check( custom_llm_provider=custom_llm_provider_from_params, api_base=api_base_from_params, api_key=api_key_from_params, - litellm_params=litellm.types.router.LiteLLM_Params( - model=model, - use_litellm_proxy=model_params.get("use_litellm_proxy", False), - ), ) if model in litellm.model_cost and mode is None: mode = litellm.model_cost[model].get("mode") @@ -7303,4 +7255,4 @@ def __getattr__(name: str) -> Any: global _encoding_cache _encoding_cache = _encoding return _encoding - raise AttributeError(f"module {__name__!r} has no attribute {name!r}") + raise AttributeError(f"module {__name__!r} has no attribute {name!r}") \ No newline at end of file From 05d9fb6fd61a50760608014a16a3bb33960dd155 Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Tue, 20 Jan 2026 07:24:39 +0900 Subject: [PATCH 05/20] feat: SEP-986 --- .../mcp_server/mcp_server_manager.py | 51 ++++++++++ .../proxy/_experimental/mcp_server/server.py | 1 - .../mcp_management_endpoints.py | 40 +++++++- .../mcp_server/test_mcp_server_manager.py | 96 +++++++++++++++++++ .../test_mcp_management_endpoints.py | 27 +++++- .../mcp_tools/create_mcp_server.tsx | 2 +- 6 files changed, 211 insertions(+), 6 deletions(-) diff --git a/litellm/proxy/_experimental/mcp_server/mcp_server_manager.py b/litellm/proxy/_experimental/mcp_server/mcp_server_manager.py index 0b81bd7aff7..53dc6e512c5 100644 --- a/litellm/proxy/_experimental/mcp_server/mcp_server_manager.py +++ b/litellm/proxy/_experimental/mcp_server/mcp_server_manager.py @@ -38,6 +38,7 @@ from litellm.proxy._experimental.mcp_server.auth.user_api_key_auth_mcp import ( MCPRequestHandler, ) from litellm.proxy._experimental.mcp_server.utils import ( + MCP_TOOL_PREFIX_SEPARATOR, add_server_prefix_to_name, get_server_prefix, is_tool_name_prefixed, @@ -61,6 +62,45 @@ from litellm.types.mcp_server.mcp_server_manager import ( MCPOAuthMetadata, MCPServer, ) +from mcp.shared.tool_name_validation import SEP_986_URL, validate_tool_name + + +# Probe includes characters on both sides of the separator to mimic real prefixed tool names. +_separator_probe_tool_name = f"litellm{MCP_TOOL_PREFIX_SEPARATOR}probe" +_separator_probe = validate_tool_name(_separator_probe_tool_name) +if not _separator_probe.is_valid: + verbose_logger.warning( + "MCP tool prefix separator '%s' violates SEP-986. See %s", + MCP_TOOL_PREFIX_SEPARATOR, + SEP_986_URL, + ) + + +def _warn_on_server_name_fields( + *, + server_id: str, + alias: Optional[str], + server_name: Optional[str], +): + def _warn(field_name: str, value: Optional[str]) -> None: + if not value: + return + result = validate_tool_name(value) + if result.is_valid: + return + + warning_text = "; ".join(result.warnings) if result.warnings else "Validation failed" + verbose_logger.warning( + "MCP server '%s' has invalid %s '%s': %s", + server_id, + field_name, + value, + warning_text, + ) + + _warn("alias", alias) + _warn("server_name", server_name) + def _deserialize_json_dict(data: Any) -> Optional[Dict[str, str]]: @@ -209,6 +249,12 @@ class MCPServerManager: alias=alias, ) + _warn_on_server_name_fields( + server_id=server_id, + alias=alias, + server_name=server_name, + ) + auth_type = server_config.get("auth_type", None) if server_url and auth_type is not None and auth_type == MCPAuth.oauth2: mcp_oauth_metadata = await self._descovery_metadata( @@ -2099,6 +2145,11 @@ class MCPServerManager: new_registry[server.server_id] = existing_server continue + _warn_on_server_name_fields( + server_id=server.server_id, + alias=getattr(server, "alias", None), + server_name=getattr(server, "server_name", None), + ) verbose_logger.debug( f"Building server from DB: {server.server_id} ({server.server_name})" ) diff --git a/litellm/proxy/_experimental/mcp_server/server.py b/litellm/proxy/_experimental/mcp_server/server.py index f22040a7dd9..76a28344856 100644 --- a/litellm/proxy/_experimental/mcp_server/server.py +++ b/litellm/proxy/_experimental/mcp_server/server.py @@ -786,7 +786,6 @@ if MCP_AVAILABLE: add_prefix=add_prefix, raw_headers=raw_headers, ) - filtered_tools = filter_tools_by_allowed_tools(tools, server) filtered_tools = await filter_tools_by_key_team_permissions( diff --git a/litellm/proxy/management_endpoints/mcp_management_endpoints.py b/litellm/proxy/management_endpoints/mcp_management_endpoints.py index d8816df010a..a15f47d13bd 100644 --- a/litellm/proxy/management_endpoints/mcp_management_endpoints.py +++ b/litellm/proxy/management_endpoints/mcp_management_endpoints.py @@ -37,7 +37,7 @@ from litellm._uuid import uuid from litellm.constants import LITELLM_PROXY_ADMIN_NAME from litellm.proxy._experimental.mcp_server.utils import ( get_server_prefix, - validate_and_normalize_mcp_server_payload, + validate_and_normalize_mcp_server_payload as _base_validate_and_normalize_mcp_server_payload, ) router = APIRouter(prefix="/v1/mcp", tags=["mcp"]) @@ -56,6 +56,7 @@ except ImportError as e: MCP_AVAILABLE = False if MCP_AVAILABLE: + from mcp.shared.tool_name_validation import validate_tool_name from litellm.proxy._experimental.mcp_server.db import ( create_mcp_server, delete_mcp_server, @@ -97,6 +98,43 @@ if MCP_AVAILABLE: server: MCPServer expires_at: datetime + def _validate_mcp_server_name_fields(payload: Any) -> None: + candidates: List[tuple[str, Optional[str]]] = [] + + server_name = getattr(payload, "server_name", None) + alias = getattr(payload, "alias", None) + + if server_name: + candidates.append(("server_name", server_name)) + if alias: + candidates.append(("alias", alias)) + + for field_name, value in candidates: + if not value: + continue + + validation_result = validate_tool_name(value) + if validation_result.is_valid: + continue + + error_messages_text = ( + f"Invalid MCP tool prefix '{value}' provided via {field_name}" + ) + if validation_result.warnings: + error_messages_text = ( + error_messages_text + + "\n" + + "\n".join(validation_result.warnings) + ) + raise HTTPException( + status_code=status.HTTP_400_BAD_REQUEST, + detail={"error": error_messages_text}, + ) + + def validate_and_normalize_mcp_server_payload(payload: Any) -> None: + _base_validate_and_normalize_mcp_server_payload(payload) + _validate_mcp_server_name_fields(payload) + def _is_public_registry_enabled() -> bool: from litellm.proxy.proxy_server import ( general_settings as proxy_general_settings, diff --git a/tests/test_litellm/proxy/_experimental/mcp_server/test_mcp_server_manager.py b/tests/test_litellm/proxy/_experimental/mcp_server/test_mcp_server_manager.py index 9ddfbf2059c..86abec31012 100644 --- a/tests/test_litellm/proxy/_experimental/mcp_server/test_mcp_server_manager.py +++ b/tests/test_litellm/proxy/_experimental/mcp_server/test_mcp_server_manager.py @@ -1,3 +1,6 @@ +import importlib +import logging +import os import sys from datetime import datetime from unittest.mock import AsyncMock, MagicMock, patch @@ -29,6 +32,15 @@ from litellm.types.mcp import MCPAuth from litellm.types.mcp_server.mcp_server_manager import MCPOAuthMetadata, MCPServer +def _reload_mcp_manager_module(): + utils_module = sys.modules["litellm.proxy._experimental.mcp_server.utils"] + manager_module = sys.modules[ + "litellm.proxy._experimental.mcp_server.mcp_server_manager" + ] + importlib.reload(utils_module) + return importlib.reload(manager_module) + + class TestMCPServerManager: """Test MCP Server Manager stdio functionality""" @@ -148,6 +160,90 @@ class TestMCPServerManager: # When the header isn't provided, the key is omitted entirely assert env == {} + @pytest.mark.asyncio + async def test_load_servers_from_config_warns_on_invalid_alias(self, caplog): + """Invalid aliases from config should emit warnings during load.""" + + manager = MCPServerManager() + config = { + "validserver": { + "alias": "bad/name", + "url": "https://example.com", + "transport": MCPTransport.http, + } + } + + with caplog.at_level(logging.WARNING, logger="LiteLLM"): + await manager.load_servers_from_config(config) + + assert any( + "invalid alias 'bad/name'" in message for message in caplog.messages + ) + + @pytest.mark.asyncio + async def test_load_servers_from_config_accepts_valid_alias(self, caplog): + """Valid aliases should be accepted and populate the registry.""" + + manager = MCPServerManager() + config = { + "validserver": { + "alias": "friendly_alias", + "url": "https://example.com", + "transport": MCPTransport.http, + } + } + + with caplog.at_level(logging.WARNING, logger="LiteLLM"): + await manager.load_servers_from_config(config) + + # No warnings logged for the valid alias + assert all("invalid alias" not in message for message in caplog.messages) + + server = next(iter(manager.config_mcp_servers.values())) + assert server.alias == "friendly_alias" + assert server.server_name == "validserver" + + def test_warns_when_custom_separator_invalid(self, monkeypatch, caplog): + """Invalid MCP_TOOL_PREFIX_SEPARATOR values should log a warning.""" + + original_value = os.environ.get("MCP_TOOL_PREFIX_SEPARATOR") + monkeypatch.setenv("MCP_TOOL_PREFIX_SEPARATOR", "/") + + with caplog.at_level(logging.WARNING, logger="LiteLLM"): + _reload_mcp_manager_module() + + assert any("violates SEP-986" in message for message in caplog.messages) + + # Restore original setting and ensure warning disappears + if original_value is None: + monkeypatch.delenv("MCP_TOOL_PREFIX_SEPARATOR", raising=False) + else: + monkeypatch.setenv("MCP_TOOL_PREFIX_SEPARATOR", original_value) + + caplog.clear() + with caplog.at_level(logging.WARNING, logger="LiteLLM"): + _reload_mcp_manager_module() + + assert all("violates SEP-986" not in message for message in caplog.messages) + + def test_accepts_valid_custom_separator(self, monkeypatch, caplog): + """Valid separators should not emit warnings during module import.""" + + original_value = os.environ.get("MCP_TOOL_PREFIX_SEPARATOR") + monkeypatch.setenv("MCP_TOOL_PREFIX_SEPARATOR", "_") + + with caplog.at_level(logging.WARNING, logger="LiteLLM"): + _reload_mcp_manager_module() + + assert all("violates SEP-986" not in message for message in caplog.messages) + + if original_value is None: + monkeypatch.delenv("MCP_TOOL_PREFIX_SEPARATOR", raising=False) + else: + monkeypatch.setenv("MCP_TOOL_PREFIX_SEPARATOR", original_value) + + _reload_mcp_manager_module() + @pytest.mark.asyncio async def test_list_tools_with_server_specific_auth_headers(self): """Test list_tools method with server-specific auth headers""" diff --git a/tests/test_litellm/proxy/management_endpoints/test_mcp_management_endpoints.py b/tests/test_litellm/proxy/management_endpoints/test_mcp_management_endpoints.py index bc223d15d5f..f7e7fcebaef 100644 --- a/tests/test_litellm/proxy/management_endpoints/test_mcp_management_endpoints.py +++ b/tests/test_litellm/proxy/management_endpoints/test_mcp_management_endpoints.py @@ -2,14 +2,18 @@ import json import os import sys import types +from types import SimpleNamespace from datetime import datetime, timedelta from typing import List, Optional from unittest.mock import AsyncMock, MagicMock, patch import pytest -from fastapi import FastAPI +from fastapi import FastAPI, HTTPException from fastapi.testclient import TestClient from litellm._uuid import uuid +from litellm.proxy.management_endpoints import ( + mcp_management_endpoints as mgmt_endpoints, +) sys.path.insert( 0, os.path.abspath("../../../..") @@ -726,8 +730,6 @@ class TestTemporaryMCPSessionEndpoints: "litellm.proxy.management_endpoints.mcp_management_endpoints.get_cached_temporary_mcp_server", return_value=None, ): - from fastapi import HTTPException - with pytest.raises(HTTPException) as exc_info: _get_cached_temporary_mcp_server_or_404("missing") @@ -1195,6 +1197,25 @@ class TestMCPRegistryEndpoint: assert result[0]["server_id"] == "server-1" assert result[0]["status"] == "healthy" + +class TestManagementPayloadValidation: + def test_rejects_invalid_alias(self): + payload = SimpleNamespace(server_name="valid_server", alias="bad/name") + + with pytest.raises(HTTPException) as exc_info: + mgmt_endpoints.validate_and_normalize_mcp_server_payload(payload) + + assert exc_info.value.status_code == 400 + error_message = exc_info.value.detail["error"] + assert "bad/name" in error_message + + def test_accepts_valid_names(self): + payload = SimpleNamespace(server_name="valid_server", alias=None) + + mgmt_endpoints.validate_and_normalize_mcp_server_payload(payload) + + assert payload.alias == "valid_server" + @pytest.mark.asyncio async def test_health_check_view_all_mode(self): """view_all mode should return health info for all MCP servers.""" diff --git a/ui/litellm-dashboard/src/components/mcp_tools/create_mcp_server.tsx b/ui/litellm-dashboard/src/components/mcp_tools/create_mcp_server.tsx index 82932a320e6..a3e27fb68fa 100644 --- a/ui/litellm-dashboard/src/components/mcp_tools/create_mcp_server.tsx +++ b/ui/litellm-dashboard/src/components/mcp_tools/create_mcp_server.tsx @@ -425,7 +425,7 @@ const CreateMCPServer: React.FC = ({ label={ MCP Server Name - + From 51cf782292f8b4a23b05abdd536ab6507ddc0c16 Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Tue, 20 Jan 2026 07:37:50 +0900 Subject: [PATCH 06/20] chore: switch experimental client to streamable_http_client API --- litellm/experimental_mcp_client/client.py | 19 +++++--- tests/mcp_tests/test_mcp_client_unit.py | 11 ++--- .../test_mcp_client.py | 47 ++++++++----------- 3 files changed, 36 insertions(+), 41 deletions(-) diff --git a/litellm/experimental_mcp_client/client.py b/litellm/experimental_mcp_client/client.py index 943cc6b2d53..582d044023c 100644 --- a/litellm/experimental_mcp_client/client.py +++ b/litellm/experimental_mcp_client/client.py @@ -4,14 +4,13 @@ LiteLLM Proxy uses this MCP Client to connnect to other MCP servers. import asyncio import base64 -from datetime import timedelta from typing import Awaitable, Callable, Dict, List, Optional, TypeVar, Union import httpx from mcp import ClientSession, ReadResourceResult, Resource, StdioServerParameters from mcp.client.sse import sse_client from mcp.client.stdio import stdio_client -from mcp.client.streamable_http import streamablehttp_client +from mcp.client.streamable_http import streamable_http_client from mcp.types import ( CallToolRequestParams as MCPCallToolRequestParams, GetPromptRequestParams, @@ -80,6 +79,7 @@ class MCPClient: ) -> TSessionResult: """Open a session, run the provided coroutine, and clean up.""" transport_ctx = None + http_client: Optional[httpx.AsyncClient] = None try: if self.transport_type == MCPTransport.stdio: @@ -105,13 +105,15 @@ class MCPClient: headers = self._get_auth_headers() httpx_client_factory = self._create_httpx_client_factory() verbose_logger.debug( - "litellm headers for streamablehttp_client: %s", headers + "litellm headers for streamable_http_client: %s", headers ) - transport_ctx = streamablehttp_client( - url=self.server_url, - timeout=timedelta(seconds=self.timeout), + http_client = httpx_client_factory( headers=headers, - httpx_client_factory=httpx_client_factory, + timeout=httpx.Timeout(self.timeout), + ) + transport_ctx = streamable_http_client( + url=self.server_url, + http_client=http_client, ) if transport_ctx is None: @@ -128,6 +130,9 @@ class MCPClient: "MCP client run_with_session failed for %s", self.server_url or "stdio" ) raise + finally: + if http_client is not None: + await http_client.aclose() def update_auth_value(self, mcp_auth_value: Union[str, Dict[str, str]]): """ diff --git a/tests/mcp_tests/test_mcp_client_unit.py b/tests/mcp_tests/test_mcp_client_unit.py index 451c3774372..301234ec983 100644 --- a/tests/mcp_tests/test_mcp_client_unit.py +++ b/tests/mcp_tests/test_mcp_client_unit.py @@ -82,7 +82,7 @@ class TestMCPClientUnitTests: assert headers == {} @pytest.mark.asyncio - @patch("litellm.experimental_mcp_client.client.streamablehttp_client") + @patch("litellm.experimental_mcp_client.client.streamable_http_client") @patch("litellm.experimental_mcp_client.client.ClientSession") async def test_run_with_session(self, mock_session_class, mock_transport): """Test run_with_session establishes session with auth headers.""" @@ -110,15 +110,14 @@ class TestMCPClientUnitTests: # Verify transport was created with auth headers call_args = mock_transport.call_args - assert call_args[1]["headers"] == { - "Authorization": "Bearer test_token", - } + http_client = call_args[1]["http_client"] + assert http_client.headers.get("Authorization") == "Bearer test_token" # Verify session was initialized mock_session_instance.initialize.assert_called_once() @pytest.mark.asyncio - @patch("litellm.experimental_mcp_client.client.streamablehttp_client") + @patch("litellm.experimental_mcp_client.client.streamable_http_client") @patch("litellm.experimental_mcp_client.client.ClientSession") async def test_list_tools(self, mock_session_class, mock_transport): """Test listing tools from the server.""" @@ -156,7 +155,7 @@ class TestMCPClientUnitTests: mock_session_instance.list_tools.assert_called_once() @pytest.mark.asyncio - @patch("litellm.experimental_mcp_client.client.streamablehttp_client") + @patch("litellm.experimental_mcp_client.client.streamable_http_client") @patch("litellm.experimental_mcp_client.client.ClientSession") async def test_call_tool(self, mock_session_class, mock_transport): """Test calling a tool.""" diff --git a/tests/test_litellm/experimental_mcp_client/test_mcp_client.py b/tests/test_litellm/experimental_mcp_client/test_mcp_client.py index 14b747a5704..a03090d9c52 100644 --- a/tests/test_litellm/experimental_mcp_client/test_mcp_client.py +++ b/tests/test_litellm/experimental_mcp_client/test_mcp_client.py @@ -81,7 +81,7 @@ class TestMCPClient: assert call_args.env == {"DEBUG": "1"} @pytest.mark.asyncio - @patch("litellm.experimental_mcp_client.client.streamablehttp_client") + @patch("litellm.experimental_mcp_client.client.streamable_http_client") @patch.dict( os.environ, { @@ -90,12 +90,12 @@ class TestMCPClient: }, ) async def test_mcp_client_ssl_configuration_from_env( - self, mock_streamablehttp_client + self, mock_streamable_http_client ): """Test that MCP client uses SSL configuration from environment variables""" # Setup mocks mock_transport = (MagicMock(), MagicMock()) - mock_streamablehttp_client.return_value.__aenter__ = AsyncMock( + mock_streamable_http_client.return_value.__aenter__ = AsyncMock( return_value=mock_transport ) @@ -121,23 +121,19 @@ class TestMCPClient: await client.run_with_session(_operation) # Verify streamablehttp_client was called - mock_streamablehttp_client.assert_called_once() - call_kwargs = mock_streamablehttp_client.call_args[1] + mock_streamable_http_client.assert_called_once() + call_kwargs = mock_streamable_http_client.call_args[1] + assert "http_client" in call_kwargs + http_client = call_kwargs["http_client"] + assert isinstance(http_client, httpx.AsyncClient) - # Verify httpx_client_factory was passed - assert "httpx_client_factory" in call_kwargs - httpx_factory = call_kwargs["httpx_client_factory"] - - # Test the factory creates a client with proper SSL config - # When SSL_CERT_FILE is set, the factory should use get_ssl_configuration + # Test the factory still creates a client with proper SSL config + httpx_factory = client._create_httpx_client_factory() test_client = httpx_factory(headers={"test": "header"}) - # Verify the client was created successfully with SSL configuration assert test_client is not None assert isinstance(test_client, httpx.AsyncClient) - # Verify it has the expected properties assert test_client.headers is not None - # Clean up await test_client.aclose() @pytest.mark.asyncio @@ -192,12 +188,12 @@ class TestMCPClient: await test_client.aclose() @pytest.mark.asyncio - @patch("litellm.experimental_mcp_client.client.streamablehttp_client") - async def test_mcp_client_ssl_verify_custom_path(self, mock_streamablehttp_client): + @patch("litellm.experimental_mcp_client.client.streamable_http_client") + async def test_mcp_client_ssl_verify_custom_path(self, mock_streamable_http_client): """Test that MCP client uses custom CA bundle path from ssl_verify parameter""" # Setup mocks mock_transport = (MagicMock(), MagicMock()) - mock_streamablehttp_client.return_value.__aenter__ = AsyncMock( + mock_streamable_http_client.return_value.__aenter__ = AsyncMock( return_value=mock_transport ) @@ -226,23 +222,18 @@ class TestMCPClient: await client.run_with_session(_operation) # Verify streamablehttp_client was called - mock_streamablehttp_client.assert_called_once() - call_kwargs = mock_streamablehttp_client.call_args[1] + mock_streamable_http_client.assert_called_once() + call_kwargs = mock_streamable_http_client.call_args[1] + assert "http_client" in call_kwargs + http_client = call_kwargs["http_client"] + assert isinstance(http_client, httpx.AsyncClient) - # Verify httpx_client_factory was passed - assert "httpx_client_factory" in call_kwargs - httpx_factory = call_kwargs["httpx_client_factory"] - - # Test the factory creates a client with custom CA bundle path - # When ssl_verify is a path, the factory should use that path for SSL verification + httpx_factory = client._create_httpx_client_factory() test_client = httpx_factory(headers={"test": "header"}) - # Verify the client was created successfully assert test_client is not None assert isinstance(test_client, httpx.AsyncClient) - # Verify it has the expected properties assert test_client.headers is not None - # Clean up await test_client.aclose() From e5bc2d31d0bd0e45959fb2d4524789e7f6172422 Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Tue, 20 Jan 2026 07:56:38 +0900 Subject: [PATCH 07/20] docs: mcp version up --- docs/my-website/docs/mcp.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/my-website/docs/mcp.md b/docs/my-website/docs/mcp.md index b7c1654dab4..d63b55ee29e 100644 --- a/docs/my-website/docs/mcp.md +++ b/docs/my-website/docs/mcp.md @@ -21,6 +21,11 @@ LiteLLM Proxy provides an MCP Gateway that allows you to use a fixed endpoint fo | Supported MCP Transports | • Streamable HTTP
• SSE
• Standard Input/Output (stdio) | | LiteLLM Permission Management | • By Key
• By Team
• By Organization | +:::caution MCP protocol update +Starting in LiteLLM v1.80.18, the LiteLLM MCP protocol version is `2025-11-25`.
+LiteLLM namespaces multiple MCP servers by prefixing each tool name with its MCP server name, so newly created servers now must use names that comply with SEP-986—noncompliant names cannot be added anymore. Existing servers that still violate SEP-986 only emit warnings today, but future MCP-side rollouts may block those names entirely, so we recommend updating any legacy server names proactively before MCP enforcement makes them unusable. +::: + ## Adding your MCP ### Prerequisites From 270b41b0f486adad81b7e1ddfa74c191a6d7b382 Mon Sep 17 00:00:00 2001 From: Alexsander Hamir Date: Mon, 19 Jan 2026 17:01:38 -0800 Subject: [PATCH 08/20] Simplify file comments (#19382) --- scripts/health_check/health_check_client.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/health_check/health_check_client.py b/scripts/health_check/health_check_client.py index 337c754a75c..4848735bb7b 100644 --- a/scripts/health_check/health_check_client.py +++ b/scripts/health_check/health_check_client.py @@ -3,8 +3,8 @@ LiteLLM Health Check Client A sentinel health check tool that tests all configured models on a LiteLLM proxy. -Similar to HRT's health check system, this script: -- Can read models from YAML config file (like HRT) or fetch from proxy API +This script: +- Can read models from YAML config file or fetch from proxy API - Sends a simple test request to each model concurrently - Reports health status for each model - Supports both chat/completion and embedding models From 97c09743c0eef7ab53082cde83b5c5e174815161 Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Tue, 20 Jan 2026 10:30:32 +0900 Subject: [PATCH 09/20] test: ci mcp version up --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index e03d1086282..c1da225addb 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1153,7 +1153,7 @@ jobs: pip install "pytest-asyncio==0.21.1" pip install "respx==0.22.0" pip install "pydantic==2.10.2" - pip install "mcp==1.21.2" + pip install "mcp==1.25.0" # Run pytest and generate JUnit XML report - run: name: Run tests From 738ffa7eec3c41aa89041449719cc1bc44e19475 Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Tue, 20 Jan 2026 10:35:46 +0900 Subject: [PATCH 10/20] test: ci mcp version up except mcp_testing --- .circleci/config.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index c1da225addb..e6c662eb4cd 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -45,7 +45,7 @@ commands: pip install "respx==0.22.0" pip install "hypercorn==0.17.3" pip install "pydantic==2.10.2" - pip install "mcp==1.10.1" + pip install "mcp==1.25.0" pip install "requests-mock>=1.12.1" pip install "responses==0.25.7" pip install "pytest-xdist==3.6.1" @@ -1557,7 +1557,7 @@ jobs: pip install "respx==0.22.0" pip install "hypercorn==0.17.3" pip install "pydantic==2.10.2" - pip install "mcp==1.10.1" + pip install "mcp==1.25.0" pip install "requests-mock>=1.12.1" pip install "responses==0.25.7" pip install "pytest-xdist==3.6.1" @@ -1915,7 +1915,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.10.1" + pip install "mcp==1.25.0" - run: name: Run tests command: | From b229410fb5ce78dbf4444db61c0b2347279c83a3 Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Tue, 20 Jan 2026 10:42:58 +0900 Subject: [PATCH 11/20] test: ci requirements mcp version up --- .circleci/requirements.txt | 2 +- .github/workflows/test-mcp.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/requirements.txt b/.circleci/requirements.txt index 2294c84813c..001d71ac547 100644 --- a/.circleci/requirements.txt +++ b/.circleci/requirements.txt @@ -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.10.1 # for MCP server +mcp==1.25.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 \ No newline at end of file diff --git a/.github/workflows/test-mcp.yml b/.github/workflows/test-mcp.yml index 64363c6f96d..aec45589e6c 100644 --- a/.github/workflows/test-mcp.yml +++ b/.github/workflows/test-mcp.yml @@ -35,7 +35,7 @@ jobs: poetry run pip install "pytest-asyncio==0.21.1" poetry run pip install "respx==0.22.0" poetry run pip install "pydantic==2.10.2" - poetry run pip install "mcp==1.10.1" + poetry run pip install "mcp==1.25.0" poetry run pip install pytest-xdist - name: Setup litellm-enterprise as local package From 7d7b78a53d7a04bcfea07519816a01bbd9332494 Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Tue, 20 Jan 2026 10:49:33 +0900 Subject: [PATCH 12/20] test: Pydantic version up mcp 1.25.0 depends on pydantic<3.0.0 and >=2.11.0 --- .circleci/config.yml | 6 +++--- .circleci/requirements.txt | 2 +- .github/workflows/test-mcp.yml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index e6c662eb4cd..02a9e3b0714 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -44,7 +44,7 @@ commands: pip install "pytest-asyncio==0.21.1" pip install "respx==0.22.0" pip install "hypercorn==0.17.3" - pip install "pydantic==2.10.2" + pip install "pydantic==2.11.0" pip install "mcp==1.25.0" pip install "requests-mock>=1.12.1" pip install "responses==0.25.7" @@ -1152,7 +1152,7 @@ jobs: pip install "pytest-cov==5.0.0" pip install "pytest-asyncio==0.21.1" pip install "respx==0.22.0" - pip install "pydantic==2.10.2" + pip install "pydantic==2.11.0" pip install "mcp==1.25.0" # Run pytest and generate JUnit XML report - run: @@ -1556,7 +1556,7 @@ jobs: pip install "pytest-asyncio==0.21.1" pip install "respx==0.22.0" pip install "hypercorn==0.17.3" - pip install "pydantic==2.10.2" + pip install "pydantic==2.11.0" pip install "mcp==1.25.0" pip install "requests-mock>=1.12.1" pip install "responses==0.25.7" diff --git a/.circleci/requirements.txt b/.circleci/requirements.txt index 001d71ac547..8c44dc18305 100644 --- a/.circleci/requirements.txt +++ b/.circleci/requirements.txt @@ -8,7 +8,7 @@ redis==5.2.1 redisvl==0.4.1 anthropic orjson==3.10.12 # fast /embedding responses -pydantic==2.10.2 +pydantic==2.11.0 google-cloud-aiplatform==1.43.0 google-cloud-iam==2.19.1 fastapi-sso==0.16.0 diff --git a/.github/workflows/test-mcp.yml b/.github/workflows/test-mcp.yml index aec45589e6c..e19e67c9c4f 100644 --- a/.github/workflows/test-mcp.yml +++ b/.github/workflows/test-mcp.yml @@ -34,7 +34,7 @@ jobs: poetry run pip install "pytest-cov==5.0.0" poetry run pip install "pytest-asyncio==0.21.1" poetry run pip install "respx==0.22.0" - poetry run pip install "pydantic==2.10.2" + poetry run pip install "pydantic==2.11.0" poetry run pip install "mcp==1.25.0" poetry run pip install pytest-xdist From 818913ee23100ca60210eaad33a6aacc6db60882 Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Mon, 19 Jan 2026 18:28:55 -0800 Subject: [PATCH 13/20] [Fix] Fix Pass through routes to work with server root path (#19383) * test_build_full_path_with_root_default * fix pt feat --- .../pass_through_endpoints.py | 29 +++- .../test_pass_through_endpoints.py | 149 +++++++++++++++++- 2 files changed, 173 insertions(+), 5 deletions(-) diff --git a/litellm/proxy/pass_through_endpoints/pass_through_endpoints.py b/litellm/proxy/pass_through_endpoints/pass_through_endpoints.py index 75d8253a904..996ee7412c9 100644 --- a/litellm/proxy/pass_through_endpoints/pass_through_endpoints.py +++ b/litellm/proxy/pass_through_endpoints/pass_through_endpoints.py @@ -51,6 +51,7 @@ from litellm.proxy._types import ( from litellm.proxy.auth.user_api_key_auth import user_api_key_auth from litellm.proxy.common_request_processing import ProxyBaseLLMRequestProcessing from litellm.proxy.common_utils.http_parsing_utils import _read_request_body +from litellm.proxy.utils import get_server_root_path from litellm.secret_managers.main import get_secret_str from litellm.types.llms.custom_http import httpxSpecialProvider from litellm.types.passthrough_endpoints.pass_through_endpoints import ( @@ -1973,10 +1974,26 @@ class InitPassThroughEndpointHelpers: _registered_pass_through_routes.clear() @staticmethod - def get_registered_pass_through_endpoints_keys() -> List[str]: + def get_all_registered_pass_through_routes() -> List[str]: """Get all registered pass-through endpoints from the registry""" return list(_registered_pass_through_routes.keys()) + @staticmethod + def _build_full_path_with_root(path: str) -> str: + """ + Build full path by prepending server root path if needed. + + Args: + path: The relative path to build + + Returns: + Full path with server root prepended (if root is not "/") + """ + root_path = get_server_root_path() + if root_path == "/": + return path + return f"{root_path}{path}" + @staticmethod def is_registered_pass_through_route(route: str) -> bool: """ @@ -2003,7 +2020,9 @@ class InitPassThroughEndpointHelpers: parts = key.split(":", 2) # Split into [endpoint_id, type, path] if len(parts) == 3: route_type = parts[1] - registered_path = parts[2] + registered_path = InitPassThroughEndpointHelpers._build_full_path_with_root( + parts[2] + ) if route_type == "exact" and route == registered_path: return True elif route_type == "subpath": @@ -2021,7 +2040,9 @@ class InitPassThroughEndpointHelpers: parts = key.split(":", 2) # Split into [endpoint_id, type, path] if len(parts) == 3: route_type = parts[1] - registered_path = parts[2] + registered_path = InitPassThroughEndpointHelpers._build_full_path_with_root( + parts[2] + ) if route_type == "exact" and route == registered_path: return _registered_pass_through_routes[key] @@ -2085,7 +2106,7 @@ async def initialize_pass_through_endpoints( # mark the ones that are visited in the list # remove the ones that are not visited from the list registered_pass_through_endpoints = ( - InitPassThroughEndpointHelpers.get_registered_pass_through_endpoints_keys() + InitPassThroughEndpointHelpers.get_all_registered_pass_through_routes() ) visited_endpoints = set() diff --git a/tests/test_litellm/proxy/pass_through_endpoints/test_pass_through_endpoints.py b/tests/test_litellm/proxy/pass_through_endpoints/test_pass_through_endpoints.py index c585089c7be..a39c95f7118 100644 --- a/tests/test_litellm/proxy/pass_through_endpoints/test_pass_through_endpoints.py +++ b/tests/test_litellm/proxy/pass_through_endpoints/test_pass_through_endpoints.py @@ -1897,8 +1897,8 @@ async def test_add_litellm_data_to_request_adds_headers_to_metadata(): The fix ensures headers are available in data["metadata"]["headers"] so guardrails can validate User-Agent, API keys, and other header-based checks. """ - from litellm.proxy.litellm_pre_call_utils import add_litellm_data_to_request from litellm.proxy._types import UserAPIKeyAuth + from litellm.proxy.litellm_pre_call_utils import add_litellm_data_to_request # Create mock request with headers including User-Agent mock_request = MagicMock(spec=Request) @@ -1954,3 +1954,150 @@ async def test_add_litellm_data_to_request_adds_headers_to_metadata(): # Also verify proxy_server_request has headers (original location) assert "proxy_server_request" in result assert "headers" in result["proxy_server_request"] + + +def test_build_full_path_with_root_default(): + """ + Test _build_full_path_with_root with default root path (/) + """ + from litellm.proxy.pass_through_endpoints.pass_through_endpoints import ( + InitPassThroughEndpointHelpers, + ) + + with patch("litellm.proxy.pass_through_endpoints.pass_through_endpoints.get_server_root_path") as mock_get_root: + # Test with default root path + mock_get_root.return_value = "/" + + result = InitPassThroughEndpointHelpers._build_full_path_with_root("/api/v1/endpoint") + assert result == "/api/v1/endpoint" + + +def test_build_full_path_with_root_custom(): + """ + Test _build_full_path_with_root with custom root path + """ + from litellm.proxy.pass_through_endpoints.pass_through_endpoints import ( + InitPassThroughEndpointHelpers, + ) + + with patch("litellm.proxy.pass_through_endpoints.pass_through_endpoints.get_server_root_path") as mock_get_root: + # Test with custom root path /proxy + mock_get_root.return_value = "/proxy" + + result = InitPassThroughEndpointHelpers._build_full_path_with_root("/api/v1/endpoint") + assert result == "/proxy/api/v1/endpoint" + + +def test_build_full_path_with_root_nested(): + """ + Test _build_full_path_with_root with nested root path + """ + from litellm.proxy.pass_through_endpoints.pass_through_endpoints import ( + InitPassThroughEndpointHelpers, + ) + + with patch("litellm.proxy.pass_through_endpoints.pass_through_endpoints.get_server_root_path") as mock_get_root: + # Test with nested root path /api/v2 + mock_get_root.return_value = "/api/v2" + + result = InitPassThroughEndpointHelpers._build_full_path_with_root("/endpoint") + assert result == "/api/v2/endpoint" + + +def test_is_registered_pass_through_route_with_custom_root(): + """ + Test is_registered_pass_through_route correctly handles server root path + + When server has a custom root path like /proxy, the registered path + should be constructed by prepending the root to match incoming routes. + """ + from litellm.proxy.pass_through_endpoints.pass_through_endpoints import ( + InitPassThroughEndpointHelpers, + _registered_pass_through_routes, + ) + + # Clear the registry first + _registered_pass_through_routes.clear() + + # Register a pass-through route with endpoint format: {endpoint_id}:exact:{path} + endpoint_id = "test-endpoint-123" + path = "/api/endpoint" + route_key = f"{endpoint_id}:exact:{path}" + _registered_pass_through_routes[route_key] = { + "target": "http://example.com", + "headers": {}, + } + + with patch("litellm.proxy.pass_through_endpoints.pass_through_endpoints.get_server_root_path") as mock_get_root: + # Test with custom root path /proxy + mock_get_root.return_value = "/proxy" + + # Should match when request route includes the root path + assert InitPassThroughEndpointHelpers.is_registered_pass_through_route("/proxy/api/endpoint") is True + + # Should not match when request route doesn't include root path + assert InitPassThroughEndpointHelpers.is_registered_pass_through_route("/api/endpoint") is False + + # Test with default root path + mock_get_root.return_value = "/" + + # Should match with default root + assert InitPassThroughEndpointHelpers.is_registered_pass_through_route("/api/endpoint") is True + + # Should not match with root prepended when root is / + assert InitPassThroughEndpointHelpers.is_registered_pass_through_route("/proxy/api/endpoint") is False + + # Clean up + _registered_pass_through_routes.clear() + + +def test_get_registered_pass_through_route_with_custom_root(): + """ + Test get_registered_pass_through_route correctly handles server root path + + When server has a custom root path, the method should return the correct + endpoint configuration by matching the full path including the root. + """ + from litellm.proxy.pass_through_endpoints.pass_through_endpoints import ( + InitPassThroughEndpointHelpers, + _registered_pass_through_routes, + ) + + # Clear the registry first + _registered_pass_through_routes.clear() + + # Register a pass-through route + endpoint_id = "test-endpoint-456" + path = "/chat/completions" + target_config = { + "target": "http://api.example.com/v1/chat/completions", + "headers": {"Authorization": "Bearer token123"}, + "forward_headers": True, + } + route_key = f"{endpoint_id}:exact:{path}" + _registered_pass_through_routes[route_key] = target_config + + with patch("litellm.proxy.pass_through_endpoints.pass_through_endpoints.get_server_root_path") as mock_get_root: + # Test with custom root path /litellm + mock_get_root.return_value = "/litellm" + + # Should return config when request route includes root path + result = InitPassThroughEndpointHelpers.get_registered_pass_through_route("/litellm/chat/completions") + assert result is not None + assert result["target"] == "http://api.example.com/v1/chat/completions" + assert result["headers"]["Authorization"] == "Bearer token123" + + # Should return None when route doesn't match + result = InitPassThroughEndpointHelpers.get_registered_pass_through_route("/chat/completions") + assert result is None + + # Test with default root path + mock_get_root.return_value = "/" + + # Should return config with default root + result = InitPassThroughEndpointHelpers.get_registered_pass_through_route("/chat/completions") + assert result is not None + assert result["target"] == "http://api.example.com/v1/chat/completions" + + # Clean up + _registered_pass_through_routes.clear() From d48df6c17d2e1c669e8a1c5412ed6f5a553ee8b8 Mon Sep 17 00:00:00 2001 From: Connor Luebbehusen Date: Mon, 19 Jan 2026 22:00:24 -0500 Subject: [PATCH 14/20] fix: correct us.anthropic.claude-opus-4-5 In-region pricing (#19310) --- litellm/model_prices_and_context_window_backup.json | 8 ++++---- model_prices_and_context_window.json | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/litellm/model_prices_and_context_window_backup.json b/litellm/model_prices_and_context_window_backup.json index 87f3566ae81..4599cafe708 100644 --- a/litellm/model_prices_and_context_window_backup.json +++ b/litellm/model_prices_and_context_window_backup.json @@ -26720,15 +26720,15 @@ "tool_use_system_prompt_tokens": 159 }, "us.anthropic.claude-opus-4-5-20251101-v1:0": { - "cache_creation_input_token_cost": 6.25e-06, - "cache_read_input_token_cost": 5e-07, - "input_cost_per_token": 5e-06, + "cache_creation_input_token_cost": 6.875e-06, + "cache_read_input_token_cost": 5.5e-07, + "input_cost_per_token": 5.5e-06, "litellm_provider": "bedrock_converse", "max_input_tokens": 200000, "max_output_tokens": 64000, "max_tokens": 64000, "mode": "chat", - "output_cost_per_token": 2.5e-05, + "output_cost_per_token": 2.75e-05, "search_context_cost_per_query": { "search_context_size_high": 0.01, "search_context_size_low": 0.01, diff --git a/model_prices_and_context_window.json b/model_prices_and_context_window.json index 87f3566ae81..4599cafe708 100644 --- a/model_prices_and_context_window.json +++ b/model_prices_and_context_window.json @@ -26720,15 +26720,15 @@ "tool_use_system_prompt_tokens": 159 }, "us.anthropic.claude-opus-4-5-20251101-v1:0": { - "cache_creation_input_token_cost": 6.25e-06, - "cache_read_input_token_cost": 5e-07, - "input_cost_per_token": 5e-06, + "cache_creation_input_token_cost": 6.875e-06, + "cache_read_input_token_cost": 5.5e-07, + "input_cost_per_token": 5.5e-06, "litellm_provider": "bedrock_converse", "max_input_tokens": 200000, "max_output_tokens": 64000, "max_tokens": 64000, "mode": "chat", - "output_cost_per_token": 2.5e-05, + "output_cost_per_token": 2.75e-05, "search_context_cost_per_query": { "search_context_size_high": 0.01, "search_context_size_low": 0.01, From 8c72cacaa4e69b14591caf646910726902f575cb Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Mon, 19 Jan 2026 19:08:59 -0800 Subject: [PATCH 15/20] [Feat] UI - Allow Adding Claude Code Plugins (#19387) * init schema * init endpoints * fix: claude_code_marketplace_router * refactor * fix: claude_code_marketplace_router * claude_code_marketplace_router * add netwroking methods * add plugin lefnat * add plugin form * add plugin on marketplace / ai hub * fix find mant bug * ui fix --- .../claude_code_marketplace.py | 27 +- litellm/types/proxy/claude_code_endpoints.py | 5 + .../app/(dashboard)/components/Sidebar2.tsx | 9 + .../experimental/claude-code-plugins/page.tsx | 17 + ui/litellm-dashboard/src/app/page.tsx | 3 + .../AIHub/ClaudeCodeMarketplaceTab.tsx | 162 ++++++++ .../src/components/AIHub/ModelHubTable.tsx | 9 +- .../AIHub/marketplace/PluginCard.tsx | 155 ++++++++ .../AIHub/marketplace_table_columns.tsx | 178 +++++++++ .../src/components/claude_code_plugins.tsx | 169 +++++++++ .../claude_code_plugins/add_plugin_form.tsx | 328 ++++++++++++++++ .../components/claude_code_plugins/helpers.ts | 264 +++++++++++++ .../claude_code_plugins/plugin_info.tsx | 350 +++++++++++++++++ .../claude_code_plugins/plugin_table.tsx | 351 ++++++++++++++++++ .../components/claude_code_plugins/types.ts | 113 ++++++ .../src/components/leftnav.tsx | 7 + .../src/components/networking.tsx | 275 ++++++++++++++ 17 files changed, 2414 insertions(+), 8 deletions(-) create mode 100644 ui/litellm-dashboard/src/app/(dashboard)/experimental/claude-code-plugins/page.tsx create mode 100644 ui/litellm-dashboard/src/components/AIHub/ClaudeCodeMarketplaceTab.tsx create mode 100644 ui/litellm-dashboard/src/components/AIHub/marketplace/PluginCard.tsx create mode 100644 ui/litellm-dashboard/src/components/AIHub/marketplace_table_columns.tsx create mode 100644 ui/litellm-dashboard/src/components/claude_code_plugins.tsx create mode 100644 ui/litellm-dashboard/src/components/claude_code_plugins/add_plugin_form.tsx create mode 100644 ui/litellm-dashboard/src/components/claude_code_plugins/helpers.ts create mode 100644 ui/litellm-dashboard/src/components/claude_code_plugins/plugin_info.tsx create mode 100644 ui/litellm-dashboard/src/components/claude_code_plugins/plugin_table.tsx create mode 100644 ui/litellm-dashboard/src/components/claude_code_plugins/types.ts diff --git a/litellm/proxy/anthropic_endpoints/claude_code_endpoints/claude_code_marketplace.py b/litellm/proxy/anthropic_endpoints/claude_code_endpoints/claude_code_marketplace.py index 7c212020a3d..ab3fa9010e2 100644 --- a/litellm/proxy/anthropic_endpoints/claude_code_endpoints/claude_code_marketplace.py +++ b/litellm/proxy/anthropic_endpoints/claude_code_endpoints/claude_code_marketplace.py @@ -310,24 +310,37 @@ async def list_plugins( where = {"enabled": True} if enabled_only else {} plugins = await prisma_client.db.litellm_claudecodeplugintable.find_many( - where=where, - order_by={"created_at": "desc"}, + where=where ) - return ListPluginsResponse( - plugins=[ + plugin_list = [] + for p in plugins: + # Parse manifest to get additional fields + manifest = json.loads(p.manifest_json) if p.manifest_json else {} + + plugin_list.append( PluginListItem( id=p.id, name=p.name, version=p.version, description=p.description, + source=manifest.get("source", {}), + author=manifest.get("author"), + homepage=manifest.get("homepage"), + keywords=manifest.get("keywords"), + category=manifest.get("category"), enabled=p.enabled, created_at=p.created_at.isoformat() if p.created_at else None, updated_at=p.updated_at.isoformat() if p.updated_at else None, ) - for p in plugins - ], - count=len(plugins), + ) + + # Sort by created_at descending (newest first) + plugin_list.sort(key=lambda x: x.created_at or "", reverse=True) + + return ListPluginsResponse( + plugins=plugin_list, + count=len(plugin_list), ) except HTTPException: diff --git a/litellm/types/proxy/claude_code_endpoints.py b/litellm/types/proxy/claude_code_endpoints.py index 663b182b805..033765527b2 100644 --- a/litellm/types/proxy/claude_code_endpoints.py +++ b/litellm/types/proxy/claude_code_endpoints.py @@ -76,6 +76,11 @@ class PluginListItem(BaseModel): name: str version: Optional[str] description: Optional[str] + source: Dict[str, str] + author: Optional[PluginAuthor] = None + homepage: Optional[str] = None + keywords: Optional[List[str]] = None + category: Optional[str] = None enabled: bool created_at: Optional[str] updated_at: Optional[str] diff --git a/ui/litellm-dashboard/src/app/(dashboard)/components/Sidebar2.tsx b/ui/litellm-dashboard/src/app/(dashboard)/components/Sidebar2.tsx index 06da61a3762..260cac16e02 100644 --- a/ui/litellm-dashboard/src/app/(dashboard)/components/Sidebar2.tsx +++ b/ui/litellm-dashboard/src/app/(dashboard)/components/Sidebar2.tsx @@ -120,6 +120,8 @@ const routeFor = (slug: string): string => { return "experimental/api-playground"; case "tag-management": return "experimental/tag-management"; + case "claude-code-plugins": + return "experimental/claude-code-plugins"; case "usage": // "Old Usage" return "experimental/old-usage"; @@ -257,6 +259,13 @@ const menuItems: MenuItemCfg[] = [ icon: , roles: all_admin_roles, }, + { + key: "27", + page: "claude-code-plugins", + label: "Claude Code Plugins", + icon: , + roles: all_admin_roles, + }, { key: "4", page: "usage", label: "Old Usage", icon: }, ], }, diff --git a/ui/litellm-dashboard/src/app/(dashboard)/experimental/claude-code-plugins/page.tsx b/ui/litellm-dashboard/src/app/(dashboard)/experimental/claude-code-plugins/page.tsx new file mode 100644 index 00000000000..c92c39639c6 --- /dev/null +++ b/ui/litellm-dashboard/src/app/(dashboard)/experimental/claude-code-plugins/page.tsx @@ -0,0 +1,17 @@ +"use client"; + +import ClaudeCodePluginsPanel from "@/components/claude_code_plugins"; +import useAuthorized from "@/app/(dashboard)/hooks/useAuthorized"; + +const ClaudeCodePluginsPage = () => { + const { accessToken, userRole } = useAuthorized(); + + return ( + + ); +}; + +export default ClaudeCodePluginsPage; diff --git a/ui/litellm-dashboard/src/app/page.tsx b/ui/litellm-dashboard/src/app/page.tsx index 8a56287e156..8ca25eb9e4c 100644 --- a/ui/litellm-dashboard/src/app/page.tsx +++ b/ui/litellm-dashboard/src/app/page.tsx @@ -8,6 +8,7 @@ import AdminPanel from "@/components/admins"; import AgentsPanel from "@/components/agents"; import BudgetPanel from "@/components/budgets/budget_panel"; import CacheDashboard from "@/components/cache_dashboard"; +import ClaudeCodePluginsPanel from "@/components/claude_code_plugins"; import { fetchTeams } from "@/components/common_components/fetch_teams"; import LoadingScreen from "@/components/common_components/LoadingScreen"; import { CostTrackingSettings } from "@/components/CostTrackingSettings"; @@ -530,6 +531,8 @@ export default function CreateKeyPage() { ) : page == "tag-management" ? ( + ) : page == "claude-code-plugins" ? ( + ) : page == "vector-stores" ? ( ) : page == "new_usage" ? ( diff --git a/ui/litellm-dashboard/src/components/AIHub/ClaudeCodeMarketplaceTab.tsx b/ui/litellm-dashboard/src/components/AIHub/ClaudeCodeMarketplaceTab.tsx new file mode 100644 index 00000000000..df022f4a749 --- /dev/null +++ b/ui/litellm-dashboard/src/components/AIHub/ClaudeCodeMarketplaceTab.tsx @@ -0,0 +1,162 @@ +import React, { useState, useEffect, useMemo } from "react"; +import { Input } from "antd"; +import { Card, TabGroup, TabList, Tab, TabPanels, TabPanel, Text } from "@tremor/react"; +import { SearchOutlined } from "@ant-design/icons"; +import { getClaudeCodeMarketplace } from "../networking"; +import { ModelDataTable } from "../model_dashboard/table"; +import { getMarketplaceTableColumns } from "./marketplace_table_columns"; +import NotificationsManager from "../molecules/notifications_manager"; +import { + MarketplaceResponse, + MarketplacePluginEntry, +} from "../claude_code_plugins/types"; +import { + extractCategories, + filterPluginsBySearch, + filterPluginsByCategory, +} from "../claude_code_plugins/helpers"; + +interface ClaudeCodeMarketplaceTabProps { + publicPage?: boolean; +} + +const ClaudeCodeMarketplaceTab: React.FC = ({ + publicPage = false, +}) => { + const [marketplaceData, setMarketplaceData] = + useState(null); + const [isLoading, setIsLoading] = useState(true); + const [searchTerm, setSearchTerm] = useState(""); + const [selectedCategoryIndex, setSelectedCategoryIndex] = useState(0); + + useEffect(() => { + fetchMarketplace(); + }, []); + + const fetchMarketplace = async () => { + setIsLoading(true); + try { + const data: MarketplaceResponse = await getClaudeCodeMarketplace(); + console.log("Claude Code marketplace:", data); + setMarketplaceData(data); + } catch (error) { + console.error("Error fetching marketplace:", error); + } finally { + setIsLoading(false); + } + }; + + const copyToClipboard = (text: string) => { + navigator.clipboard.writeText(text); + NotificationsManager.success("Copied to clipboard!"); + }; + + // Extract unique categories from plugins + const categories = useMemo(() => { + if (!marketplaceData) return ["All"]; + return extractCategories(marketplaceData.plugins); + }, [marketplaceData]); + + // Get selected category name + const selectedCategory = categories[selectedCategoryIndex] || "All"; + + // Filter plugins by search and category + const filteredPlugins = useMemo(() => { + if (!marketplaceData) return []; + + let plugins = marketplaceData.plugins; + + // Apply category filter + plugins = filterPluginsByCategory(plugins, selectedCategory); + + // Apply search filter + plugins = filterPluginsBySearch(plugins, searchTerm); + + return plugins; + }, [marketplaceData, selectedCategory, searchTerm]); + + const columns = useMemo( + () => getMarketplaceTableColumns(copyToClipboard, publicPage), + [publicPage] + ); + + if (!marketplaceData && !isLoading) { + return ( + +
+ + Failed to load marketplace. Please try again later. + +
+
+ ); + } + + return ( +
+ {/* Search Bar */} +
+ } + value={searchTerm} + onChange={(e) => setSearchTerm(e.target.value)} + allowClear + size="large" + /> +
+ + {/* Category Tabs */} + + + {categories.map((category) => { + // Count plugins in this category + const categoryPlugins = filterPluginsByCategory( + marketplaceData?.plugins || [], + category + ); + const count = filterPluginsBySearch( + categoryPlugins, + searchTerm + ).length; + + return ( + + {category} {count > 0 && `(${count})`} + + ); + })} + + + + {categories.map((category) => ( + + + {/* Plugin Table */} + + + + {/* Footer Info */} +
+ + Showing {filteredPlugins.length} of{" "} + {marketplaceData?.plugins.length || 0} plugin + {marketplaceData?.plugins.length !== 1 ? "s" : ""} + {searchTerm && ` matching "${searchTerm}"`} + {selectedCategory !== "All" && ` in ${selectedCategory}`} + +
+
+ ))} +
+
+
+ ); +}; + +export default ClaudeCodeMarketplaceTab; diff --git a/ui/litellm-dashboard/src/components/AIHub/ModelHubTable.tsx b/ui/litellm-dashboard/src/components/AIHub/ModelHubTable.tsx index 7c538b618f1..23bfb7d219f 100644 --- a/ui/litellm-dashboard/src/components/AIHub/ModelHubTable.tsx +++ b/ui/litellm-dashboard/src/components/AIHub/ModelHubTable.tsx @@ -5,6 +5,7 @@ import MakeModelPublicForm from "@/components/AIHub/forms/MakeModelPublicForm"; import { mcpHubColumns, MCPServerData } from "@/components/mcp_hub_table_columns"; import { modelHubColumns } from "@/components/model_hub_table_columns"; import UsefulLinksManagement from "@/components/AIHub/UsefulLinksManagement"; +import ClaudeCodeMarketplaceTab from "@/components/AIHub/ClaudeCodeMarketplaceTab"; import { ModelDataTable } from "@/components/model_dashboard/table"; import ModelFilters from "@/components/model_filters"; import NotificationsManager from "@/components/molecules/notifications_manager"; @@ -372,12 +373,13 @@ const ModelHubTable: React.FC = ({ accessToken, publicPage, )} - {/* Tab System for Model Hub, Agent Hub, and MCP Hub */} + {/* Tab System for Model Hub, Agent Hub, MCP Hub, and Plugin Marketplace */} Model Hub Agent Hub MCP Hub + Claude Code Plugin Marketplace @@ -462,6 +464,11 @@ const ModelHubTable: React.FC = ({ accessToken, publicPage, + + {/* Plugin Marketplace Tab */} + + + diff --git a/ui/litellm-dashboard/src/components/AIHub/marketplace/PluginCard.tsx b/ui/litellm-dashboard/src/components/AIHub/marketplace/PluginCard.tsx new file mode 100644 index 00000000000..d8111b2da07 --- /dev/null +++ b/ui/litellm-dashboard/src/components/AIHub/marketplace/PluginCard.tsx @@ -0,0 +1,155 @@ +import React from "react"; +import { Card, Badge, Button, Text } from "@tremor/react"; +import { Tooltip } from "antd"; +import { CopyOutlined, ExternalLinkIcon } from "@heroicons/react/outline"; +import { MarketplacePluginEntry } from "@/components/claude_code_plugins/types"; +import { + formatInstallCommand, + getCategoryBadgeColor, + getSourceLink, + truncateText, +} from "@/components/claude_code_plugins/helpers"; +import NotificationsManager from "@/components/molecules/notifications_manager"; + +interface PluginCardProps { + plugin: MarketplacePluginEntry; +} + +const PluginCard: React.FC = ({ plugin }) => { + const installCommand = formatInstallCommand(plugin); + const sourceLink = getSourceLink(plugin.source); + const categoryBadgeColor = getCategoryBadgeColor(plugin.category); + + const copyToClipboard = (text: string) => { + navigator.clipboard.writeText(text); + NotificationsManager.success("Install command copied!"); + }; + + // Limit keywords display to first 5 + const displayKeywords = plugin.keywords?.slice(0, 5) || []; + const remainingKeywords = (plugin.keywords?.length || 0) - 5; + + return ( + + {/* Header */} +
+
+
+

+ {plugin.name} +

+ {plugin.version && ( + + v{plugin.version} + + )} + {plugin.category && ( + + {plugin.category} + + )} +
+
+ {sourceLink && ( + + e.stopPropagation()} + > + + + + )} +
+ + {/* Description */} +
+ {plugin.description ? ( + + {plugin.description} + + ) : ( + + No description available + + )} +
+ + {/* Keywords */} + {displayKeywords.length > 0 && ( +
+ {displayKeywords.map((keyword, index) => ( + + {keyword} + + ))} + {remainingKeywords > 0 && ( + + +{remainingKeywords} more + + )} +
+ )} + + {/* Author */} + {plugin.author && ( +
+ + By {plugin.author.name} + {plugin.author.email && ` (${plugin.author.email})`} + +
+ )} + + {/* Homepage Link */} + {plugin.homepage && ( + + )} + + {/* Install Command */} +
+
+
+ Install command + + + {installCommand} + + +
+ +
+
+
+ ); +}; + +export default PluginCard; diff --git a/ui/litellm-dashboard/src/components/AIHub/marketplace_table_columns.tsx b/ui/litellm-dashboard/src/components/AIHub/marketplace_table_columns.tsx new file mode 100644 index 00000000000..ed17e84c23e --- /dev/null +++ b/ui/litellm-dashboard/src/components/AIHub/marketplace_table_columns.tsx @@ -0,0 +1,178 @@ +import { ColumnDef } from "@tanstack/react-table"; +import { Button, Badge, Text } from "@tremor/react"; +import { Tooltip } from "antd"; +import { CopyOutlined } from "@ant-design/icons"; +import { MarketplacePluginEntry } from "@/components/claude_code_plugins/types"; +import { + formatInstallCommand, + getCategoryBadgeColor, + getSourceDisplayText, +} from "@/components/claude_code_plugins/helpers"; + +export const getMarketplaceTableColumns = ( + copyToClipboard: (text: string) => void, + publicPage: boolean = false, +): ColumnDef[] => { + const allColumns: ColumnDef[] = [ + { + header: "Plugin Name", + accessorKey: "name", + enableSorting: true, + sortingFn: "alphanumeric", + cell: ({ row }) => { + const plugin = row.original; + const installCommand = formatInstallCommand(plugin); + + return ( +
+
+ {plugin.name} + + copyToClipboard(installCommand)} + className="cursor-pointer text-gray-500 hover:text-blue-500 text-xs" + /> + +
+ {/* Show description on mobile */} +
+ + {plugin.description || "No description"} + +
+
+ ); + }, + }, + { + header: "Description", + accessorKey: "description", + enableSorting: true, + sortingFn: "alphanumeric", + cell: ({ row }) => { + const plugin = row.original; + + return ( + + {plugin.description || "-"} + + ); + }, + meta: { + className: "hidden md:table-cell", + }, + }, + { + header: "Version", + accessorKey: "version", + enableSorting: true, + sortingFn: "alphanumeric", + cell: ({ row }) => { + const plugin = row.original; + + return plugin.version ? ( + + v{plugin.version} + + ) : ( + - + ); + }, + meta: { + className: "hidden lg:table-cell", + }, + }, + { + header: "Category", + accessorKey: "category", + enableSorting: true, + sortingFn: "alphanumeric", + cell: ({ row }) => { + const plugin = row.original; + const badgeColor = getCategoryBadgeColor(plugin.category); + + return plugin.category ? ( + + {plugin.category} + + ) : ( + + Uncategorized + + ); + }, + meta: { + className: "hidden lg:table-cell", + }, + }, + { + header: "Source", + accessorKey: "source", + enableSorting: false, + cell: ({ row }) => { + const plugin = row.original; + const sourceText = getSourceDisplayText(plugin.source); + + return {sourceText}; + }, + meta: { + className: "hidden xl:table-cell", + }, + }, + { + header: "Keywords", + accessorKey: "keywords", + enableSorting: false, + cell: ({ row }) => { + const plugin = row.original; + const keywords = plugin.keywords?.slice(0, 3) || []; + const remaining = (plugin.keywords?.length || 0) - 3; + + return ( +
+ {keywords.map((keyword, index) => ( + + {keyword} + + ))} + {remaining > 0 && ( + + +{remaining} + + )} +
+ ); + }, + meta: { + className: "hidden xl:table-cell", + }, + }, + { + header: "Install Command", + id: "install_command", + enableSorting: false, + cell: ({ row }) => { + const plugin = row.original; + const installCommand = formatInstallCommand(plugin); + + return ( +
+ + {installCommand} + + +
+ ); + }, + }, + ]; + + return allColumns; +}; diff --git a/ui/litellm-dashboard/src/components/claude_code_plugins.tsx b/ui/litellm-dashboard/src/components/claude_code_plugins.tsx new file mode 100644 index 00000000000..b2e66349a23 --- /dev/null +++ b/ui/litellm-dashboard/src/components/claude_code_plugins.tsx @@ -0,0 +1,169 @@ +import React, { useState, useEffect } from "react"; +import { Button } from "@tremor/react"; +import { Modal } from "antd"; +import { + getClaudeCodePluginsList, + deleteClaudeCodePlugin, +} from "./networking"; +import AddPluginForm from "./claude_code_plugins/add_plugin_form"; +import PluginTable from "./claude_code_plugins/plugin_table"; +import { isAdminRole } from "@/utils/roles"; +import PluginInfoView from "./claude_code_plugins/plugin_info"; +import NotificationsManager from "./molecules/notifications_manager"; +import { Plugin, ListPluginsResponse } from "./claude_code_plugins/types"; + +interface ClaudeCodePluginsPanelProps { + accessToken: string | null; + userRole?: string; +} + +const ClaudeCodePluginsPanel: React.FC = ({ + accessToken, + userRole, +}) => { + const [pluginsList, setPluginsList] = useState([]); + const [isAddModalVisible, setIsAddModalVisible] = useState(false); + const [isLoading, setIsLoading] = useState(false); + const [isDeleting, setIsDeleting] = useState(false); + const [pluginToDelete, setPluginToDelete] = useState<{ + name: string; + displayName: string; + } | null>(null); + const [selectedPluginId, setSelectedPluginId] = useState( + null + ); + + const isAdmin = userRole ? isAdminRole(userRole) : false; + + const fetchPlugins = async () => { + if (!accessToken) { + return; + } + + setIsLoading(true); + try { + const response: ListPluginsResponse = await getClaudeCodePluginsList( + accessToken, + false // Get all plugins (enabled and disabled) + ); + console.log(`Claude Code plugins: ${JSON.stringify(response)}`); + setPluginsList(response.plugins); + } catch (error) { + console.error("Error fetching Claude Code plugins:", error); + } finally { + setIsLoading(false); + } + }; + + useEffect(() => { + fetchPlugins(); + }, [accessToken]); + + const handleAddPlugin = () => { + if (selectedPluginId) { + setSelectedPluginId(null); + } + setIsAddModalVisible(true); + }; + + const handleCloseModal = () => { + setIsAddModalVisible(false); + }; + + const handleSuccess = () => { + fetchPlugins(); + }; + + const handleDeleteClick = (pluginName: string, displayName: string) => { + setPluginToDelete({ name: pluginName, displayName }); + }; + + const handleDeleteConfirm = async () => { + if (!pluginToDelete || !accessToken) return; + + setIsDeleting(true); + try { + await deleteClaudeCodePlugin(accessToken, pluginToDelete.name); + NotificationsManager.success( + `Plugin "${pluginToDelete.displayName}" deleted successfully` + ); + fetchPlugins(); + } catch (error) { + console.error("Error deleting plugin:", error); + NotificationsManager.error("Failed to delete plugin"); + } finally { + setIsDeleting(false); + setPluginToDelete(null); + } + }; + + const handleDeleteCancel = () => { + setPluginToDelete(null); + }; + + return ( +
+
+

Claude Code Plugins

+

+ Manage Claude Code marketplace plugins. Add, enable, disable, or + delete plugins that will be available in your marketplace catalog. + Enabled plugins will appear in the public marketplace at{" "} + /claude-code/marketplace.json. +

+
+ +
+
+ + {selectedPluginId ? ( + setSelectedPluginId(null)} + accessToken={accessToken} + isAdmin={isAdmin} + onPluginUpdated={fetchPlugins} + /> + ) : ( + setSelectedPluginId(id)} + /> + )} + + + + {pluginToDelete && ( + +

+ Are you sure you want to delete plugin:{" "} + {pluginToDelete.displayName}? +

+

This action cannot be undone.

+
+ )} +
+ ); +}; + +export default ClaudeCodePluginsPanel; diff --git a/ui/litellm-dashboard/src/components/claude_code_plugins/add_plugin_form.tsx b/ui/litellm-dashboard/src/components/claude_code_plugins/add_plugin_form.tsx new file mode 100644 index 00000000000..217851f128f --- /dev/null +++ b/ui/litellm-dashboard/src/components/claude_code_plugins/add_plugin_form.tsx @@ -0,0 +1,328 @@ +import React, { useState } from "react"; +import { Modal, Form, Input, Select, message } from "antd"; +import { Button } from "@tremor/react"; +import { registerClaudeCodePlugin } from "../networking"; +import { + validatePluginName, + isValidSemanticVersion, + isValidEmail, + isValidUrl, + parseKeywords, +} from "./helpers"; + +const { TextArea } = Input; +const { Option } = Select; + +interface AddPluginFormProps { + visible: boolean; + onClose: () => void; + accessToken: string | null; + onSuccess: () => void; +} + +const PREDEFINED_CATEGORIES = [ + "Development", + "Productivity", + "Learning", + "Security", + "Data & Analytics", + "Integration", + "Testing", + "Documentation", +]; + +const AddPluginForm: React.FC = ({ + visible, + onClose, + accessToken, + onSuccess, +}) => { + const [form] = Form.useForm(); + const [isSubmitting, setIsSubmitting] = useState(false); + const [sourceType, setSourceType] = useState<"github" | "url">("github"); + + const handleSubmit = async (values: any) => { + if (!accessToken) { + message.error("No access token available"); + return; + } + + // Validate plugin name + if (!validatePluginName(values.name)) { + message.error( + "Plugin name must be kebab-case (lowercase letters, numbers, and hyphens only)" + ); + return; + } + + // Validate semantic version if provided + if (values.version && !isValidSemanticVersion(values.version)) { + message.error( + "Version must be in semantic versioning format (e.g., 1.0.0)" + ); + return; + } + + // Validate email if provided + if (values.authorEmail && !isValidEmail(values.authorEmail)) { + message.error("Invalid email format"); + return; + } + + // Validate homepage URL if provided + if (values.homepage && !isValidUrl(values.homepage)) { + message.error("Invalid homepage URL format"); + return; + } + + setIsSubmitting(true); + try { + // Build plugin data + const pluginData: any = { + name: values.name.trim(), + source: + sourceType === "github" + ? { + source: "github", + repo: values.repo.trim(), + } + : { + source: "url", + url: values.url.trim(), + }, + }; + + // Add optional fields + if (values.version) { + pluginData.version = values.version.trim(); + } + if (values.description) { + pluginData.description = values.description.trim(); + } + if (values.authorName || values.authorEmail) { + pluginData.author = {}; + if (values.authorName) { + pluginData.author.name = values.authorName.trim(); + } + if (values.authorEmail) { + pluginData.author.email = values.authorEmail.trim(); + } + } + if (values.homepage) { + pluginData.homepage = values.homepage.trim(); + } + if (values.category) { + pluginData.category = values.category; + } + if (values.keywords) { + pluginData.keywords = parseKeywords(values.keywords); + } + + await registerClaudeCodePlugin(accessToken, pluginData); + message.success("Plugin registered successfully"); + form.resetFields(); + setSourceType("github"); + onSuccess(); + onClose(); + } catch (error) { + console.error("Error registering plugin:", error); + message.error("Failed to register plugin"); + } finally { + setIsSubmitting(false); + } + }; + + const handleCancel = () => { + form.resetFields(); + setSourceType("github"); + onClose(); + }; + + const handleSourceTypeChange = (value: "github" | "url") => { + setSourceType(value); + // Clear repo/url fields when switching + form.setFieldsValue({ repo: undefined, url: undefined }); + }; + + return ( + +
+ {/* Plugin Name */} + + + + + {/* Source Type */} + + + + + {/* GitHub Repository */} + {sourceType === "github" && ( + + + + )} + + {/* Git URL */} + {sourceType === "url" && ( + + + + )} + + {/* Version */} + + + + + {/* Description */} + +