fix(tasks): raise on failure so isError=true on the MCP wire#36
Open
sanjibani wants to merge 1 commit into
Open
fix(tasks): raise on failure so isError=true on the MCP wire#36sanjibani wants to merge 1 commit into
sanjibani wants to merge 1 commit into
Conversation
9 `except APIError as e: return _format_error(e)` and 9
`except Exception as e: return json.dumps({"error": True, ...})`
sites in apps/mcp-server/src/taskflow_mcp/tools/tasks.py all returned
JSON-encoded error strings. FastMCP wraps those as success content
with isError=false, so MCP clients treat the failure as data and the
LLM often proceeds as if the call had succeeded.
This is the same isError-compliance gap flagged in the recent MCP
security audit (Dayna Blackwell, 'Tool Poisoning, Rug Pulls, and
Prompt Injections — oh my!').
Each return is replaced with bare `raise` so the original exception
propagates and FastMCP sets isError=true on the wire while preserving
the formatted message in content for the LLM.
Regression test: apps/mcp-server/tests/test_iserror_compliance.py
asserts that a failing create_task call surfaces as ToolError
(isError=true on the wire).
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
9
except APIError as e: return _format_error(e)and 9except Exception as e: return json.dumps({"error": True, ...})sites inapps/mcp-server/src/taskflow_mcp/tools/tasks.pyall returned JSON-encoded error strings. FastMCP wraps those as success content withisError=false, so MCP clients treat the failure as data and the LLM often proceeds as if the call had succeeded.This is the same
isError-compliance gap flagged in the recent MCP security audit (Dayna Blackwell, Tool Poisoning, Rug Pulls, and Prompt Injections — oh my!).Changes
Each return is replaced with bare
raiseso the original exception propagates and FastMCP setsisError=trueon the wire while preserving the formatted message incontentfor the LLM.Tests
apps/mcp-server/tests/test_iserror_compliance.pyasserts that a failingcreate_taskcall surfaces asToolError(isError=true on the wire).Reference: https://composio.dev/blog/mcp-security-vulnerabilities