Skip to content

Conversation

@EmanueleDeRossi1
Copy link
Collaborator

This PR introduces changes from the feature/improve-mcp-errors branch.

📝 Summary

📁 Files Changed ( 6 files)

apps/backend/src/rhesis/backend/app/routers/services.py
apps/backend/src/rhesis/backend/app/services/mcp_service.py
sdk/src/rhesis/sdk/services/mcp/__init__.py
sdk/src/rhesis/sdk/services/mcp/agent.py
sdk/src/rhesis/sdk/services/mcp/exceptions.py
sdk/src/rhesis/sdk/services/mcp/executor.py

📋 Commit Details

68284d98 - feat: implement structured error handling for MCP endpoints (Emanuele De Rossi, 2025-12-01 17:33)

✅ Checklist

  • Code follows the project's style guidelines
  • Self-review of code has been performed
  • Code is commented, particularly in hard-to-understand areas
  • Corresponding changes to documentation have been made
  • Tests have been added/updated for new functionality
  • All tests pass locally

🧪 Testing

📸 Screenshots (if applicable)

🔗 Related Issues

- Add custom exception classes (MCPError, MCPAuthenticationError, MCPNotFoundError, MCPDataFormatError, MCPConnectionError) in SDK
- Move error detection from backend keyword matching to SDK-level exception handling
- ToolExecutor detects tool-level errors (auth, connection) and raises exceptions
- MCPAgent detects agent-level semantic errors (not found, max iterations, JSON parsing)
- Backend service functions let MCP exceptions bubble up directly (no intermediate ValueError translation)
- Router endpoints catch MCP exceptions and map to appropriate HTTP status codes (404, 422, 503)
- Remove fragile keyword matching logic in favor of structured exceptions

This improves error handling reliability and maintainability by centralizing error detection in the SDK and simplifying HTTP status code mapping in the backend.
@EmanueleDeRossi1 EmanueleDeRossi1 self-assigned this Dec 2, 2025
@EmanueleDeRossi1 EmanueleDeRossi1 linked an issue Dec 2, 2025 that may be closed by this pull request
7 tasks
@EmanueleDeRossi1 EmanueleDeRossi1 marked this pull request as draft December 2, 2025 13:33
@EmanueleDeRossi1 EmanueleDeRossi1 added Frontend Test Results Issues related to creating, reviewing test results. labels Dec 4, 2025
@EmanueleDeRossi1 EmanueleDeRossi1 added this to the Release 11 (12.12) milestone Dec 4, 2025
@EmanueleDeRossi1 EmanueleDeRossi1 removed Test Results Issues related to creating, reviewing test results. Frontend labels Dec 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve MCP Error Detection

2 participants