Class GrouperMcpToolLogUtil
java.lang.Object
edu.internet2.middleware.grouper.ws.mcp.GrouperMcpToolLogUtil
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringcheckThrottle(GrouperMcpAuthUser authUser, String toolCategory) Check if the user has exceeded the throttle limit for the given tool category.static voidlogToolCall(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.
-
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 usertoolName- the tool nametoolCategory- the tool categoryrequestJson- 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 errorstartedMicros- micros since 1970 when the call starteddurationMicros- duration in microseconds (null if not available)
-
checkThrottle
Check if the user has exceeded the throttle limit for the given tool category.- Parameters:
authUser- the authenticated usertoolCategory- the tool category- Returns:
- null if the user is within limits, or an error message string if throttled
-