iflytek/astron-agent · error · ValueError

toolName cannot be empty

Error message

toolName cannot be empty

What it means

McpNode's model_validator (validate_fields) rejects construction when toolName is empty — a Pydantic declarative guard on the node config. A workflow MCP node without a tool name could never dispatch an execution, so it fails at model validation instead.

Solutions

  1. Set toolName to the exact MCP tool name exposed by the server (e.g. 'web_search')
  2. In the workflow editor, open the MCP node and select a tool from the server's tool list
  3. Verify the chosen MCP server actually exposes the tool name referenced

Example fix

// before
{"mcpServerId": "srv-123", "toolName": ""}
// after
{"mcpServerId": "srv-123", "toolName": "web_search"}
Defensive patterns

Strategy: validation

Validate before calling

if not node_config.get("toolName"):
    raise ValueError("toolName is required for MCP nodes")

Type guard

def has_tool_name(cfg: dict) -> bool:
    return bool(isinstance(cfg.get("toolName"), str) and cfg["toolName"].strip())

Try / catch

from pydantic import ValidationError
try:
    node = MCPNode(**node_config)
except ValidationError as e:
    # surface 'toolName cannot be empty' to the workflow editor
    ...

Prevention

When it happens

Trigger: An MCP node is defined with a valid server (mcpServerId or mcpServerUrl) but toolName is '' or missing, e.g. the user never picked a tool in the node editor.

Common situations: Tool list failed to load in the UI so no tool was selected; workflow JSON imported without the toolName field; server's tools changed and the previous selection was cleared.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


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

Appendix: source

Thrown at core/workflow/engine/nodes/mcp/mcp_node.py:42

    """
    MCP (Model Context Protocol) execution node for workflow execution.

    This node enables calling MCP tools from external MCP servers within workflows,
    supporting dynamic tool execution with configurable parameters and server endpoints.
    """

    _private_config = PrivateConfig()
    mcpServerId: str = Field(default="", description="MCP server unique identifier")
    mcpServerUrl: str = Field(default="", description="MCP server endpoint URL")
    toolName: str = Field(..., description="Name of the MCP tool to execute")

    @model_validator(mode="after")
    def validate_fields(self) -> "MCPNode":
        """Validate field constraints."""
        if not self.mcpServerId and not self.mcpServerUrl:
            raise ValueError("mcpServerId and mcpServerUrl cannot both be empty")
        if not self.toolName:
            raise ValueError("toolName cannot be empty")
        return self

    async def execute(
        self,
        variable_pool: VariablePool,
        span: Span,
        event_log_node_trace: NodeLog | None = None,
    ) -> NodeRunResult:
        """
        Execute the MCP tool call operation.

        Retrieves input variables, constructs the MCP tool call request,
        sends it to the MCP server, and returns the results.

        :param variable_pool: Pool containing workflow variables
        :param span: Span object for tracing and logging
        :param event_log_node_trace: Optional node log trace object
        :return: NodeRunResult containing the tool execution results or error information

View on GitHub (pinned to 5e758547a8)