Files
cleveragents-core/features
freemo b96138b88e fix(mcp): extract error message from content[0].text per MCP 1.4.0 protocol
MCPToolAdapter.invoke() was reading error messages from result.get('error',
'unknown error'), but the MCP 1.4.0 protocol returns errors in the content
field as a list of content items with type and text keys. This caused every
error from a real MCP 1.4.0-compliant server to be silently replaced with
the string 'unknown error'.

Changes:
- src/cleveragents/mcp/adapter.py: extract error_text from content[0].text
  with safe guards (isinstance check, length check) and fallback to
  'unknown error' when content is absent or empty
- features/mocks/mock_mcp_transport.py: return MCP 1.4.0-compliant error
  responses using content list format instead of the non-standard error key
- features/tdd_mcp_error_content_key.feature: Behave scenario verifying
  correct error extraction from MCP 1.4.0 content arrays (written as TDD
  issue-capture, @tdd_expected_fail removed after fix applied)
- features/steps/tdd_mcp_error_content_key_steps.py: step definitions for
  the new scenario including _MCP14ErrorTransport mock subclass

All 51 MCP adapter scenarios pass. Typecheck: 0 errors. Lint: clean.

ISSUES CLOSED: #2158
2026-04-03 19:03:15 +00:00
..