iflytek/astron-agent · error · PluginExc

40026

40026

Error message

Failed to get MCP server protocol

What it means

GetMcpPluginExc raised in McpPlugin.query_servers (mcp.py:183). When the MCP list-servers HTTP response is not 200 (raise_for_status throws), the exception handler records the status in a span event and re-raises the generic 40026 'Failed to get MCP server protocol'.

Solutions

  1. Read span event 'mcp-plugin-list-outputs' for the HTTP status and inspect MCP plugin service logs.
  2. Verify the plugin service is up and reachable: curl LIST_MCP_PLUGIN_URL from inside the agent container.
  3. Fix the URL/auth configuration if 4xx; restart or scale the plugin service if 5xx.
  4. Wrap build_tools so a transient list failure degrades gracefully instead of failing the whole agent run.

Example fix

// before
servers = await mcp_plugin.query_servers(span)
// after
try:
    servers = await mcp_plugin.query_servers(span)
except GetMcpPluginExc:
    logger.warning("MCP server list unavailable; continuing without MCP tools")
    servers = []
Defensive patterns

Strategy: fallback

Validate before calling

import aiohttp
async def mcp_list_reachable(url: str) -> bool:
    try:
        async with aiohttp.ClientSession() as s:
            async with s.post(url, json={}, timeout=aiohttp.ClientTimeout(total=5)) as r:
                return r.status < 500
    except Exception:
        return False

Type guard

def is_http_ok(response: aiohttp.ClientResponse) -> bool:
    return response.status == 200

Try / catch

try:
    servers = await mcp_plugin.query_servers(span)
except GetMcpPluginExc:
    logger.warning("MCP server list failed; continuing without MCP tools")
    servers = []

Prevention

When it happens

Trigger: POST to LIST_MCP_PLUGIN_URL returning 4xx/5xx during build_tools: plugin service down, bad URL, auth rejected, gateway error (502/503/504).

Common situations: MCP plugin service crashed or being redeployed, wrong LIST_MCP_PLUGIN_URL host/port, network policy or DNS failure between agent and plugin, ingress misconfiguration.

Understand the failure class

Background: "API error: {status}" and "HTTP 401/403/404/429/5xx" errors: non-2xx HTTP responses explained — this error's family across 27 libraries.

Related errors


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

Appendix: source

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

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

            code = resp.get("code")
            if code != 0:
                raise GetMcpPluginExc

            servers_list = resp.get("data", {}).get("servers", [])

            # Type cast to ensure return type matches annotation
            return cast(
                list[dict[Any, Any]],
                servers_list if isinstance(servers_list, list) else [],
            )

    @staticmethod
    async def convert_tool(tool: dict) -> str:
        property_template = json.dumps(

View on GitHub (pinned to 5e758547a8)