Interface AsyncModernMcpToolCallCustomizer

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface AsyncModernMcpToolCallCustomizer
Customizes a single call of a modern MCP tool, with the ToolContext of that call at hand.

AsyncModernMcpToolCallback applies it to the request spec of each call, after the arguments and the _meta entries are set. It can set anything a McpAsyncClient.ToolSpec offers for one call, in particular the elicitation handlers and the progress listener, which replace those of the client for that call. A handler set here can read the ToolContext, for example to find the user it has to ask, which a handler set on the client cannot.

Since:
2.1.0
Author:
Christian Tzolov
See Also:
  • AsyncModernMcpToolCallbackProvider.Builder.toolCallCustomizer
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns a customizer that applies this customizer and then the given one to the spec this one returned.
    io.modelcontextprotocol.modern.client.McpAsyncClient.ToolSpec
    customize(McpModernConnectionInfo connectionInfo, io.modelcontextprotocol.modern.client.McpAsyncClient.ToolSpec toolSpec, @Nullable ToolContext toolContext)
    Customizes the request spec of a tool call.
  • Method Details

    • customize

      io.modelcontextprotocol.modern.client.McpAsyncClient.ToolSpec customize(McpModernConnectionInfo connectionInfo, io.modelcontextprotocol.modern.client.McpAsyncClient.ToolSpec toolSpec, @Nullable ToolContext toolContext)
      Customizes the request spec of a tool call.
      Parameters:
      connectionInfo - the connection the tool belongs to
      toolSpec - the request spec of the call; specs are immutable, so every setter returns a new one
      toolContext - the tool context of the call, or null if the tool is called without one
      Returns:
      the spec to call the tool with
    • andThen

      Returns a customizer that applies this customizer and then the given one to the spec this one returned. What the second one sets replaces what the first one set.
      Parameters:
      next - the customizer to apply after this one
      Returns:
      the composed customizer