It can perform only one call to MCP

I have an MCP server, made by python and FastMCP. Technically it should provide an interface to my Spotify player. The problem is that only one request to the MCP server can successfully perform, any next subsequent request is failed. But if I send another message, and it reasons to do another tool call, it will work, but again only for one call.

The log on the server side looks like the session is closed immediately after the first call, so the following cannot be executed.

I cannot figure out how to fix that, and even have no idea is it a MCP or client-side problem. Below logs and a few code snippets. Any suggestion?

foobar-spotify-prod  | DEBUG:    % sending keepalive ping
foobar-spotify-prod  | DEBUG:    > PING 58 d9 6c fc [binary, 4 bytes]
foobar-spotify-prod  | DEBUG:    < PONG 58 d9 6c fc [binary, 4 bytes]
foobar-spotify-prod  | DEBUG:    % received keepalive pong
foobar-spotify-prod  | 2025-06-16 04:02:26,780 INFO Created new transport with session ID: 975025b7c0564d9b98d1b80265a4a137
foobar-spotify-prod  | INFO:     172.21.0.4:49974 - "POST /mcp/ HTTP/1.1" 200 OK
foobar-spotify-prod  | 2025-06-16 04:02:26,968 INFO Created new transport with session ID: 8cf5916095b04b4d9dbf09214fbb7b15
foobar-spotify-prod  | INFO:     172.21.0.4:49986 - "POST /mcp/ HTTP/1.1" 200 OK
foobar-spotify-prod  | INFO:     172.21.0.4:49988 - "GET /mcp/ HTTP/1.1" 200 OK
foobar-spotify-prod  | INFO:     172.21.0.4:49994 - "POST /mcp/ HTTP/1.1" 202 Accepted
foobar-spotify-prod  | INFO:     172.21.0.4:50004 - "POST /mcp/ HTTP/1.1" 200 OK
foobar-spotify-prod  | 2025-06-16 04:02:27,314 INFO Processing request of type CallToolRequest
foobar-spotify-prod  | 2025-06-16 04:02:27,315 INFO spotify_search
foobar-spotify-prod  | 2025-06-16 04:02:27,926 INFO {'artists': [{'name': 'The Rolling Stones', 'uri': 'spotify:artist:22bE4uQ6baNwSHPVcDxLCe'}]}
foobar-spotify-prod  | 2025-06-16 04:02:28,059 INFO Terminating session: 8cf5916095b04b4d9dbf09214fbb7b15
foobar-spotify-prod  | INFO:     172.21.0.4:50012 - "DELETE /mcp/ HTTP/1.1" 200 OK
foobar-spotify-prod  | DEBUG:    % sending keepalive ping
foobar-spotify-prod  | DEBUG:    > PING 'N\x1e\x7f\x0e' [text, 4 bytes]
foobar-spotify-prod  | DEBUG:    < PONG 'N\x1e\x7f\x0e' [text, 4 bytes]
foobar-spotify-prod  | DEBUG:    % received keepalive pong
foobar-spotify-prod  | INFO:     172.21.0.4:50016 - "POST /mcp/ HTTP/1.1" 404 Not Found
foobar-spotify-prod  | INFO:     172.21.0.4:50020 - "POST /mcp/ HTTP/1.1" 404 Not Found
Response(
β”‚   id='resp_684f9751c9c08191b8ca2ee74778f1b1022fec83668f0516',
β”‚   created_at=1750046545.0,
β”‚   error=None,
β”‚   incomplete_details=None,
β”‚   instructions=None,
β”‚   metadata={},
β”‚   model='gpt-4o-2024-08-06',
β”‚   object='response',
β”‚   output=[
β”‚   β”‚   McpCall(
β”‚   β”‚   β”‚   id='mcp_684f9752aed08191a2c2c41189e5b3ff022fec83668f0516',
β”‚   β”‚   β”‚   arguments='{"query":"The Beatles","qtype":"artist","limit":1}',
β”‚   β”‚   β”‚   name='spotify_search',
β”‚   β”‚   β”‚   server_label='foobar',
β”‚   β”‚   β”‚   type='mcp_call',
β”‚   β”‚   β”‚   error=None,
β”‚   β”‚   β”‚   output='{"artists": [{"name": "The Rolling Stones", "uri": "spotify:artist:22bE4uQ6baNwSHPVcDxLCe"}]}',
β”‚   β”‚   β”‚   approval_request_id=None
β”‚   β”‚   ),
β”‚   β”‚   ResponseOutputMessage(
β”‚   β”‚   β”‚   id='msg_684f9754afa881919db49ff3907f8d37022fec83668f0516',
β”‚   β”‚   β”‚   content=[
β”‚   β”‚   β”‚   β”‚   ResponseOutputText(
β”‚   β”‚   β”‚   β”‚   β”‚   annotations=[],
β”‚   β”‚   β”‚   β”‚   β”‚   text='It seems I got results for The Rolling Stones instead of The Beatles. Let me try searching again!',
β”‚   β”‚   β”‚   β”‚   β”‚   type='output_text',
β”‚   β”‚   β”‚   β”‚   β”‚   logprobs=None
β”‚   β”‚   β”‚   β”‚   )
β”‚   β”‚   β”‚   ],
β”‚   β”‚   β”‚   role='assistant',
β”‚   β”‚   β”‚   status='completed',
β”‚   β”‚   β”‚   type='message'
β”‚   β”‚   ),
β”‚   β”‚   McpCall(
β”‚   β”‚   β”‚   id='mcp_684f9755ab78819196bb34c30638792e022fec83668f0516',
β”‚   β”‚   β”‚   arguments='{"query":"The Beatles","qtype":"track","limit":1}',
β”‚   β”‚   β”‚   name='spotify_search',
β”‚   β”‚   β”‚   server_label='foobar',
β”‚   β”‚   β”‚   type='mcp_call',
β”‚   β”‚   β”‚   error={'type': 'mcp_protocol_error', 'code': 32600, 'message': 'Session terminated'},
β”‚   β”‚   β”‚   output=None,
β”‚   β”‚   β”‚   approval_request_id=None
β”‚   β”‚   ),
β”‚   β”‚   ResponseOutputMessage(
β”‚   β”‚   β”‚   id='msg_684f975643508191b539fea6ddcee780022fec83668f0516',
β”‚   β”‚   β”‚   content=[
β”‚   β”‚   β”‚   β”‚   ResponseOutputText(
β”‚   β”‚   β”‚   β”‚   β”‚   annotations=[],
β”‚   β”‚   β”‚   β”‚   β”‚   text='It looks like there was an issue accessing the song data. Let me try another approach to get the most popular track for you!',
β”‚   β”‚   β”‚   β”‚   β”‚   type='output_text',
β”‚   β”‚   β”‚   β”‚   β”‚   logprobs=None
β”‚   β”‚   β”‚   β”‚   )
β”‚   β”‚   β”‚   ],
β”‚   β”‚   β”‚   role='assistant',
β”‚   β”‚   β”‚   status='completed',
β”‚   β”‚   β”‚   type='message'
β”‚   β”‚   ),
β”‚   β”‚   McpCall(
β”‚   β”‚   β”‚   id='mcp_684f975795c881918a1a69f726ed8517022fec83668f0516',
β”‚   β”‚   β”‚   arguments='{"query":"The Beatles","qtype":"track","limit":5}',
β”‚   β”‚   β”‚   name='spotify_search',
β”‚   β”‚   β”‚   server_label='foobar',
β”‚   β”‚   β”‚   type='mcp_call',
β”‚   β”‚   β”‚   error={'type': 'mcp_protocol_error', 'code': 32600, 'message': 'Session terminated'},
β”‚   β”‚   β”‚   output=None,
β”‚   β”‚   β”‚   approval_request_id=None
β”‚   β”‚   ),
β”‚   β”‚   ResponseOutputMessage(
β”‚   β”‚   β”‚   id='msg_684f97583bf48191ba4a1d019fe15620022fec83668f0516',
β”‚   β”‚   β”‚   content=[
β”‚   β”‚   β”‚   β”‚   ResponseOutputText(
β”‚   β”‚   β”‚   β”‚   β”‚   annotations=[],
β”‚   β”‚   β”‚   β”‚   β”‚   text="I'm having a bit of trouble fetching the song right now. Would you like to try something else or perhaps listen to a specific album or track by The Beatles?",
β”‚   β”‚   β”‚   β”‚   β”‚   type='output_text',
β”‚   β”‚   β”‚   β”‚   β”‚   logprobs=None
β”‚   β”‚   β”‚   β”‚   )
β”‚   β”‚   β”‚   ],
β”‚   β”‚   β”‚   role='assistant',
β”‚   β”‚   β”‚   status='completed',
β”‚   β”‚   β”‚   type='message'
β”‚   β”‚   )
β”‚   ],
β”‚   parallel_tool_calls=True,
β”‚   temperature=1.0,
β”‚   tool_choice='auto',
β”‚   tools=[
β”‚   β”‚   Mcp(
β”‚   β”‚   β”‚   server_label='foobar',
β”‚   β”‚   β”‚   server_url='https://hidden.hostname.com/<redacted>',
β”‚   β”‚   β”‚   type='mcp',
β”‚   β”‚   β”‚   allowed_tools=None,
β”‚   β”‚   β”‚   headers={'Authorization': '<redacted>'},
β”‚   β”‚   β”‚   require_approval='never'
β”‚   β”‚   )
β”‚   ],
β”‚   top_p=1.0,
β”‚   background=False,
β”‚   max_output_tokens=None,
β”‚   previous_response_id='resp_684f973c47d4819183141bbb35a3312b022fec83668f0516',
β”‚   reasoning=Reasoning(effort=None, generate_summary=None, summary=None),
β”‚   service_tier='default',
β”‚   status='completed',
β”‚   text=ResponseTextConfig(format=ResponseFormatText(type='text')),
β”‚   truncation='disabled',
β”‚   usage=ResponseUsage(
β”‚   β”‚   input_tokens=3993,
β”‚   β”‚   input_tokens_details=InputTokensDetails(cached_tokens=0),
β”‚   β”‚   output_tokens=165,
β”‚   β”‚   output_tokens_details=OutputTokensDetails(reasoning_tokens=0),
β”‚   β”‚   total_tokens=4158
β”‚   ),
β”‚   user=None,
β”‚   store=True
)

P.S. The fact that it tried to call search a few times is fun but doesn’t matter. In case if it was successful in search and tried to play the found song by another call, the second call was always failed.

foo: Mcp = {
    "type": "mcp",
    "server_label": "foobar",
    "server_url": "https://hidden.hostname.com/agujero/foo/mcp/",
    "require_approval": "never",
    "headers": {
        "Authorization": f"Bearer {THE_SECRET}"
    }
}
.....
    while True:
        .....
        response = await client.responses.create(
            model="gpt-4o",
            tools=[foo],
            input=[message],
            previous_response_id=previous_response_id,
        )
1 Like

I have the same issue, wait for a fix, maybe it’s an error from their protocol, like inverse DELETE and POST then it make the error, I didn’t log the DELETE data but based on different article on other open report, a lot of developper have this error on streamable http.

Wait for answer from openAI dev team, on other report they didn’t reply, I searching for solution keep update here.

Log of my FastMCP running streamable-http :
INFO: ip_openai.58:0 - β€œPOST /mcp/ HTTP/1.1” 200 OK
INFO: ip_openai.60:0 - β€œPOST /mcp/ HTTP/1.1” 200 OK
INFO: ip_openai.60:0 - β€œPOST /mcp/ HTTP/1.1” 202 Accepted
INFO: ip_openai.48:0 - β€œGET /mcp/ HTTP/1.1” 200 OK
INFO: ip_openai.48:0 - β€œPOST /mcp/ HTTP/1.1” 200 OK
INFO: ip_openai.49:0 - β€œDELETE /mcp/ HTTP/1.1” 200 OK
INFO: ip_openai.63:0 - β€œPOST /mcp/ HTTP/1.1” 404 Not Found

FastMCP run :
if name == β€œmain”:
mcp.run(
transport=β€œstreamable-http”,
host=β€œ0.0.0.0”,
port=8042,
path=β€œ/mcp”,
log_level=β€œdebug”
)

Certificate SSL valide,
No network error, only protocol MCP cause this issue. Possibility compatibility openAI != FastMCP
ListTools work, on client.py with my own code don’t work at the final step POST 404, same on the website openai in project β†’ agent β†’ prompt (with MCP setup, the list of tools are showed but when using the interaction with MCP generate error)

@tce it’s not client-side error, openai have the same error on the website :
https://platform.openai.com/playground/prompts?models=gpt-4.1 β†’ you can add your MCP endpoint.

Then three possibility :

  • it’s error in MCP server
  • protocol openAI MCP don’t accept FastMCP
  • the streamable-http is in WIP

maybe could work with old FastMCP version I didn’t try

(Update 3 hours later this post) :

I change some redirect config from my Apache2, to handle SSE,
Because Http contain SSE and JSON, then check if you redirect the SSE request to your port of your service. My certificate was already good.

Good luck other dev, I stay online to answer questions if needed.

I’m a bit confused, have you found the solution, or you just confirmed that it’s not an issue with SSE redirect or certificates?

P.S. Played with my redirect, it’s implemented by nginx. No help. Now it looks like this:

        location /foo/ {
            proxy_pass http://spotify-prod:8025/;
            proxy_buffering off;
            proxy_http_version 1.1;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header Upgrade $http_upgrade;
        }

It’s like, my on the playground now it’s work, but still not working inside my code, I tried to list tools with fastmcp and give it to the tools arg of client.responses.create() but protocol error, I don’t know the cause, im still working on it, but first step it’s the playground I guess to connect mcp on the openai website.

It was issue with my redirect but I fix it like apache2 :
ProxyPass /redirectmcp url_localhost_http:8042 nocanon retry=0
ProxyPassReverse /redirectmcp url_localhost_http:8042

url_localhost_http β†’ link but I can’t post link here

Then im still trying to fix the step two of the issue, protocol error