Package org.gridgain.internal.mcp.utils
Class ToolRegistryUtils
java.lang.Object
org.gridgain.internal.mcp.utils.ToolRegistryUtils
Utility class for creating and configuring MCP tool handlers.
Provides helper methods to dynamically create tool handlers using reflection
and automatically wrap them with rate limiting if the target method is annotated with RateLimited.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic BiFunction<io.modelcontextprotocol.server.McpAsyncServerExchange,Map<String, Object>, reactor.core.publisher.Mono<io.modelcontextprotocol.spec.McpSchema.CallToolResult>> getMcpAsyncServerExchangeMapMonoBiFunction(String toolName, String methodName, Class<?> handlerClass) Creates a BiFunction handler for an MCP tool by dynamically invoking a static method via reflection.static voidsetAuditInterceptor(AuditInterceptor interceptor) Sets the audit interceptor for all tools.
-
Constructor Details
-
ToolRegistryUtils
public ToolRegistryUtils()
-
-
Method Details
-
setAuditInterceptor
Sets the audit interceptor for all tools. Called once during server initialization.- Parameters:
interceptor- the audit interceptor
-
getMcpAsyncServerExchangeMapMonoBiFunction
public static BiFunction<io.modelcontextprotocol.server.McpAsyncServerExchange,Map<String, getMcpAsyncServerExchangeMapMonoBiFunctionObject>, reactor.core.publisher.Mono<io.modelcontextprotocol.spec.McpSchema.CallToolResult>> (String toolName, String methodName, Class<?> handlerClass) throws NoSuchMethodException Creates a BiFunction handler for an MCP tool by dynamically invoking a static method via reflection. Automatically wraps the handler with: 1. Rate limiting (if method has @RateLimited annotation) 2. Audit logging (if audit interceptor is configured)- Parameters:
toolName- Name of the MCP tool (used for logging and rate limiting)methodName- Name of the static handler method to invokehandlerClass- Class containing the static handler method- Returns:
- BiFunction handler wrapped with rate limiting (if applicable)
- Throws:
NoSuchMethodException- if the specified method doesn't exist or has wrong signature
-