Back Home

GitHub Repo

Dify Community Proposes MCP Error-Handling Fix to Prevent Failed Tool Calls from Being Marked Successful

On November 12, the Dify community reported that workflows may treat an MCP tool response with the `isError` flag as successful and skip error-handling policies. The proposed fix includes unit tests but has not been merged; its impact on deployed versions remains unclear.

The original uploader was Ggia at Greek Wikipedia. · CC BY-SA 2.5 · Image source
zh-Hant

On November 12, the Dify community filed an issue report and proposed a fix, saying that MCP tool responses can be treated as normal tool output even when they explicitly return isError: true. The report describes a self-hosted source-code deployment labeled version 1.19.0, at main-branch commit f8fc371; this alone does not establish that all deployed versions are affected. Issue report

The problem lies in how protocol results map to workflow state. The MCP specification distinguishes JSON-RPC-level errors from tool execution errors: failed API calls, invalid input, or business-logic errors can be expressed through isError in an otherwise normal result object, with the error details placed in content. A response in the expected format therefore does not mean the tool ran successfully. MCP Tools specification

The reporter reproduced the issue with a mock server response: after a database tool returned a connection-refused message and an error flag, MCPTool._invoke did not raise an exception and instead produced a text message. According to the report, this causes the tool node to be marked successful, preventing failure branches, retries, and default-value policies from running; the agent also records the call as a normal observation. The error text remains available, but the workflow loses an explicit failure signal. Reproduction details

The proposed fix checks the flag and raises ToolInvokeError, following the existing error path for plugins and built-in tools while preserving the server’s message so the agent can try to correct its call. If there is no text content, it uses the tool name to construct an error message. Usage information is recorded before the exception is raised. The author says the added tests cover error results with text and with only non-text content; they fail on the original main branch and pass with the proposed change. Proposed fix

As of this review, the pull request remains open and awaits review by a code owner; it is not yet an official fix. Engineering teams can first use a test tool that explicitly returns an error flag to check whether node status and error branches behave as expected. Next steps are to track the merge and release and verify integration with real MCP services. Current evidence is mainly based on mock responses and unit tests, which is not enough to quantify the scale of production incidents.

Sources

  1. Dify issue #46107:MCP 錯誤結果被視為成功
  2. Dify PR #46108:依 isError 標記拋出工具錯誤
  3. Model Context Protocol:Tools 與錯誤處理規範