Skip to content

fix: show error toast when streamable-http MCP connection fails (fixes #2823)#2829

Open
giulio-leone wants to merge 1 commit intoChainlit:mainfrom
giulio-leone:fix/streamable-http-mcp-error-toast-2823
Open

fix: show error toast when streamable-http MCP connection fails (fixes #2823)#2829
giulio-leone wants to merge 1 commit intoChainlit:mainfrom
giulio-leone:fix/streamable-http-mcp-error-toast-2823

Conversation

@giulio-leone
Copy link
Contributor

@giulio-leone giulio-leone commented Mar 7, 2026

Summary

Fixes #2823 — Frontend shows "MCP added!" success toast when a streamable-http MCP connection fails with HTTP 400, while SSE correctly shows an error toast.

Root Cause

However, the frontend's ExtendedChainlitAPI.connectStreamableHttpMCP() overrides the base method with a raw fetch() that does not throw on non-OK responses — it returns { success: res.ok, ... }. The promise always resolves, so toast.promise() always shows the success toast.

Fix

  throw new ClientError(res.statusText, res.status, data.detail);
}

Result

Connection type Invalid URL before Invalid URL after
SSE ❌ Error toast ❌ Error toast
Streamable HTTP
Stdio ❌ Error toast ❌ Error toast

Summary by cubic

Show an error toast when a streamable-http MCP connection fails. We now throw a ClientError on non-OK responses, use detail when present, and skip JSON parsing for HTML errors so toast.promise shows the real message (fixes #2823).

Written for commit 3f15d96. Summary will update on new commits.

@dosubot dosubot bot added size:XS This PR changes 0-9 lines, ignoring generated files. frontend Pertains to the frontend. labels Mar 7, 2026
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

When connecting to a streamable-http MCP server that is unreachable,
the frontend showed a green 'MCP added!' success toast instead of an
error message because the HTTP error was not thrown (fixes Chainlit#2823).

Throw ClientError on non-ok response. Check res.ok before attempting
JSON parse so proxy HTML error pages don't cause a SyntaxError.
Use data.detail as the message so the toast shows the actual error
reason (e.g. 'Connection refused') rather than generic status text.
@giulio-leone giulio-leone force-pushed the fix/streamable-http-mcp-error-toast-2823 branch from 9ce8714 to eaee828 Compare March 7, 2026 17:31
@dosubot dosubot bot added size:S This PR changes 10-29 lines, ignoring generated files. and removed size:XS This PR changes 0-9 lines, ignoring generated files. labels Mar 7, 2026
@giulio-leone giulio-leone force-pushed the fix/streamable-http-mcp-error-toast-2823 branch from eaee828 to 3f15d96 Compare March 8, 2026 22:06
@giulio-leone
Copy link
Contributor Author

Friendly ping — CI is green, tests pass, ready for review whenever convenient. Happy to address any feedback. Thanks! 🙏

@giulio-leone
Copy link
Contributor Author

Friendly follow-up in case this is still relevant — happy to update, rebase, or address any feedback if useful. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

frontend Pertains to the frontend. size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Frontend shows "MCP added!" success toast when streamable-http connection fails

1 participant