Skip to content

SyncMcpToolCallback call method NPE #2447

@Fj-ivy

Description

@Fj-ivy

Bug description
A clear and concise description of what the bug is about.
I create mcp client to invoke @modelcontextprotocol/server-filesystem by stdio. It can invoke server-filesystem success, But when
SyncMcpToolCallback call method response field error is null, it will NPE.

Image

Environment
Spring AI version: 1.0.0-SNAPSHOT
Java Version: 21

Steps to reproduce

  • application.properties
spring.application.name=mcp-examples
 spring.ai.ollama.base-url=http://localhost:11434
 spring.ai.ollama.chat.model=qwen2.5:latest
 spring.ai.mcp.client.enabled=true
 spring.ai.mcp.client.name=mcp-client
 spring.ai.mcp.client.version=1.0.0
 spring.ai.mcp.client.type=SYNC
 spring.ai.mcp.client.request-timeout=30s
 spring.ai.mcp.client.stdio.servers-configuration=classpath:/mcp-servers-config.json
  • mcp-servers-config.json
{
      "mcpServers": {
        "filesystem": {
          "command": "npx",
          "args": [
            "-y",
            "@modelcontextprotocol/server-filesystem",
            "."
          ]
        }
      }
    }
  • controller
@RestController
public class FileSystemController {

    @Resource
    private OllamaChatModel ollamaChatModel;

    @Resource
    private SyncMcpToolCallbackProvider toolCallbackProvider;

    @GetMapping("/chat")
    public String call(@RequestParam String input) {
        ChatClient chatClient = ChatClient.builder(ollamaChatModel)
                .defaultTools(toolCallbackProvider.getToolCallbacks())
                .build();
        return chatClient.prompt(input).call().content();
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions