-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Confirm this is an issue with the Python library and not an underlying OpenAI API
- This is an issue with the Python library
Describe the bug
When using authenticated remote MCP servers like GitHub's remote MCP the list_tools() runs successfully however actually calling the tools produces the following error.
{
"id": "mcp_68938c85a9908192bfa5ffe1c83af8f40446391e66c97710",
"arguments": "{\"owner\":\"<REDACTED>}",
"name": "list_pull_requests",
"server_label": "github",
"type": "mcp_call",
"error": {
"type": "mcp_protocol_error",
"code": 32600,
"message": "Session terminated"
},
"output": null,
"approval_request_id": null
},
If I use the previous_response_id
that contains the MCP list_tools then the 1st tool call works, but the second gives the same session terminated error.
So it seems like the MCP server is getting disconnected and the session is not persisted. This only occurs for authenticated remote MCP servers.
References:
- https://community.openai.com/t/error-using-mcp-server-using-open-ai-api-playground/1280337/2
- https://community.openai.com/t/the-responses-api-terminates-a-session-too-early/1312539
- https://community.openai.com/t/openai-responses-api-to-mcp-server-connection-problems/1269983
- Remote MCP Server | Session Terminated after 1st interaction github/github-mcp-server#702
- FastMCP does not work with OpenAI's responses API jlowin/fastmcp#855
To Reproduce
from openai.types.responses.tool_param import Mcp
mcp_github = Mcp(
server_label="github",
server_url="https://api.githubcopilot.com/mcp/",
type="mcp",
headers={
"Authorization": f"Bearer {GITHUB_PAT}",
},
require_approval="never",
)
stream = await llm.responses.create(
model="gpt-4.1",
tools=[mcp_github],
input="What is my GitHub username?",
stream=True
)
async for event in stream:
print(event.model_dump_json(indent=2))
Code snippets
OS
Windows 11
Python version
Python v3.13.2
Library version
openai v.1.99.1
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working