Package io.meeds.mcp.server.plugin
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 key may map to null: the tool receives it as an omitted argument,
and an evaluator reads it the same way, with get, never
containsKey.
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 Summary
Modifier and TypeMethodDescriptiondefault booleanallowsStandingApproval(String toolName, Map<String, Object> arguments) Tells whether any standing approval, limited or not, may cover this call.booleanTells whether a call stays within a grant's argument limit.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.boolean
-
Method Details
-
supports
- Parameters:
toolName- the MCP tool name- Returns:
- true when this evaluator owns the constraints of that tool
-
allowsStandingApproval
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 namearguments- the call arguments as the tool receives them- Returns:
- true when a standing approval may cover the call
-
proposeConstraint
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 namearguments- the call arguments as the tool receives them- Returns:
- the constraint to offer, or null when none can be offered
-
matches
Tells whether a call stays within a grant's argument limit.- Parameters:
toolName- the MCP tool namearguments- the call arguments as the tool receives themconstraint- the grant's constraint, never null- Returns:
- true only when the call provably satisfies the constraint
-