iflytek/astron-agent · error · PluginExc

40027

40027

Error message

Failed to execute MCP server tool

What it means

RunMcpPluginExc raised in McpPluginRunner.run (mcp.py:73). The MCP plugin runner POSTs tool execution to RUN_MCP_PLUGIN_URL with an aiohttp timeout of MCP_CALL_TIMEOUT (default 90s); when the request exceeds it, asyncio.TimeoutError is caught and re-raised as the generic 40027 'Failed to execute MCP server tool'.

Solutions

  1. Check whether the MCP server/tool itself is hung; test it directly outside the agent.
  2. Raise the MCP_CALL_TIMEOUT env var (seconds) to accommodate legitimately slow tools.
  3. Verify MCP plugin service health/resource usage; scale it if the queue is backing up.
  4. Add retry-once-with-backoff for idempotent tools to tolerate transient slowness.

Example fix

// before
timeout = aiohttp.ClientTimeout(total=int(os.getenv("MCP_CALL_TIMEOUT", "90")))
// after: give long tools more headroom
os.environ.setdefault("MCP_CALL_TIMEOUT", "180")
timeout = aiohttp.ClientTimeout(total=int(os.getenv("MCP_CALL_TIMEOUT", "90")))
Defensive patterns

Strategy: retry

Validate before calling

timeout_s = int(os.getenv("MCP_CALL_TIMEOUT", "90"))
if timeout_s < expected_tool_max_seconds:
    logger.warning("MCP_CALL_TIMEOUT=%s may be too low for this tool", timeout_s)

Try / catch

try:
    result = await runner.run(action_input, span)
except RunMcpPluginExc as e:
    if isinstance(e.__cause__, asyncio.TimeoutError):
        logger.warning("MCP tool timed out; tool=%s timeout=%ss", runner.name, timeout_s)
    raise

Prevention

When it happens

Trigger: Calling McpPluginRunner.run where the MCP plugin service takes longer than MCP_CALL_TIMEOUT seconds to respond to the tool-execution POST.

Common situations: Slow or hanging downstream MCP server tool, MCP plugin service overloaded, network latency between agent and plugin, MCP_CALL_TIMEOUT set too low for a legitimately long-running tool.

Understand the failure class

Background: Request timed out: what client-side request timeouts mean across libraries (Request timed out, TIMED_OUT, APITimeoutError) — this error's family across 39 libraries.

Related errors


AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12). Data as JSON: /api/errors/1a1fe2005dda9dcf. Report an issue: GitHub.

Appendix: source

Thrown at core/agent/service/plugin/mcp.py:73

                        response.raise_for_status()
                        if response.status == 200:
                            resp = await response.json()
                            sp.add_info_events(
                                attributes={
                                    "mcp-plugin-run-outputs": json.dumps(
                                        resp, ensure_ascii=False
                                    )
                                }
                            )
                        else:
                            sp.add_info_events(
                                attributes={
                                    "mcp-plugin-run-outputs": (
                                        f"response code is {response.status}"
                                    )
                                }
                            )
                            raise RunMcpPluginExc
            except asyncio.TimeoutError as e:
                raise RunMcpPluginExc from e

            end_time = int(round(time.time() * 1000))
            plugin_response = PluginResponse(
                code=resp.get("code", ""),
                sid=resp.get("sid", ""),
                start_time=start_time,
                end_time=end_time,
                result=resp,
                log=[{"name": self.name, "input": action_input, "output": resp}],
            )

            return plugin_response


class McpPluginFactory(BaseModel):
    app_id: str

View on GitHub (pinned to 5e758547a8)