Class GrouperMcpToolLogUtil

java.lang.Object
edu.internet2.middleware.grouper.ws.mcp.GrouperMcpToolLogUtil

public class GrouperMcpToolLogUtil extends Object
Utility class for MCP tool call audit logging and throttle checking. Handles inserting audit log entries into grouper_mcp_tool_log and checking rate limits based on recent call counts from that table.
  • Constructor Details

    • GrouperMcpToolLogUtil

      public GrouperMcpToolLogUtil()
  • Method Details

    • logToolCall

      public static void logToolCall(GrouperMcpAuthUser authUser, String toolName, String toolCategory, String requestJson, String responseOrError, boolean isError, long startedMicros, Long durationMicros)
      Log an MCP tool call to the audit table.
      Parameters:
      authUser - the authenticated user
      toolName - the tool name
      toolCategory - the tool category
      requestJson - the request arguments as JSON string (will be truncated to 4000)
      responseOrError - the response text or error message (will be truncated to 4000)
      isError - true if this was an error
      startedMicros - micros since 1970 when the call started
      durationMicros - duration in microseconds (null if not available)
    • checkThrottle

      public static String checkThrottle(GrouperMcpAuthUser authUser, String toolCategory)
      Check if the user has exceeded the throttle limit for the given tool category.
      Parameters:
      authUser - the authenticated user
      toolCategory - the tool category
      Returns:
      null if the user is within limits, or an error message string if throttled