Describe the Bug
When AgentGatewayClient.call_mcp_tool is used to invoke an MCP tool and the MCP server returns a spec-compliant error response (isError: true, HTTP 200, SSE event: message), the method returns None instead of a CallToolResult. Any subsequent access on the return value raises AttributeError: 'NoneType' object has no attribute 'isError'.
The MCP server side is correct — a direct tools/call against the MCP endpoint returns a well-formed response (see Expected Behavior). The failure is in how call_mcp_tool parses the SSE response for the isError: true case.
Steps to Reproduce
Set up an AgentGatewayClient pointing to an MCP server deployed via Agent Gateway.
Discover tools via agw_client.list_mcp_tools(user_token=...) and locate a tool whose backend can return an error (e.g. a lookup tool called with an ID that does not exist).
Call await agw_client.call_mcp_tool(tool, user_token=..., =).
The MCP server returns HTTP 200 + SSE event: message with isError: true (confirmed via direct call — see Expected Behavior).
call_mcp_tool returns None.
Access result.isError → AttributeError: 'NoneType' object has no attribute 'isError'.
Expected Behavior
A direct tools/call to the same MCP server with the same arguments returns a well-formed, spec-compliant response (MCP protocol 2025-11-25):
HTTP 200 — text/event-stream
event: message
data: {
"result": {
"content": [{"type": "text", "text": "{"status":500,"error":"HTTP Error","message":"Tool call failed"}"}],
"isError": true
},
"jsonrpc": "2.0",
"id": 3
}
call_mcp_tool should parse this SSE event and return a CallToolResult with isError=True and content populated. If parsing fails for any reason, it should raise an exception — returning None silently is never a valid outcome.
Screenshots
No response
Used Versions
sap-cloud-sdk 0.48.2
fastapi 0.135.3
langchain-core 1.5.3
langchain-mcp-adapters (version — run uv pip list to confirm)
Code Examples
Stack Trace
AttributeError: 'NoneType' object has no attribute 'isError'
The above exception was the direct cause of the following exception:
File "app/clients/mcp_validation_rule_wrapper.py", line 197, in _call_tool
result = await _invoke_with_timeout(tool, arguments)
(exception originates inside sap_cloud_sdk.agentgateway internals
when accessing result.isError on the None returned by call_mcp_tool)
Log File
INFO [mcp_wrapper] call tool= args=[...]
INFO Negotiated protocol version: 2025-11-25
INFO Loaded 7 MCP tool(s) from Agent Gateway (deployed mode)
ERROR Unexpected error during tool invocation
ERROR [mcp_wrapper] tool= error=Tool invocation failed for '':
'NoneType' object has no attribute 'isError'
INFO [mcp_wrapper] done tool= duration_ms=9603 status=error
Affected Development Phase
Development
Impact
Impaired
Timeline
No response
Describe the Bug
When AgentGatewayClient.call_mcp_tool is used to invoke an MCP tool and the MCP server returns a spec-compliant error response (isError: true, HTTP 200, SSE event: message), the method returns None instead of a CallToolResult. Any subsequent access on the return value raises AttributeError: 'NoneType' object has no attribute 'isError'.
The MCP server side is correct — a direct tools/call against the MCP endpoint returns a well-formed response (see Expected Behavior). The failure is in how call_mcp_tool parses the SSE response for the isError: true case.
Steps to Reproduce
Set up an AgentGatewayClient pointing to an MCP server deployed via Agent Gateway.
Discover tools via agw_client.list_mcp_tools(user_token=...) and locate a tool whose backend can return an error (e.g. a lookup tool called with an ID that does not exist).
Call await agw_client.call_mcp_tool(tool, user_token=..., =).
The MCP server returns HTTP 200 + SSE event: message with isError: true (confirmed via direct call — see Expected Behavior).
call_mcp_tool returns None.
Access result.isError → AttributeError: 'NoneType' object has no attribute 'isError'.
Expected Behavior
A direct tools/call to the same MCP server with the same arguments returns a well-formed, spec-compliant response (MCP protocol 2025-11-25):
HTTP 200 — text/event-stream
event: message
data: {
"result": {
"content": [{"type": "text", "text": "{"status":500,"error":"HTTP Error","message":"Tool call failed"}"}],
"isError": true
},
"jsonrpc": "2.0",
"id": 3
}
call_mcp_tool should parse this SSE event and return a CallToolResult with isError=True and content populated. If parsing fails for any reason, it should raise an exception — returning None silently is never a valid outcome.
Screenshots
No response
Used Versions
sap-cloud-sdk 0.48.2
fastapi 0.135.3
langchain-core 1.5.3
langchain-mcp-adapters (version — run uv pip list to confirm)
Code Examples
# Your code hereStack Trace
AttributeError: 'NoneType' object has no attribute 'isError'
The above exception was the direct cause of the following exception:
File "app/clients/mcp_validation_rule_wrapper.py", line 197, in _call_tool
result = await _invoke_with_timeout(tool, arguments)
(exception originates inside sap_cloud_sdk.agentgateway internals
when accessing result.isError on the None returned by call_mcp_tool)
Log File
INFO [mcp_wrapper] call tool= args=[...]
INFO Negotiated protocol version: 2025-11-25
INFO Loaded 7 MCP tool(s) from Agent Gateway (deployed mode)
ERROR Unexpected error during tool invocation
ERROR [mcp_wrapper] tool= error=Tool invocation failed for '':
'NoneType' object has no attribute 'isError'
INFO [mcp_wrapper] done tool= duration_ms=9603 status=error
Affected Development Phase
Development
Impact
Impaired
Timeline
No response