Class AuditInterceptor

java.lang.Object
org.gridgain.internal.mcp.audit.AuditInterceptor

public class AuditInterceptor extends Object
Interceptor that wraps MCP tool execution handlers to capture audit events.

For each tool invocation, this interceptor:

  1. Records start time
  2. Extracts user identity and request context
  3. Executes the wrapped tool handler
  4. Extracts result metadata (row count, query)
  5. Logs audit event with timing information

Thread-safe and non-blocking - uses Reactor operators for async composition.

  • Constructor Details

    • AuditInterceptor

      public AuditInterceptor(AuditLogger auditLogger)
      Constructs a new audit interceptor.
      Parameters:
      auditLogger - the audit logger to use
  • Method Details

    • wrap

      public BiFunction<io.modelcontextprotocol.server.McpAsyncServerExchange,Map<String,Object>,reactor.core.publisher.Mono<io.modelcontextprotocol.spec.McpSchema.CallToolResult>> wrap(String toolName, BiFunction<io.modelcontextprotocol.server.McpAsyncServerExchange,Map<String,Object>,reactor.core.publisher.Mono<io.modelcontextprotocol.spec.McpSchema.CallToolResult>> handler)
      Wraps a tool handler with audit logging.
      Parameters:
      toolName - the name of the tool
      handler - the original tool handler
      Returns:
      wrapped handler that logs audit events