check_policy
Verify if actions comply with organizational policies to enforce AI agent governance and maintain compliance standards.
Instructions
Check if an action is allowed by the organization's policies.
Args:
action_type: The action to check (e.g. "data:read:users", "api:external:call")
agent_id: Optional agent ID to check policies forInput Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| action_type | Yes | ||
| agent_id | No |
Implementation Reference
- src/asqav_mcp/server.py:26-59 (handler)The check_policy tool implementation, which queries an external API to determine if an action complies with organization policies.
@mcp.tool() async def check_policy(action_type: str, agent_id: str | None = None) -> str: """Check if an action is allowed by the organization's policies. Args: action_type: The action to check (e.g. "data:read:users", "api:external:call") agent_id: Optional agent ID to check policies for """ try: policies = await _request("GET", "/policies") matching = [] for p in policies: if not p.get("is_active"): continue pattern = p.get("action_pattern", "") if pattern == "*" or action_type.startswith(pattern.rstrip("*")): matching.append(p) if not matching: return f"ALLOWED: No policies match action '{action_type}'" blocked = [p for p in matching if p["action"] in ("block", "block_and_alert")] if blocked: names = ", ".join(p["name"] for p in blocked) return f"BLOCKED: Action '{action_type}' blocked by: {names}" alerted = [p for p in matching if p["action"] in ("alert", "block_and_alert")] if alerted: names = ", ".join(p["name"] for p in alerted) return f"ALLOWED with ALERT: Action '{action_type}' triggers alerts: {names}" return f"ALLOWED: Action '{action_type}' passes all policies" except Exception as e: return f"Error checking policies: {e}"