{"record":{"id":"9fe2005275e68a77","repo":"alibaba/spring-ai-alibaba","slug":"mcp-call-fail-e-getmessage","errorCode":null,"errorMessage":"MCP call fail: {e.getMessage()}","messagePattern":"MCP call fail: (.+?)","errorType":"exception","errorClass":"McpNodeException","httpStatus":null,"severity":"error","filePath":"spring-boot-starters/spring-ai-alibaba-starter-builtin-nodes/src/main/java/com/alibaba/cloud/ai/graph/node/McpNode.java","lineNumber":126,"sourceCode":"\t\t// 2. Then use params (after variable replacement) to overwrite\n\t\tMap<String, Object> replacedParams = replaceVariablesObj(params, state);\n\t\tif (replacedParams != null) {\n\t\t\tfinalParams.putAll(replacedParams);\n\t\t}\n\t\tlog.info(\"[McpNode] after replace params: url={}, tool={}, headers={}, params={}\", url, finalTool, headers,\n\t\t\t\tfinalParams);\n\n\t\t// Directly use the already initialized client\n\t\tCallToolResult result;\n\t\ttry {\n\t\t\tMcpSchema.CallToolRequest request = new McpSchema.CallToolRequest(finalTool, finalParams);\n\t\t\tlog.info(\"[McpNode] CallToolRequest: {}\", request);\n\t\t\tresult = client.callTool(request);\n\t\t\tlog.info(\"[McpNode] tool call result: {}\", result);\n\t\t}\n\t\tcatch (Exception e) {\n\t\t\tlog.error(\"[McpNode] MCP call fail:\", e);\n\t\t\tthrow new McpNodeException(\"MCP call fail: \" + e.getMessage(), e);\n\t\t}\n\n\t\t// Result handling\n\t\tMap<String, Object> updatedState = new HashMap<>();\n\t\t// updatedState.put(\"mcp_result\", result.content());\n\t\tupdatedState.put(\"messages\", result.content());\n\t\tif (StringUtils.hasLength(this.outputKey)) {\n\t\t\tObject content = result.content();\n\t\t\tif (content instanceof List<?> list && !CollectionUtils.isEmpty(list)) {\n\t\t\t\tObject first = list.get(0);\n\t\t\t\t// Compatible with the text field of TextContent\n\t\t\t\tif (first instanceof TextContent textContent) {\n\t\t\t\t\tupdatedState.put(this.outputKey, textContent.text());\n\t\t\t\t}\n\t\t\t\telse if (first instanceof Map<?, ?> map && map.containsKey(\"text\")) {\n\t\t\t\t\tupdatedState.put(this.outputKey, map.get(\"text\"));\n\t\t\t\t}\n\t\t\t\telse {","sourceCodeStart":108,"sourceCodeEnd":144,"githubUrl":"https://github.com/alibaba/spring-ai-alibaba/blob/f82da0b50f35744c13968191be2b1cd2452ef550/spring-boot-starters/spring-ai-alibaba-starter-builtin-nodes/src/main/java/com/alibaba/cloud/ai/graph/node/McpNode.java#L108-L144","documentation":"McpNode.apply() wraps any exception thrown while invoking the remote MCP tool (client.callTool) in a McpNodeException prefixed with 'MCP call fail:'. The original exception is chained as the cause. It signals that the MCP tool invocation itself failed — network, protocol, tool-argument, or server-side error — not that the node was misconfigured.","triggerScenarios":"client.callTool(request) throws: MCP server unreachable, tool name not found, invalid tool arguments, timeout, or server returns a protocol error during graph execution of the McpNode.","commonSituations":"MCP server not running or wrong SSE/stdio endpoint; tool schema changed so arguments no longer validate; network/firewall blocking the MCP endpoint; MCP client misconfigured in application properties.","solutions":["Read the chained cause (e.getCause()) to find the root failure","Verify the MCP server is running and the configured endpoint/connection is correct","Confirm the tool name and arguments in the CallToolRequest match the server's tool schema","Add retry/timeout handling around the node for transient network failures"],"exampleFix":"try {\n    state = mcpNode.apply(state);\n} catch (McpNodeException e) {\n    log.error(\"MCP tool invocation failed\", e.getCause());\n    // fallback or rethrow\n}","handlingStrategy":"try-catch","validationCode":"// verify connectivity before graph run\nboolean reachable = mcpEndpoint != null && !mcpEndpoint.isBlank();","typeGuard":null,"tryCatchPattern":"try { state = mcpNode.apply(state); } catch (McpNodeException e) { Throwable root = e.getCause(); log.error(\"MCP call failed\", root); }","preventionTips":["Health-check the MCP server before running the graph","Pin tool names/schemas and validate arguments before callTool","Set explicit timeouts and retry transient network failures"],"tags":["mcp","network","tool-call"],"backgroundTag":"api-request-failed","analyzedSha":"f82da0b50f35744c13968191be2b1cd2452ef550","analyzedAt":"2026-09-09T15:32:42.421Z","contentChangedAt":"2026-09-09T15:32:42.421Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}