Skip to content

fix: set MCP error flag for tool error payloads#95

Merged
blazickjp merged 1 commit into
mainfrom
fix/issue-92-mcp-error-flag
Apr 26, 2026
Merged

fix: set MCP error flag for tool error payloads#95
blazickjp merged 1 commit into
mainfrom
fix/issue-92-mcp-error-flag

Conversation

@blazickjp

Copy link
Copy Markdown
Owner

Fixes #92

Summary

  • Treat JSON tool responses with status: "error" as MCP tool errors at the server boundary.
  • Preserve the existing JSON error body while letting the MCP SDK emit isError: true.
  • Add a protocol-level regression test for get_abstract not-found responses.

Root cause

Tool handlers returned JSON error payloads as normal text content. The MCP Python SDK normalizes returned content with isError: false; it only sets isError: true when the registered tool callback raises/returns an SDK error result. So clients checking the MCP flag saw a successful tool call with an error-looking body.

Tests

  • uv run pytest tests/test_mcp_tool_error_semantics.py::test_get_abstract_not_found_sets_mcp_is_error -q
  • uv run pytest tests/tools/test_get_abstract.py tests/test_mcp_tool_error_semantics.py -q
  • uv run pytest -q

Treat JSON tool responses with status=error as MCP tool errors so clients receive isError=true. Adds protocol-level regression coverage for invalid get_abstract IDs.

Fixes #92
@blazickjp blazickjp merged commit c8c45f3 into main Apr 26, 2026
7 checks passed
@blazickjp blazickjp deleted the fix/issue-92-mcp-error-flag branch April 26, 2026 03:39
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.

get_abstract: returns error content but isError flag not set for invalid paper IDs

1 participant