[Bugfix] Support MCP SDK 2.x tool input schemas (#53870)
Signed-off-by: chaunceyjiang <chaunceyjiang@gmail.com>
This commit is contained in:
@@ -51,7 +51,7 @@ setproctitle # Used to set process names for better debugging and monitoring
|
|||||||
openai-harmony >= 0.0.3 # Required for gpt-oss
|
openai-harmony >= 0.0.3 # Required for gpt-oss
|
||||||
anthropic >= 0.71.0
|
anthropic >= 0.71.0
|
||||||
model-hosting-container-standards >= 0.1.14, < 1.0.0
|
model-hosting-container-standards >= 0.1.14, < 1.0.0
|
||||||
mcp
|
mcp >= 2.0.0, < 3.0.0
|
||||||
opentelemetry-sdk >= 1.27.0
|
opentelemetry-sdk >= 1.27.0
|
||||||
opentelemetry-api >= 1.27.0
|
opentelemetry-api >= 1.27.0
|
||||||
opentelemetry-exporter-otlp >= 1.27.0
|
opentelemetry-exporter-otlp >= 1.27.0
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ anyio==4.14.1
|
|||||||
# via
|
# via
|
||||||
# anthropic
|
# anthropic
|
||||||
# httpx
|
# httpx
|
||||||
|
# httpx2
|
||||||
# mcp
|
# mcp
|
||||||
# openai
|
# openai
|
||||||
# sse-starlette
|
# sse-starlette
|
||||||
@@ -304,9 +305,10 @@ grpcio==1.78.0
|
|||||||
# ray
|
# ray
|
||||||
grpcio-reflection==1.78.0
|
grpcio-reflection==1.78.0
|
||||||
# via -r requirements/test/cuda.in
|
# via -r requirements/test/cuda.in
|
||||||
h11==0.14.0
|
h11==0.16.0
|
||||||
# via
|
# via
|
||||||
# httpcore
|
# httpcore
|
||||||
|
# httpcore2
|
||||||
# uvicorn
|
# uvicorn
|
||||||
h2==4.3.0
|
h2==4.3.0
|
||||||
# via httpx
|
# via httpx
|
||||||
@@ -320,8 +322,10 @@ hpack==4.1.0
|
|||||||
# via h2
|
# via h2
|
||||||
html2text==2025.4.15
|
html2text==2025.4.15
|
||||||
# via gpt-oss
|
# via gpt-oss
|
||||||
httpcore==1.0.6
|
httpcore==1.0.9
|
||||||
# via httpx
|
# via httpx
|
||||||
|
httpcore2==2.12.0
|
||||||
|
# via httpx2
|
||||||
httptools==0.8.0
|
httptools==0.8.0
|
||||||
# via uvicorn
|
# via uvicorn
|
||||||
httpx==0.27.2
|
httpx==0.27.2
|
||||||
@@ -332,12 +336,11 @@ httpx==0.27.2
|
|||||||
# fastapi
|
# fastapi
|
||||||
# fastapi-cloud-cli
|
# fastapi-cloud-cli
|
||||||
# huggingface-hub
|
# huggingface-hub
|
||||||
# mcp
|
|
||||||
# model-hosting-container-standards
|
# model-hosting-container-standards
|
||||||
# openai
|
# openai
|
||||||
# perceptron
|
# perceptron
|
||||||
# schemathesis
|
# schemathesis
|
||||||
httpx-sse==0.4.3
|
httpx2==2.12.0
|
||||||
# via mcp
|
# via mcp
|
||||||
huggingface-hub==1.28.0
|
huggingface-hub==1.28.0
|
||||||
# via
|
# via
|
||||||
@@ -366,11 +369,12 @@ hypothesis-graphql==0.13.0
|
|||||||
# via schemathesis
|
# via schemathesis
|
||||||
hypothesis-jsonschema==0.23.1
|
hypothesis-jsonschema==0.23.1
|
||||||
# via schemathesis
|
# via schemathesis
|
||||||
idna==3.10
|
idna==3.19
|
||||||
# via
|
# via
|
||||||
# anyio
|
# anyio
|
||||||
# email-validator
|
# email-validator
|
||||||
# httpx
|
# httpx
|
||||||
|
# httpx2
|
||||||
# requests
|
# requests
|
||||||
# yarl
|
# yarl
|
||||||
ijson==3.5.0
|
ijson==3.5.0
|
||||||
@@ -476,8 +480,10 @@ mbstrdecoder==1.1.3
|
|||||||
# dataproperty
|
# dataproperty
|
||||||
# pytablewriter
|
# pytablewriter
|
||||||
# typepy
|
# typepy
|
||||||
mcp==1.28.1
|
mcp==2.1.1
|
||||||
# via -r requirements/test/../common.txt
|
# via -r requirements/test/../common.txt
|
||||||
|
mcp-types==2.1.1
|
||||||
|
# via mcp
|
||||||
mdurl==0.1.2
|
mdurl==0.1.2
|
||||||
# via markdown-it-py
|
# via markdown-it-py
|
||||||
mistral-common==1.11.6
|
mistral-common==1.11.6
|
||||||
@@ -596,6 +602,7 @@ openpyxl==3.1.5
|
|||||||
opentelemetry-api==1.35.0
|
opentelemetry-api==1.35.0
|
||||||
# via
|
# via
|
||||||
# -r requirements/test/../common.txt
|
# -r requirements/test/../common.txt
|
||||||
|
# mcp
|
||||||
# opentelemetry-exporter-otlp-proto-grpc
|
# opentelemetry-exporter-otlp-proto-grpc
|
||||||
# opentelemetry-exporter-otlp-proto-http
|
# opentelemetry-exporter-otlp-proto-http
|
||||||
# opentelemetry-exporter-prometheus
|
# opentelemetry-exporter-prometheus
|
||||||
@@ -782,6 +789,7 @@ pydantic==2.12.0
|
|||||||
# gpt-oss
|
# gpt-oss
|
||||||
# lm-format-enforcer
|
# lm-format-enforcer
|
||||||
# mcp
|
# mcp
|
||||||
|
# mcp-types
|
||||||
# mistral-common
|
# mistral-common
|
||||||
# model-hosting-container-standards
|
# model-hosting-container-standards
|
||||||
# mteb
|
# mteb
|
||||||
@@ -800,9 +808,7 @@ pydantic-extra-types==2.10.5
|
|||||||
# fastapi
|
# fastapi
|
||||||
# mistral-common
|
# mistral-common
|
||||||
pydantic-settings==2.14.2
|
pydantic-settings==2.14.2
|
||||||
# via
|
# via fastapi
|
||||||
# fastapi
|
|
||||||
# mcp
|
|
||||||
pygments==2.18.0
|
pygments==2.18.0
|
||||||
# via
|
# via
|
||||||
# pytest
|
# pytest
|
||||||
@@ -1185,6 +1191,10 @@ triton==3.6.0
|
|||||||
# via xgrammar
|
# via xgrammar
|
||||||
tritonclient==2.64.0
|
tritonclient==2.64.0
|
||||||
# via -r requirements/test/cuda.in
|
# via -r requirements/test/cuda.in
|
||||||
|
truststore==0.10.4
|
||||||
|
# via
|
||||||
|
# httpcore2
|
||||||
|
# httpx2
|
||||||
typepy==1.3.2
|
typepy==1.3.2
|
||||||
# via
|
# via
|
||||||
# dataproperty
|
# dataproperty
|
||||||
@@ -1215,10 +1225,12 @@ typing-extensions==4.15.0
|
|||||||
# cohere
|
# cohere
|
||||||
# fastapi
|
# fastapi
|
||||||
# grpcio
|
# grpcio
|
||||||
|
# httpx2
|
||||||
# huggingface-hub
|
# huggingface-hub
|
||||||
# librosa
|
# librosa
|
||||||
# lm-eval
|
# lm-eval
|
||||||
# mcp
|
# mcp
|
||||||
|
# mcp-types
|
||||||
# mistral-common
|
# mistral-common
|
||||||
# mteb
|
# mteb
|
||||||
# openai
|
# openai
|
||||||
|
|||||||
+24
-10
@@ -40,6 +40,7 @@ anyio==4.14.1
|
|||||||
# via
|
# via
|
||||||
# anthropic
|
# anthropic
|
||||||
# httpx
|
# httpx
|
||||||
|
# httpx2
|
||||||
# mcp
|
# mcp
|
||||||
# openai
|
# openai
|
||||||
# sse-starlette
|
# sse-starlette
|
||||||
@@ -323,9 +324,10 @@ grpcio==1.78.0
|
|||||||
# ray
|
# ray
|
||||||
grpcio-reflection==1.78.0
|
grpcio-reflection==1.78.0
|
||||||
# via -r requirements/test/cuda.in
|
# via -r requirements/test/cuda.in
|
||||||
h11==0.14.0
|
h11==0.16.0
|
||||||
# via
|
# via
|
||||||
# httpcore
|
# httpcore
|
||||||
|
# httpcore2
|
||||||
# uvicorn
|
# uvicorn
|
||||||
h2==4.3.0
|
h2==4.3.0
|
||||||
# via httpx
|
# via httpx
|
||||||
@@ -339,8 +341,10 @@ hpack==4.1.0
|
|||||||
# via h2
|
# via h2
|
||||||
html2text==2025.4.15
|
html2text==2025.4.15
|
||||||
# via gpt-oss
|
# via gpt-oss
|
||||||
httpcore==1.0.6
|
httpcore==1.0.9
|
||||||
# via httpx
|
# via httpx
|
||||||
|
httpcore2==2.12.0
|
||||||
|
# via httpx2
|
||||||
httptools==0.8.0
|
httptools==0.8.0
|
||||||
# via uvicorn
|
# via uvicorn
|
||||||
httpx==0.27.2
|
httpx==0.27.2
|
||||||
@@ -351,12 +355,11 @@ httpx==0.27.2
|
|||||||
# fastapi
|
# fastapi
|
||||||
# fastapi-cloud-cli
|
# fastapi-cloud-cli
|
||||||
# huggingface-hub
|
# huggingface-hub
|
||||||
# mcp
|
|
||||||
# model-hosting-container-standards
|
# model-hosting-container-standards
|
||||||
# openai
|
# openai
|
||||||
# perceptron
|
# perceptron
|
||||||
# schemathesis
|
# schemathesis
|
||||||
httpx-sse==0.4.3
|
httpx2==2.12.0
|
||||||
# via mcp
|
# via mcp
|
||||||
huggingface-hub==1.28.0
|
huggingface-hub==1.28.0
|
||||||
# via
|
# via
|
||||||
@@ -386,11 +389,12 @@ hypothesis-graphql==0.13.0
|
|||||||
# via schemathesis
|
# via schemathesis
|
||||||
hypothesis-jsonschema==0.23.1
|
hypothesis-jsonschema==0.23.1
|
||||||
# via schemathesis
|
# via schemathesis
|
||||||
idna==3.10
|
idna==3.19
|
||||||
# via
|
# via
|
||||||
# anyio
|
# anyio
|
||||||
# email-validator
|
# email-validator
|
||||||
# httpx
|
# httpx
|
||||||
|
# httpx2
|
||||||
# requests
|
# requests
|
||||||
# yarl
|
# yarl
|
||||||
ijson==3.5.0
|
ijson==3.5.0
|
||||||
@@ -505,8 +509,12 @@ mbstrdecoder==1.1.3
|
|||||||
# dataproperty
|
# dataproperty
|
||||||
# pytablewriter
|
# pytablewriter
|
||||||
# typepy
|
# typepy
|
||||||
mcp==1.28.1
|
mcp==2.1.1
|
||||||
# via -r requirements/test/../common.txt
|
# via
|
||||||
|
# -c requirements/common.txt
|
||||||
|
# -r requirements/test/../common.txt
|
||||||
|
mcp-types==2.1.1
|
||||||
|
# via mcp
|
||||||
mdurl==0.1.2
|
mdurl==0.1.2
|
||||||
# via markdown-it-py
|
# via markdown-it-py
|
||||||
mistral-common==1.11.6
|
mistral-common==1.11.6
|
||||||
@@ -675,6 +683,7 @@ opentelemetry-api==1.35.0
|
|||||||
# via
|
# via
|
||||||
# -c requirements/common.txt
|
# -c requirements/common.txt
|
||||||
# -r requirements/test/../common.txt
|
# -r requirements/test/../common.txt
|
||||||
|
# mcp
|
||||||
# opentelemetry-exporter-otlp-proto-grpc
|
# opentelemetry-exporter-otlp-proto-grpc
|
||||||
# opentelemetry-exporter-otlp-proto-http
|
# opentelemetry-exporter-otlp-proto-http
|
||||||
# opentelemetry-exporter-prometheus
|
# opentelemetry-exporter-prometheus
|
||||||
@@ -873,6 +882,7 @@ pydantic==2.12.0
|
|||||||
# gpt-oss
|
# gpt-oss
|
||||||
# lm-format-enforcer
|
# lm-format-enforcer
|
||||||
# mcp
|
# mcp
|
||||||
|
# mcp-types
|
||||||
# mistral-common
|
# mistral-common
|
||||||
# model-hosting-container-standards
|
# model-hosting-container-standards
|
||||||
# mteb
|
# mteb
|
||||||
@@ -891,9 +901,7 @@ pydantic-extra-types==2.10.5
|
|||||||
# fastapi
|
# fastapi
|
||||||
# mistral-common
|
# mistral-common
|
||||||
pydantic-settings==2.14.2
|
pydantic-settings==2.14.2
|
||||||
# via
|
# via fastapi
|
||||||
# fastapi
|
|
||||||
# mcp
|
|
||||||
pygments==2.18.0
|
pygments==2.18.0
|
||||||
# via
|
# via
|
||||||
# pytest
|
# pytest
|
||||||
@@ -1293,6 +1301,10 @@ triton==3.7.1
|
|||||||
# xgrammar
|
# xgrammar
|
||||||
tritonclient==2.64.0
|
tritonclient==2.64.0
|
||||||
# via -r requirements/test/cuda.in
|
# via -r requirements/test/cuda.in
|
||||||
|
truststore==0.10.4
|
||||||
|
# via
|
||||||
|
# httpcore2
|
||||||
|
# httpx2
|
||||||
typepy==1.3.2
|
typepy==1.3.2
|
||||||
# via
|
# via
|
||||||
# dataproperty
|
# dataproperty
|
||||||
@@ -1324,10 +1336,12 @@ typing-extensions==4.15.0
|
|||||||
# cohere
|
# cohere
|
||||||
# fastapi
|
# fastapi
|
||||||
# grpcio
|
# grpcio
|
||||||
|
# httpx2
|
||||||
# huggingface-hub
|
# huggingface-hub
|
||||||
# librosa
|
# librosa
|
||||||
# lm-eval
|
# lm-eval
|
||||||
# mcp
|
# mcp
|
||||||
|
# mcp-types
|
||||||
# mistral-common
|
# mistral-common
|
||||||
# mteb
|
# mteb
|
||||||
# openai
|
# openai
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ anyio==4.13.0
|
|||||||
# via
|
# via
|
||||||
# anthropic
|
# anthropic
|
||||||
# httpx
|
# httpx
|
||||||
|
# httpx2
|
||||||
# mcp
|
# mcp
|
||||||
# openai
|
# openai
|
||||||
# sse-starlette
|
# sse-starlette
|
||||||
@@ -319,6 +320,7 @@ grpcio-reflection==1.78.0
|
|||||||
h11==0.16.0
|
h11==0.16.0
|
||||||
# via
|
# via
|
||||||
# httpcore
|
# httpcore
|
||||||
|
# httpcore2
|
||||||
# uvicorn
|
# uvicorn
|
||||||
h2==4.3.0
|
h2==4.3.0
|
||||||
# via httpx
|
# via httpx
|
||||||
@@ -334,6 +336,8 @@ html2text==2025.4.15
|
|||||||
# via gpt-oss
|
# via gpt-oss
|
||||||
httpcore==1.0.9
|
httpcore==1.0.9
|
||||||
# via httpx
|
# via httpx
|
||||||
|
httpcore2==2.12.0
|
||||||
|
# via httpx2
|
||||||
httptools==0.7.1
|
httptools==0.7.1
|
||||||
# via uvicorn
|
# via uvicorn
|
||||||
httpx==0.27.2
|
httpx==0.27.2
|
||||||
@@ -344,12 +348,11 @@ httpx==0.27.2
|
|||||||
# fastapi
|
# fastapi
|
||||||
# fastapi-cloud-cli
|
# fastapi-cloud-cli
|
||||||
# huggingface-hub
|
# huggingface-hub
|
||||||
# mcp
|
|
||||||
# model-hosting-container-standards
|
# model-hosting-container-standards
|
||||||
# openai
|
# openai
|
||||||
# perceptron
|
# perceptron
|
||||||
# schemathesis
|
# schemathesis
|
||||||
httpx-sse==0.4.3
|
httpx2==2.12.0
|
||||||
# via mcp
|
# via mcp
|
||||||
huggingface-hub==1.28.0
|
huggingface-hub==1.28.0
|
||||||
# via
|
# via
|
||||||
@@ -379,11 +382,12 @@ hypothesis-graphql==0.13.0
|
|||||||
# via schemathesis
|
# via schemathesis
|
||||||
hypothesis-jsonschema==0.23.1
|
hypothesis-jsonschema==0.23.1
|
||||||
# via schemathesis
|
# via schemathesis
|
||||||
idna==3.11
|
idna==3.19
|
||||||
# via
|
# via
|
||||||
# anyio
|
# anyio
|
||||||
# email-validator
|
# email-validator
|
||||||
# httpx
|
# httpx
|
||||||
|
# httpx2
|
||||||
# requests
|
# requests
|
||||||
# yarl
|
# yarl
|
||||||
ijson==3.5.0
|
ijson==3.5.0
|
||||||
@@ -500,8 +504,12 @@ mbstrdecoder==1.1.4
|
|||||||
# dataproperty
|
# dataproperty
|
||||||
# pytablewriter
|
# pytablewriter
|
||||||
# typepy
|
# typepy
|
||||||
mcp==1.27.0
|
mcp==2.1.1
|
||||||
# via -r requirements/test/../common.txt
|
# via
|
||||||
|
# -c requirements/common.txt
|
||||||
|
# -r requirements/test/../common.txt
|
||||||
|
mcp-types==2.1.1
|
||||||
|
# via mcp
|
||||||
mdurl==0.1.2
|
mdurl==0.1.2
|
||||||
# via markdown-it-py
|
# via markdown-it-py
|
||||||
mistral-common==1.11.6
|
mistral-common==1.11.6
|
||||||
@@ -642,6 +650,7 @@ opentelemetry-api==1.40.0
|
|||||||
# via
|
# via
|
||||||
# -c requirements/common.txt
|
# -c requirements/common.txt
|
||||||
# -r requirements/test/../common.txt
|
# -r requirements/test/../common.txt
|
||||||
|
# mcp
|
||||||
# opentelemetry-exporter-otlp-proto-grpc
|
# opentelemetry-exporter-otlp-proto-grpc
|
||||||
# opentelemetry-exporter-otlp-proto-http
|
# opentelemetry-exporter-otlp-proto-http
|
||||||
# opentelemetry-exporter-prometheus
|
# opentelemetry-exporter-prometheus
|
||||||
@@ -847,6 +856,7 @@ pydantic==2.12.5
|
|||||||
# gpt-oss
|
# gpt-oss
|
||||||
# lm-format-enforcer
|
# lm-format-enforcer
|
||||||
# mcp
|
# mcp
|
||||||
|
# mcp-types
|
||||||
# mistral-common
|
# mistral-common
|
||||||
# model-hosting-container-standards
|
# model-hosting-container-standards
|
||||||
# mteb
|
# mteb
|
||||||
@@ -865,9 +875,7 @@ pydantic-extra-types==2.11.1
|
|||||||
# fastapi
|
# fastapi
|
||||||
# mistral-common
|
# mistral-common
|
||||||
pydantic-settings==2.13.1
|
pydantic-settings==2.13.1
|
||||||
# via
|
# via fastapi
|
||||||
# fastapi
|
|
||||||
# mcp
|
|
||||||
pygments==2.19.2
|
pygments==2.19.2
|
||||||
# via
|
# via
|
||||||
# pytest
|
# pytest
|
||||||
@@ -1241,6 +1249,10 @@ transformers-stream-generator==0.0.5
|
|||||||
# via -r requirements/test/rocm.in
|
# via -r requirements/test/rocm.in
|
||||||
tritonclient==2.66.0
|
tritonclient==2.66.0
|
||||||
# via -r requirements/test/rocm.in
|
# via -r requirements/test/rocm.in
|
||||||
|
truststore==0.10.4
|
||||||
|
# via
|
||||||
|
# httpcore2
|
||||||
|
# httpx2
|
||||||
typeguard==4.5.1
|
typeguard==4.5.1
|
||||||
# via inflect
|
# via inflect
|
||||||
typepy==1.3.4
|
typepy==1.3.4
|
||||||
@@ -1274,10 +1286,12 @@ typing-extensions==4.15.0
|
|||||||
# cohere
|
# cohere
|
||||||
# fastapi
|
# fastapi
|
||||||
# grpcio
|
# grpcio
|
||||||
|
# httpx2
|
||||||
# huggingface-hub
|
# huggingface-hub
|
||||||
# librosa
|
# librosa
|
||||||
# lm-eval
|
# lm-eval
|
||||||
# mcp
|
# mcp
|
||||||
|
# mcp-types
|
||||||
# mistral-common
|
# mistral-common
|
||||||
# mteb
|
# mteb
|
||||||
# openai
|
# openai
|
||||||
|
|||||||
@@ -375,9 +375,11 @@ mbstrdecoder==1.1.5
|
|||||||
# dataproperty
|
# dataproperty
|
||||||
# pytablewriter
|
# pytablewriter
|
||||||
# typepy
|
# typepy
|
||||||
mcp==2.0.0
|
mcp==2.1.1
|
||||||
# via -r requirements/test/../common.txt
|
# via
|
||||||
mcp-types==2.0.0
|
# -c requirements/common.txt
|
||||||
|
# -r requirements/test/../common.txt
|
||||||
|
mcp-types==2.1.1
|
||||||
# via mcp
|
# via mcp
|
||||||
mdurl==0.1.2
|
mdurl==0.1.2
|
||||||
# via markdown-it-py
|
# via markdown-it-py
|
||||||
|
|||||||
@@ -10,7 +10,10 @@ from openai import OpenAI
|
|||||||
from openai_harmony import Message, ToolDescription, ToolNamespaceConfig
|
from openai_harmony import Message, ToolDescription, ToolNamespaceConfig
|
||||||
|
|
||||||
from tests.utils import RemoteOpenAIServer
|
from tests.utils import RemoteOpenAIServer
|
||||||
from vllm.entrypoints.mcp.tool_server import MCPToolServer
|
from vllm.entrypoints.mcp.tool_server import (
|
||||||
|
MCPToolServer,
|
||||||
|
post_process_tools_description,
|
||||||
|
)
|
||||||
|
|
||||||
from .conftest import (
|
from .conftest import (
|
||||||
BASE_TEST_ENV,
|
BASE_TEST_ENV,
|
||||||
@@ -36,8 +39,9 @@ _PYTHON_TOOL_INSTRUCTION = (
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.skip_global_cleanup
|
||||||
class TestMCPToolServerUnit:
|
class TestMCPToolServerUnit:
|
||||||
"""Test MCPToolServer.get_tool_description filtering logic.
|
"""Test MCP tool description processing and filtering.
|
||||||
|
|
||||||
Note: The wildcard "*" is normalized to None by
|
Note: The wildcard "*" is normalized to None by
|
||||||
_extract_allowed_tools_from_mcp_requests before reaching this layer,
|
_extract_allowed_tools_from_mcp_requests before reaching this layer,
|
||||||
@@ -96,6 +100,41 @@ class TestMCPToolServerUnit:
|
|||||||
# Empty list - returns None
|
# Empty list - returns None
|
||||||
assert server.get_tool_description("test_server", allowed_tools=[]) is None
|
assert server.get_tool_description("test_server", allowed_tools=[]) is None
|
||||||
|
|
||||||
|
def test_post_process_tools_description_uses_trim_schema_result(self, monkeypatch):
|
||||||
|
mcp_types = pytest.importorskip("mcp.types")
|
||||||
|
tool = mcp_types.Tool(
|
||||||
|
name="tool",
|
||||||
|
input_schema={"type": "object"},
|
||||||
|
)
|
||||||
|
result = mcp_types.ListToolsResult(tools=[tool])
|
||||||
|
trimmed_schema = {"type": "object", "properties": {}}
|
||||||
|
|
||||||
|
monkeypatch.setattr(
|
||||||
|
"vllm.entrypoints.mcp.tool_server.trim_schema",
|
||||||
|
lambda _schema: trimmed_schema,
|
||||||
|
)
|
||||||
|
|
||||||
|
post_process_tools_description(result)
|
||||||
|
|
||||||
|
assert tool.input_schema is trimmed_schema
|
||||||
|
|
||||||
|
def test_post_process_tools_description_honors_meta_opt_out(self):
|
||||||
|
mcp_types = pytest.importorskip("mcp.types")
|
||||||
|
included = mcp_types.Tool(
|
||||||
|
name="included",
|
||||||
|
input_schema={"type": "object"},
|
||||||
|
)
|
||||||
|
excluded = mcp_types.Tool(
|
||||||
|
name="excluded",
|
||||||
|
input_schema={"type": "object"},
|
||||||
|
meta={"include_in_prompt": False},
|
||||||
|
)
|
||||||
|
result = mcp_types.ListToolsResult(tools=[included, excluded])
|
||||||
|
|
||||||
|
post_process_tools_description(result)
|
||||||
|
|
||||||
|
assert result.tools == [included]
|
||||||
|
|
||||||
def test_builtin_tools_consistency(self):
|
def test_builtin_tools_consistency(self):
|
||||||
"""MCP_BUILTIN_TOOLS must match BUILTIN_TOOL_TO_MCP_SERVER_LABEL values."""
|
"""MCP_BUILTIN_TOOLS must match BUILTIN_TOOL_TO_MCP_SERVER_LABEL values."""
|
||||||
from vllm.entrypoints.openai.parser.harmony_utils import (
|
from vllm.entrypoints.openai.parser.harmony_utils import (
|
||||||
|
|||||||
@@ -58,14 +58,14 @@ def post_process_tools_description(
|
|||||||
) -> "ListToolsResult":
|
) -> "ListToolsResult":
|
||||||
# Adapt the MCP tool result for Harmony
|
# Adapt the MCP tool result for Harmony
|
||||||
for tool in list_tools_result.tools:
|
for tool in list_tools_result.tools:
|
||||||
tool.inputSchema = trim_schema(tool.inputSchema)
|
tool.input_schema = trim_schema(tool.input_schema)
|
||||||
|
|
||||||
# Some tools schema don't need to be part of the prompt (e.g. simple text
|
# Some tools schema don't need to be part of the prompt (e.g. simple text
|
||||||
# in text out for Python)
|
# in text out for Python)
|
||||||
list_tools_result.tools = [
|
list_tools_result.tools = [
|
||||||
tool
|
tool
|
||||||
for tool in list_tools_result.tools
|
for tool in list_tools_result.tools
|
||||||
if getattr(tool.annotations, "include_in_prompt", True)
|
if (tool.meta or {}).get("include_in_prompt", True)
|
||||||
]
|
]
|
||||||
|
|
||||||
return list_tools_result
|
return list_tools_result
|
||||||
@@ -121,13 +121,13 @@ class MCPToolServer(ToolServer):
|
|||||||
list_tools_response = post_process_tools_description(list_tools_response)
|
list_tools_response = post_process_tools_description(list_tools_response)
|
||||||
|
|
||||||
tool_from_mcp = ToolNamespaceConfig(
|
tool_from_mcp = ToolNamespaceConfig(
|
||||||
name=initialize_response.serverInfo.name,
|
name=initialize_response.server_info.name,
|
||||||
description=initialize_response.instructions,
|
description=initialize_response.instructions,
|
||||||
tools=[
|
tools=[
|
||||||
ToolDescription.new(
|
ToolDescription.new(
|
||||||
name=tool.name,
|
name=tool.name,
|
||||||
description=tool.description,
|
description=tool.description,
|
||||||
parameters=tool.inputSchema,
|
parameters=tool.input_schema,
|
||||||
)
|
)
|
||||||
for tool in list_tools_response.tools
|
for tool in list_tools_response.tools
|
||||||
],
|
],
|
||||||
|
|||||||
Reference in New Issue
Block a user