Open
Description
Description
If an MCP tool call receives a non-2xx response from its upstream service, the wrapper raises an AgentsException
. Because the tool never returns a result object, the agent cannot handle the failure and the entire turn aborts.
Steps to Reproduce
- Invoke any MCP tool with parameters that make the upstream API reply with an error (e.g., an invalid search query).
- Observe that the run terminates with an uncaught
AgentsException
.
Expected Result
The tool returns a structured error payload so the agent can decide how to respond.
Actual Result
An AgentsException
is raised and the run stops.
Sanitized Traceback
Error invoking MCP tool <tool_name>: GET <service-url>?q=<masked_query>: 422 <service-error>
Traceback (most recent call last):
File "<site-packages>/agents/mcp/util.py", line 104, in invoke_mcp_tool
result = await server.call_tool(tool.name, json_data)
...
mcp.shared.exceptions.McpError: GET <service-url>: 422 <service-error>
agents.exceptions.AgentsException: Error invoking MCP tool <tool_name>: ...