spring-projects/spring-ai · warning

Tool call arguments are null or empty for MCP tool: <toolNam

Error message

Tool call arguments are null or empty for MCP tool: <toolName>. Using empty JSON object as default.

What it means

AsyncMcpToolCallback.call() received a null/empty tool call input (typical when a model's streaming response yields no arguments) and, rather than failing JSON parsing, logs this warning and substitutes an empty JSON object "{}". The MCP tool is then invoked with no arguments, which may or may not be what the tool expects.

Source

Thrown at mcp/common/src/main/java/org/springframework/ai/mcp/AsyncMcpToolCallback.java:116

		return McpToolUtils.createToolDefinition(this.prefixedToolName, this.tool);
	}

	public String getOriginalToolName() {
		return this.tool.name();
	}

	@Override
	public String call(String toolCallInput) {
		return this.call(toolCallInput, null);
	}

	@Override
	public String call(String toolCallInput, @Nullable ToolContext toolContext) {

		// Handle the possible null parameter situation in streaming mode.
		if (!StringUtils.hasText(toolCallInput)) {
			if (logger.isWarnEnabled()) {
				logger.warn("Tool call arguments are null or empty for MCP tool: " + this.tool.name()
						+ ". Using empty JSON object as default.");
			}
			toolCallInput = "{}";
		}

		Map<String, Object> arguments = jsonHelper.fromJsonToMap(toolCallInput);

		CallToolResult response;
		try {
			var mcpMeta = toolContext != null ? this.toolContextToMcpMetaConverter.convert(toolContext) : null;

			// Use the original tool name, not the prefixed one from getToolDefinition
			var request = CallToolRequest.builder(this.tool.name()).arguments(arguments).meta(mcpMeta).build();

			// Only map non-McpError exceptions to ToolExecutionException. McpError is a
			// protocol-level signal (e.g. URL elicitation) that must propagate as a hard
			// failure rather than being conveyed to the model as an error result.
			response = this.mcpClient.callTool(request).onErrorMap(e -> !(e instanceof McpError), e -> {

View on GitHub (pinned to 98a7beda4f)

Solutions

  1. Ensure the tool actually accepts zero arguments; if it requires arguments, fix the prompting/schema so the model provides them.
  2. Validate toolCallInput has text before invoking the callback and provide a meaningful default or error.
  3. Check the MCP tool's inputSchema and pass required fields explicitly in the tool call input JSON.
  4. If the empty-object default is fine, this warning can be ignored or the logger level adjusted.

Example fix

// before: caller passes possibly-blank input
String result = toolCallback.call(modelToolInput);
// after: guard before the call
String result = toolCallback.call(
    StringUtils.hasText(modelToolInput) ? modelToolInput : "{\"mode\":\"default\"}");
Defensive patterns

Strategy: type-guard

Validate before calling

if (input == null || input.isBlank()) {
    input = "{}"; // or build the required arguments explicitly
}
Json.parse(input); // fail fast if not valid JSON before calling the tool

Type guard

boolean hasToolArguments(String input) {
    return input != null && !input.isBlank();
}

Try / catch

// the library does not throw; handle downstream tool errors
try {
    String result = callback.call(input);
} catch (NonToolExecutionException e) {
    logger.error("MCP tool rejected arguments", e);
}

Prevention

When it happens

Trigger: Calling call() on an async MCP tool callback where toolCallInput is null, empty, or whitespace — commonly when streaming model output produces tool calls without arguments, or when the caller passes an empty string.

Common situations: Models emitting argument-less tool invocations in streaming mode; frameworks forwarding blank tool inputs on tool-end events; integrations where the LLM decided no arguments were needed but the underlying MCP tool requires them (leading to a downstream tool error instead).

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 spring-projects/spring-ai@98a7beda4f (2026-09-11). Data as JSON: /api/errors/086a376e2398a6fb. Report an issue: GitHub.