fastapi_mcp icon indicating copy to clipboard operation
fastapi_mcp copied to clipboard

Fix duplicated 'http.response.start' event error during client session disconnection

Open cuspymd opened this issue 5 months ago • 2 comments

Describe your changes

When a client session is disconnected, the handle_mcp_connection() function returns None, which the server processes as a JsonResponse, triggering the 'http.response.start' event. To prevent the 'http.response.start' event from occurring, it was modified to return a VoidResponse that does not generate any message.

For reference, this error always occurs when the SSE client session is disconnected, regardless of middleware registration.

Issue ticket number and link (if applicable)

#171

Screenshots of the feature / bugfix

Checklist before requesting a review

  • [ ] Added relevant tests
  • [ ] Run ruff & mypy
  • [ ] All tests pass

cuspymd avatar Jul 18 '25 10:07 cuspymd

I can confirm that it's also fixing the #171 for me

CaddyGlow avatar Jul 23 '25 07:07 CaddyGlow

+1 to this PR, solved the issue for us as well

azaroth42 avatar Aug 06 '25 14:08 azaroth42