Skip to content

Conversation

@daniel-salib
Copy link
Contributor

@daniel-salib daniel-salib commented Dec 4, 2025

Add MCP type support infrastructure to Responses API

Summary

Add MCP type support infrastructure to Responses API

Changes

  • Import and use McpCall type from openai library
  • Add _parse_mcp_call() function to parse MCP tool calls into properly typed output items
  • Update parse_output_message() to route unknown recipients (not browser.*, functions.*, or built-in tools) to MCP parsing
  • Update parse_remaining_state() to handle in-progress MCP calls
  • Add server_label field to McpCall objects (extracted from recipient name)

Test Plan

Unit tests:

python3 -m pytest tests/entrypoints/test_harmony_utils.py -k "mcp" -v

Manual test - Before this change (missing server_label field):

curl -X POST "http://localhost:8000/v1/responses" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer dummy-api-key" \
  -d '{
    "model": "default",
    "input": "Use the filesystem tool to list files in /tmp directory",
    "tools": [{
      "type": "mcp",
      "server_label": "filesystem",
      "headers": {"test": "test"}
    }],
    "enable_response_messages": true
  }'

Response: {"error":{"message":"unhandled errors in a TaskGroup (1 sub-exception)","type":"BadRequestError","param":null,"code":400}}

After this change:
Same curl command now returns:

{
  "output": [
    ...reasoning items...,
    {
      "id": "mcp_bc8c1958cd96823c",
      "arguments": "{\"path\": \"/tmp\"}",
      "name": "filesystem",
      "server_label": "filesystem",
      "type": "mcp_call",
      "status": "completed"
    }
  ]
}

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds support for MCP (Multi-turn Conversation Protocol) tool calls to the Responses API. The changes introduce parsing logic for MCP calls in both complete and streaming responses, update the protocol definitions, and add corresponding tests. My review identified a critical issue in the streaming logic that could lead to incorrect behavior for certain built-in tools, and a high-severity issue regarding code duplication that impacts maintainability. I've provided suggestions to address both. The rest of the changes, including the new tests and protocol updates, are well-implemented.

@daniel-salib daniel-salib force-pushed the pr2-mcp-core branch 2 times, most recently from 4da4f60 to 82adc20 Compare December 4, 2025 11:09
@chaunceyjiang
Copy link
Collaborator

/cc @yeqcharlotte @qandrew PTAL

@daniel-salib daniel-salib force-pushed the pr2-mcp-core branch 2 times, most recently from 9ee6816 to b6bbde0 Compare December 5, 2025 07:49
@mergify
Copy link

mergify bot commented Dec 5, 2025

Hi @daniel-salib, the pre-commit checks have failed. Please run:

uv pip install pre-commit
pre-commit install
pre-commit run --all-files

Then, commit the changes and push to your branch.

For future commits, pre-commit will run automatically on changed files before each commit.

@mergify
Copy link

mergify bot commented Dec 5, 2025

This pull request has merge conflicts that must be resolved before it can be
merged. Please rebase the PR, @daniel-salib.

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

Copy link
Collaborator

@yeqcharlotte yeqcharlotte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM @qandrew @daniel-salib can we create a follow-up PR to update examples?

@github-project-automation github-project-automation bot moved this from To Triage to Ready in gpt-oss Issues & Enhancements Dec 6, 2025
@yeqcharlotte yeqcharlotte enabled auto-merge (squash) December 6, 2025 02:06
@github-actions github-actions bot added the ready ONLY add when PR is ready to merge/full CI is needed label Dec 6, 2025
auto-merge was automatically disabled December 6, 2025 03:20

Head branch was pushed to by a user without write access

@daniel-salib daniel-salib force-pushed the pr2-mcp-core branch 2 times, most recently from cec9f47 to f450c23 Compare December 6, 2025 03:21
@daniel-salib daniel-salib force-pushed the pr2-mcp-core branch 3 times, most recently from 18cd84c to bd2d381 Compare December 6, 2025 14:37
@mergify
Copy link

mergify bot commented Dec 6, 2025

Documentation preview: https://vllm--30054.org.readthedocs.build/en/30054/

@mergify mergify bot added the documentation Improvements or additions to documentation label Dec 6, 2025
@daniel-salib daniel-salib force-pushed the pr2-mcp-core branch 3 times, most recently from 04b9d64 to 687ca45 Compare December 6, 2025 23:15
Signed-off-by: Daniel Salib <danielsalib@meta.com>
@chaunceyjiang chaunceyjiang merged commit 444f0e3 into vllm-project:main Dec 8, 2025
47 checks passed
penfree pushed a commit to penfree/vllm that referenced this pull request Dec 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation frontend gpt-oss Related to GPT-OSS models ready ONLY add when PR is ready to merge/full CI is needed

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants