fix: show error toast when streamable-http MCP connection fails (fixes #2823)#2829
Open
giulio-leone wants to merge 1 commit intoChainlit:mainfrom
Open
fix: show error toast when streamable-http MCP connection fails (fixes #2823)#2829giulio-leone wants to merge 1 commit intoChainlit:mainfrom
giulio-leone wants to merge 1 commit intoChainlit:mainfrom
Conversation
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.
9ce8714 to
eaee828
Compare
eaee828 to
3f15d96
Compare
Contributor
Author
|
Friendly ping — CI is green, tests pass, ready for review whenever convenient. Happy to address any feedback. Thanks! 🙏 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 rawfetch()that does not throw on non-OK responses — it returns{ success: res.ok, ... }. The promise always resolves, sotoast.promise()always shows the success toast.Fix
Result
Summary by cubic
Show an error toast when a streamable-http MCP connection fails. We now throw a
ClientErroron non-OK responses, usedetailwhen present, and skip JSON parsing for HTML errors sotoast.promiseshows the real message (fixes #2823).Written for commit 3f15d96. Summary will update on new commits.