Skip to content

Conversation

skamenan7
Copy link
Contributor

What does this PR do?

Fixes error handling when MCP server connections fail. Instead of returning generic 500 errors, now provides
descriptive error messages with proper HTTP status codes.

Closes #3107

Test Plan

Before fix:
curl -X GET "http://localhost:8321/v1/tool-runtime/list-tools?tool_group_id=bad-mcp-server"
Returns: {"detail": "Internal server error: An unexpected error occurred."} (500)

After fix:
curl -X GET "http://localhost:8321/v1/tool-runtime/list-tools?tool_group_id=bad-mcp-server"
Returns: {"error": {"detail": "Failed to connect to MCP server at http://localhost:9999/sse: Connection
refused"}} (502)

Tests:

  • Added unit test for ConnectionError → 502 translation
  • Manually tested with unreachable MCP servers (connection refused)

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Meta Open Source bot. label Aug 26, 2025
@skamenan7 skamenan7 force-pushed the bugs/show-mcp-errors-3107 branch 4 times, most recently from 194cc32 to e13affa Compare August 26, 2025 11:54
@skamenan7 skamenan7 marked this pull request as ready for review August 26, 2025 11:54
@skamenan7 skamenan7 changed the title fix: show descriptive MCP server connection errors instead of generic 500s fix: show descriptive MCP server connection errors instead of generic 500s Aug 26, 2025
@skamenan7 skamenan7 force-pushed the bugs/show-mcp-errors-3107 branch 3 times, most recently from bb8f2f5 to 1bf815f Compare August 27, 2025 12:53
@skamenan7 skamenan7 force-pushed the bugs/show-mcp-errors-3107 branch from 1bf815f to 5bccb37 Compare September 3, 2025 17:43
@raghotham raghotham merged commit 55a8c5f into llamastack:main Sep 4, 2025
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Meta Open Source bot.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

poor error handling on failure to connect to mcp server through responses API
2 participants