Interface McpToolGrantConstraintEvaluator


public interface McpToolGrantConstraintEvaluator
Evaluates the argument limits of standing approvals for the tools of one add-on. It lives beside the tool so that the limit and the tool read the arguments with the same parser: a value the tool would interpret differently from the check is the hole this SPI exists to close.

Both methods receive the arguments exactly as the tool method will receive them (camel-case keys, values as parsed from the call input). Both must fail closed: an argument they cannot read with certainty means "no constraint offered" and "does not match".

A contributor is a dedicated Spring @Service with an explicit, unique bean name, non-final (the Kernel/Spring bridge exports it to the MCP server as a proxy of its class). It is never the tool plugin class itself: every public method of an McpToolPlugin is a tool candidate.

  • Method Details

    • supports

      boolean supports(String toolName)
      Parameters:
      toolName - the MCP tool name
      Returns:
      true when this evaluator owns the constraints of that tool
    • allowsStandingApproval

      default boolean allowsStandingApproval(String toolName, Map<String,Object> arguments)
      Tells whether any standing approval, limited or not, may cover this call. A tool returns false for calls it never lets run unasked, for example a mail sent from a shared mailbox or in another person's name; such a call always shows its card, and the card doesn't offer "Always allow".
      Parameters:
      toolName - the MCP tool name
      arguments - the call arguments as the tool receives them
      Returns:
      true when a standing approval may cover the call
    • proposeConstraint

      McpToolGrantConstraint proposeConstraint(String toolName, Map<String,Object> arguments)
      Derives the argument limit an approval card may offer for this call, for example "only recipients in example.com" when every recipient is there.
      Parameters:
      toolName - the MCP tool name
      arguments - the call arguments as the tool receives them
      Returns:
      the constraint to offer, or null when none can be offered
    • matches

      boolean matches(String toolName, Map<String,Object> arguments, McpToolGrantConstraint constraint)
      Tells whether a call stays within a grant's argument limit.
      Parameters:
      toolName - the MCP tool name
      arguments - the call arguments as the tool receives them
      constraint - the grant's constraint, never null
      Returns:
      true only when the call provably satisfies the constraint