Class ToolRegistryUtils

java.lang.Object
org.gridgain.internal.mcp.utils.ToolRegistryUtils

public class ToolRegistryUtils extends Object
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 Details

    • ToolRegistryUtils

      public ToolRegistryUtils()
  • Method Details

    • setAuditInterceptor

      public static void setAuditInterceptor(AuditInterceptor interceptor)
      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,Object>,reactor.core.publisher.Mono<io.modelcontextprotocol.spec.McpSchema.CallToolResult>> getMcpAsyncServerExchangeMapMonoBiFunction(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 invoke
      handlerClass - 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