Skip to content

SyncMcpToolCallback call fails with UnsupportedOperationException if ToolContext is set #2378

@henningSaulCM

Description

@henningSaulCM

Bug description
Integrating and calling an MCP Tool with an existing Spring AI application that uses a ToolContext will result in an UnsupportedOperationException.

Environment
Spring AI 1.0.0-M6

Steps to reproduce

  1. Integrate https://github.com/modelcontextprotocol/servers/tree/main/src/everything into a Spring AI application using https://docs.spring.io/spring-ai/reference/api/mcp/mcp-client-boot-starter-docs.html
  2. Set the ToolContext in your Spring AI application
  3. Call one of the tools provided by the everything MCP server, e.g. printEnv
  4. Observe "UnsupportedOperationException: Tool context is not supported!" for SyncMcpToolCallback

Exception is raised here:

throw new UnsupportedOperationException("Tool context is not supported!");

Expected behavior
The MCP printEnv tool is called, ignoring the ToolContext (assuming this concept is not supported in MCP).

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions