spring-projects / spring-projects/spring-ai

Tools MethodToolCallback, parameter name cannot be matched

Open
#2,947 7 comments 0 reactions 1 assignee View on GitHub

@tzolov is already working on this.

Since May 4, 2025.

bug mcp
Dominant language
Java
Stars
9.5k
Forks
2.9k
Avg merge
1d 7h
Merged PRs (30d)
6

Description

Please do a quick search on GitHub issues first, there might be already a duplicate issue for the one you are about to create.
If the bug is trivial, just go ahead and create the issue. Otherwise, please take a few moments and fill in the following sections:

Bug description
The parameter[name, value] is always null

  @Tool(description = "get combo data")
  public ComboDto getCombo(String name, String value) {
    log.info("==>name: {},value: {}", name, value);
    return new ComboDto(name, "Item." + value);
  }

client Test

  @Test
  void getCombo() {
    Map<String, Object> params = new HashMap<>();
    params.put("name", "label");
    params.put("value", "Root");

    McpSchema.CallToolResult result = mcpSyncClients.callTool(new McpSchema.CallToolRequest("getCombo", params));
    log.info("==>result: {}", JsonUtils.toJsonString(result));
  }

Client config

spring:
  ai:
    mcp:
      client:
        enabled: true
        name: mcp-client
        version: v1.0.0
        request-timeout: 10s
        type: sync
        sse:
          connections:
            server1:
              url: http://localhost:18080

MethodToolCallback(Line number 138), Object rawArgument = toolInputArguments.get(parameter.getName()) is null

private Object[] buildMethodArguments(Map<String, Object> toolInputArguments, @Nullable ToolContext toolContext) {
	return Stream.of(toolMethod.getParameters()).map(parameter -> {
		if (parameter.getType().isAssignableFrom(ToolContext.class)) {
			return toolContext;
		}
		Object rawArgument = toolInputArguments.get(parameter.getName());
		return buildTypedArgument(rawArgument, parameter.getType());
	}).toArray();
}

Environment
Please provide as many details as possible: Spring AI version, Java version, which vector store you use if any, etc

<dependency>
      <groupId>org.springframework.ai</groupId>
      <artifactId>spring-ai-starter-mcp-server-webmvc</artifactId>
      <version>1.0.0-M7</version>
  </dependency>

jdk

openjdk version "17.0.11" 2024-04-16
OpenJDK Runtime Environment Temurin-17.0.11+9 (build 17.0.11+9)
OpenJDK 64-Bit Server VM Temurin-17.0.11+9 (build 17.0.11+9, mixed mode, sharing)

Steps to reproduce
Steps to reproduce the issue.

Expected behavior
MCP server can obtain the passed parameters normally.

Can anyone help me?

Minimal Complete Reproducible example
Please provide a failing test or a minimal complete verifiable example that reproduces the issue.
Bug reports that are reproducible will take priority in resolution over reports that are not reproducible.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.