Class AbstractSyncMcpToolMethodCallback<T,RC extends McpRequestContextTypes<?>>

Type Parameters:
T - The type of the context parameter (e.g., McpTransportContext or McpSyncServerExchange)
Direct Known Subclasses:
SyncMcpToolMethodCallback, SyncStatelessMcpToolMethodCallback

public abstract class AbstractSyncMcpToolMethodCallback<T,RC extends McpRequestContextTypes<?>> extends AbstractAsyncMcpToolMethodCallback<T,RC>
Abstract base class for creating Function callbacks around synchronous tool methods. This class extends AbstractAsyncMcpToolMethodCallback and provides synchronous wrapper methods for handling tool requests. It converts the asynchronous reactive methods from the parent class into synchronous equivalents suitable for blocking operations.
Author:
Christian Tzolov
  • Constructor Details

    • AbstractSyncMcpToolMethodCallback

      protected AbstractSyncMcpToolMethodCallback(ReturnMode returnMode, Method toolMethod, Object toolObject, Class<? extends Throwable> toolCallExceptionClass)
  • Method Details

    • processResult

      protected io.modelcontextprotocol.spec.McpSchema.CallToolResult processResult(Object result)
      Processes the result of the method invocation and converts it to a CallToolResult. This is a synchronous wrapper around the parent class's reactive result processing.
      Parameters:
      result - The result from the method invocation
      Returns:
      A CallToolResult representing the processed result
    • createSyncErrorResult

      protected io.modelcontextprotocol.spec.McpSchema.CallToolResult createSyncErrorResult(Exception e)
      Creates an error result for exceptions that occur during method invocation. This is a synchronous wrapper around the parent class's reactive error handling.
      Parameters:
      e - The exception that occurred
      Returns:
      A CallToolResult representing the error
    • validateSyncRequest

      protected void validateSyncRequest(io.modelcontextprotocol.spec.McpSchema.CallToolRequest request)
      Validates that the request is not null. This is a synchronous wrapper around the parent class's reactive validation.
      Parameters:
      request - The request to validate
      Throws:
      IllegalArgumentException - if the request is null