🐞 Bug Summary
When an upstream MCP server returns a tool execution error (isError: true), the gateway still attempts to validate the error response against the tool's outputSchema. Since error responses naturally don't conform to the success schema, the original error message (e.g., "Workflow is not available in MCP") is replaced with a generic "Output validation error: outputSchema defined but no structured output returned", hiding the actual error cause from the user.
🧩 Affected Component
Select the area of the project impacted:
🔁 Steps to Reproduce
- Register an upstream MCP server that defines outputSchema on its tools (e.g., n8n Instance-level MCP server)
- Call a tool that returns an error response with isError: true and a text content error message — for example, calling get_workflow_details on a workflow that has MCP access disabled
- The upstream server responds with:
{
"result": {
"content": [{"type": "text", "text": "Workflow is not available in MCP. Enable MCP access in workflow settings."}],
"isError": true
}
}
- Instead of passing through this error message, the gateway returns: "Output validation error: outputSchema defined but no structured output returned"
🤔 Expected Behavior
When isError: true is set in the tool result, outputSchema validation should be skipped entirely and the original error content should be passed through to the client as-is. Per the MCP spec, outputSchema defines the expected structure for successful tool results, not error responses.
📓 Logs / Error Output
# Gateway logs show MCP call succeeds but tool invocation is marked as failed:
[tool_service] MCP tool call completed: get_workflow_details (success: true)
[tool_service] Tool 'n8n-get-workflow-details' invocation failed (error_message: null)
The issue is in mcpgateway/services/tool_service.py, method _extract_and_validate_structured_content() (around line 1111). The method checks for output_schema presence but does not check tool_result.is_error before proceeding with validation.
🧠 Environment Info
You can retrieve most of this from the /version endpoint.
| Key |
Value |
| Version or commit |
latest main |
| Runtime |
Python3.12 |
| Platform / OS |
Linux |
| Container |
Docker |
🧩 Additional Context (optional)
- This affects any upstream MCP server that defines outputSchema and can return tool execution errors.
🐞 Bug Summary
When an upstream MCP server returns a tool execution error (isError: true), the gateway still attempts to validate the error response against the tool's outputSchema. Since error responses naturally don't conform to the success schema, the original error message (e.g., "Workflow is not available in MCP") is replaced with a generic "Output validation error: outputSchema defined but no structured output returned", hiding the actual error cause from the user.
🧩 Affected Component
Select the area of the project impacted:
mcpgateway- APImcpgateway- UI (admin panel)mcpgateway.wrapper- stdio wrapper🔁 Steps to Reproduce
{ "result": { "content": [{"type": "text", "text": "Workflow is not available in MCP. Enable MCP access in workflow settings."}], "isError": true } }🤔 Expected Behavior
When isError: true is set in the tool result, outputSchema validation should be skipped entirely and the original error content should be passed through to the client as-is. Per the MCP spec, outputSchema defines the expected structure for successful tool results, not error responses.
📓 Logs / Error Output
The issue is in mcpgateway/services/tool_service.py, method _extract_and_validate_structured_content() (around line 1111). The method checks for output_schema presence but does not check tool_result.is_error before proceeding with validation.
🧠 Environment Info
You can retrieve most of this from the
/versionendpoint.latest mainPython3.12LinuxDocker🧩 Additional Context (optional)