Class AbstractSyncMcpToolMethodCallback<T,RC extends McpRequestContextTypes<?>>
java.lang.Object
org.springaicommunity.mcp.method.tool.AbstractMcpToolMethodCallback<T,RC>
org.springaicommunity.mcp.method.tool.AbstractAsyncMcpToolMethodCallback<T,RC>
org.springaicommunity.mcp.method.tool.AbstractSyncMcpToolMethodCallback<T,RC>
- 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
-
Field Summary
Fields inherited from class org.springaicommunity.mcp.method.tool.AbstractAsyncMcpToolMethodCallback
toolCallExceptionClassFields inherited from class org.springaicommunity.mcp.method.tool.AbstractMcpToolMethodCallback
returnMode, toolMethod, toolObject -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractSyncMcpToolMethodCallback(ReturnMode returnMode, Method toolMethod, Object toolObject, Class<? extends Throwable> toolCallExceptionClass) -
Method Summary
Modifier and TypeMethodDescriptionprotected io.modelcontextprotocol.spec.McpSchema.CallToolResultCreates an error result for exceptions that occur during method invocation.protected io.modelcontextprotocol.spec.McpSchema.CallToolResultprocessResult(Object result) Processes the result of the method invocation and converts it to a CallToolResult.protected voidvalidateSyncRequest(io.modelcontextprotocol.spec.McpSchema.CallToolRequest request) Validates that the request is not null.Methods inherited from class org.springaicommunity.mcp.method.tool.AbstractAsyncMcpToolMethodCallback
convertToCallToolResult, createAsyncErrorResult, isExchangeOrContextType, mapValueToCallToolResult, validateRequestMethods inherited from class org.springaicommunity.mcp.method.tool.AbstractMcpToolMethodCallback
buildMethodArguments, buildTypedArgument, callMethod, convertValueToCallToolResult, createErrorMessage, createRequestContext, findCauseUsingPlainJava
-
Constructor Details
-
AbstractSyncMcpToolMethodCallback
protected AbstractSyncMcpToolMethodCallback(ReturnMode returnMode, Method toolMethod, Object toolObject, Class<? extends Throwable> toolCallExceptionClass)
-
-
Method Details
-
processResult
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
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
-