Fix MCP connection leak and "Not Acceptable" error#8
Conversation
This change addresses a connection leak in the MCP plugin where SSE streams returned by POST requests were not always consumed or closed. This led to hitting browser connection limits and causing intermittent failures. Changes: - Refined the Accept header to 'text/event-stream,application/json'. - Ensured all fetch responses always have their body consumed via resp.text(). - Improved robust parsing of JSON-RPC responses wrapped in SSE events. - Updated initialization to correctly handle the new return type. - Fixed Playwright tests to use correct tool prefixes. Co-authored-by: dmatscheko <38495897+dmatscheko@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
The MCP transport in the JS code was leaking connections because it didn't always read the response body of POST requests that returned SSE streams (which is common in FastMCP-based servers). This caused intermittent "Not Acceptable" errors when browser connection limits were reached.
The fix ensures that the response body is always consumed, even when only headers are needed. It also improves the SSE fallback parsing to correctly handle error messages and refines the Accept header for better compatibility.
PR created automatically by Jules for task 14071015176736618620 started by @dmatscheko