-
-
Notifications
You must be signed in to change notification settings - Fork 11.5k
[Frontend] Responses API MCP tools for built in tools and to pass through headers #24628
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
yeqcharlotte
merged 14 commits into
vllm-project:main
from
alecsolder:builtin_mcp_tools_with_headers
Sep 22, 2025
Merged
Changes from 11 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
e6ad3ae
Adding the ability to use MCP tools for built in tools to pass throug…
69b7e04
Adding one unit test which works locally, fixing type to name transla…
f0553be
Removing log line
94162b0
Enabling oss coding tool for tests
103f6d9
Merge branch 'main' into builtin_mcp_tools_with_headers
alecsolder 8bc171d
adding the skip back
aa572f5
Moving MCP tests to separate file, adding env variable for allowing m…
12f67da
Merge branch 'main' into builtin_mcp_tools_with_headers
alecsolder dd50bda
Merge branch 'main' into builtin_mcp_tools_with_headers
yeqcharlotte 0bd5e53
Fixing nits and adding env variable validation
da6d8a5
Merge branch 'main' into builtin_mcp_tools_with_headers
alecsolder 823414a
Adding tests for env variable parsing
d247304
Merge branch 'main' into builtin_mcp_tools_with_headers
alecsolder 175a77c
Merge branch 'main' into builtin_mcp_tools_with_headers
yeqcharlotte File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
106 changes: 106 additions & 0 deletions
106
tests/entrypoints/openai/test_response_api_mcp_tools.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # SPDX-FileCopyrightText: Copyright contributors to the vLLM project | ||
|
|
||
| import pytest | ||
| import pytest_asyncio | ||
| from openai import OpenAI | ||
|
|
||
| from ...utils import RemoteOpenAIServer | ||
|
|
||
| MODEL_NAME = "openai/gpt-oss-20b" | ||
|
|
||
|
|
||
| @pytest.fixture(scope="module") | ||
| def monkeypatch_module(): | ||
| from _pytest.monkeypatch import MonkeyPatch | ||
| mpatch = MonkeyPatch() | ||
| yield mpatch | ||
| mpatch.undo() | ||
|
|
||
|
|
||
| @pytest.fixture(scope="module") | ||
| def mcp_disabled_server(monkeypatch_module: pytest.MonkeyPatch): | ||
| args = ["--enforce-eager", "--tool-server", "demo"] | ||
|
|
||
| with monkeypatch_module.context() as m: | ||
| m.setenv("VLLM_ENABLE_RESPONSES_API_STORE", "1") | ||
| m.setenv("PYTHON_EXECUTION_BACKEND", "dangerously_use_uv") | ||
| with RemoteOpenAIServer(MODEL_NAME, args) as remote_server: | ||
| yield remote_server | ||
|
|
||
|
|
||
| @pytest.fixture(scope="function") | ||
| def mcp_enabled_server(monkeypatch_module: pytest.MonkeyPatch): | ||
| args = ["--enforce-eager", "--tool-server", "demo"] | ||
|
|
||
| with monkeypatch_module.context() as m: | ||
| m.setenv("VLLM_ENABLE_RESPONSES_API_STORE", "1") | ||
| m.setenv("PYTHON_EXECUTION_BACKEND", "dangerously_use_uv") | ||
| m.setenv("GPT_OSS_SYSTEM_TOOL_MCP_LABELS", | ||
| "code_interpreter,container") | ||
| with RemoteOpenAIServer(MODEL_NAME, args) as remote_server: | ||
| yield remote_server | ||
|
|
||
|
|
||
| @pytest_asyncio.fixture | ||
| async def mcp_disabled_client(mcp_disabled_server): | ||
| async with mcp_disabled_server.get_async_client() as async_client: | ||
| yield async_client | ||
|
|
||
|
|
||
| @pytest_asyncio.fixture | ||
| async def mcp_enabled_client(mcp_enabled_server): | ||
| async with mcp_enabled_server.get_async_client() as async_client: | ||
| yield async_client | ||
|
|
||
|
|
||
| @pytest.mark.asyncio | ||
| @pytest.mark.parametrize("model_name", [MODEL_NAME]) | ||
| @pytest.mark.skip(reason="Code interpreter tool is not available in CI yet.") | ||
| async def test_mcp_tool_env_flag_enabled(mcp_enabled_client: OpenAI, | ||
| model_name: str): | ||
| response = await mcp_enabled_client.responses.create( | ||
| model=model_name, | ||
| # TODO: Ideally should be able to set max tool calls | ||
| # to prevent multi-turn, but it is not currently supported | ||
| # would speed up the test | ||
| input=("What's the first 4 digits after the decimal point of " | ||
| "cube root of `19910212 * 20250910`? " | ||
| "Show only the digits. The python interpreter is not stateful " | ||
| "and you must print to see the output."), | ||
| tools=[{ | ||
| "type": "mcp", | ||
| "server_label": "code_interpreter", | ||
| # URL unused for DemoToolServer | ||
| "server_url": "http://localhost:8888" | ||
| }], | ||
| ) | ||
| assert response is not None | ||
| assert response.status == "completed" | ||
| assert response.usage.output_tokens_details.tool_output_tokens > 0 | ||
|
|
||
|
|
||
| @pytest.mark.asyncio | ||
| @pytest.mark.parametrize("model_name", [MODEL_NAME]) | ||
| @pytest.mark.skip(reason="Code interpreter tool is not available in CI yet.") | ||
| async def test_mcp_tool_env_flag_disabled(mcp_disabled_client: OpenAI, | ||
| model_name: str): | ||
| response = await mcp_disabled_client.responses.create( | ||
| model=model_name, | ||
| # TODO: Ideally should be able to set max tool calls | ||
| # to prevent multi-turn, but it is not currently supported | ||
| # would speed up the test | ||
| input=("What's the first 4 digits after the decimal point of " | ||
| "cube root of `19910212 * 20250910`? " | ||
| "Show only the digits. The python interpreter is not stateful " | ||
| "and you must print to see the output."), | ||
| tools=[{ | ||
| "type": "mcp", | ||
| "server_label": "code_interpreter", | ||
| # URL unused for DemoToolServer | ||
| "server_url": "http://localhost:8888" | ||
| }], | ||
| ) | ||
| assert response is not None | ||
| assert response.status == "completed" | ||
| assert response.usage.output_tokens_details.tool_output_tokens == 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.