Hi everyone,
I’ve been experimenting with MCP in the Responses API, and I believe that for some messages, the type
chunk is incorrect.
With this code:
❯ curl https://api.openai.com/v1/responses \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{
"model": "o4-mini",
"reasoning": {"effort": "medium", "summary": "detailed"},
"tools": [
{
"type": "mcp",
"server_label": "deepwiki",
"server_url": "https://mcp.deepwiki.com/mcp",
"require_approval": "never"
}
],
"input": "What transport protocols are supported in the 2025-03-26 version of the MCP spec? Before you call any tool, tell me if youre calling a tool any why. FYI: the github is modelcontextprotocol/modelcontextprotocol",
"stream": true
}'
I get some events looking like this:
{
"type": "response.mcp_call_arguments.delta",
"sequence_number": 10,
"output_index": 2,
"item_id": "mcp_684ff3a22a60819c90fa205XXXXXXXXXXX",
"delta": "{\"repoName\":\"modelcontextprotocol/modelcontextprotocol\"}"
},
{
"type": "response.mcp_call_arguments.done",
"sequence_number": 11,
"output_index": 2,
"item_id": "mcp_684ff3a22a60819c90fa205XXXXXXXXXXX",
"arguments": "{\"repoName\":\"modelcontextprotocol/modelcontextprotocol\"}"
},
The two type
s, here, are response.mcp_call_arguments.delta
and response.mcp_call_arguments.done
. But in the API reference, they should be response.mcp_call.arguments.delta
and response.mcp_call.arguments.done
, respectively. (See https://platform.openai.com/docs/api-reference/responses-streaming/response/mcp_call/arguments/delta)
This is not about being pedantic: this breaks the Python SDK, as far as I can tell:
from openai.types import responses as rt # version 1.86.0
from pydantic import TypeAdapter
attempt = [
{
"type": "response.mcp_call_arguments.delta",
"sequence_number": 10,
"output_index": 2,
"item_id": "mcp_684ff3a22a60819c90fa205XXXXXXXXXXX",
"delta": '{"repoName":"modelcontextprotocol/modelcontextprotocol"}',
},
{
"type": "response.mcp_call_arguments.done",
"sequence_number": 11,
"output_index": 2,
"item_id": "mcp_684ff3a22a60819c90fa205XXXXXXXXXXX",
"arguments": '{"repoName":"modelcontextprotocol/modelcontextprotocol"}',
},
]
_ = TypeAdapter(list[rt.ResponseStreamEvent]).validate_python(attempt) # Will not work
Now, funnily enough, even with the correct type
, the code will not work, because the Python SDK also has the wrong type
. (PR on the Python SDK GitHub repo is 2412.) But the point about the API being deficient stands.
Thanks