Skip to content

Tools MethodToolCallback, parameter name cannot be matched #2947

Open
@leelance

Description

@leelance

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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions