Conversation
MCPToolWrapper returned the error text as a plain str when a server answered tools/call with isError=true, so the framework recorded the call as a success: no ToolFailureDetectedEvent, no ToolOutput.has_tool_failures. MCPNativeTool already reported the same server answer as ToolFailure(reason=MCP_ERROR).
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthrough
ChangesMCP error handling
Sequence Diagram(s)sequenceDiagram
participant MCPToolWrapper
participant MCPServer
participant ToolFailure
MCPToolWrapper->>MCPServer: call_tool
MCPServer-->>MCPToolWrapper: CallToolResult with content and isError
MCPToolWrapper->>ToolFailure: create MCP_ERROR failure when isError is true
ToolFailure-->>MCPToolWrapper: structured failure
Priority: ⬇️ Low 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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
MCPToolWrapper(the external HTTPS URL resolution path used bymcp/tool_resolver.py::_resolve_external) returned the response text unconditionally from_execute_tooland never inspected theisErrorflag an MCP server sets on an otherwise successfultools/callresponse (lib/crewai/src/crewai/tools/mcp_tool_wrapper.py:185-187 on main). The error text reached the framework as a plainstr, so the call was recorded as a success: noToolFailureDetectedEventandToolOutput.has_tool_failuresstayed false.MCPNativeToolalready handles the same server answer by returningToolFailure(reason=MCP_ERROR)(lib/crewai/src/crewai/tools/mcp_native_tool.py:135-145).Changes
_execute_toolnow checksresult.isErrorafter extracting the content and returnsToolFailure(message=content, reason=ToolFailureReason.MCP_ERROR, details={"server": ..., "tool": ...}), matchingMCPNativeTool. Signatures along the retry path are widened tostr | ToolFailure. Successful calls are unchanged.Verification
Tests added or updated for the changed behavior
Relevant tests and quality checks pass locally
python -m pytest tests/tools/test_mcp_tool_wrapper.py -p no:randomly -q(fromlib/crewai) — 2 passedWith the source change reverted (tests only), the new test fails with
AssertionError: assert False + where False = isinstance('Error: file not found', ToolFailure), confirming the old code reported the server error as a successpython -m pytest tests/tools/ tests/mcp/ -p no:randomly -q— 326 passedruff check lib/crewai/src/crewai/tools/mcp_tool_wrapper.py lib/crewai/tests/tools/test_mcp_tool_wrapper.py— All checks passedmypy lib/crewai/src/crewai/tools/mcp_tool_wrapper.py— Success: no issues found in 1 source fileAdditional context
This PR was authored by an AI coding agent. Per
.github/CONTRIBUTING.mdit should carry thellm-generatedlabel; I don't have permission to apply labels, so a maintainer would need to add it.