simulate_policy
Test whether a hypothetical action would be allowed by current policy without issuing a receipt. Pre-check API calls, data access, purchases, or custom actions before proceeding.
Instructions
Test whether a hypothetical action would be allowed by the current policy WITHOUT actually issuing a receipt. Use this to pre-check before acting.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| action_type | Yes | ||
| terms_url | Yes | URL of the terms | |
| action_context | No | Optional context metadata |
Implementation Reference
- openterms_mcp_server.py:318-343 (handler)The handler logic for the 'simulate_policy' tool, which sends a POST request to '/v1/policy/simulate' and formats the response.
elif name == "simulate_policy": payload = { "payload": { "action_type": arguments["action_type"], "terms_url": arguments["terms_url"], } } if arguments.get("action_context"): payload["payload"]["action_context"] = arguments["action_context"] resp = client.post("/v1/policy/simulate", json=payload, headers=_headers()) if resp.status_code == 200: result = resp.json() decision = result.get("decision", "unknown") icon = {"allow": "β ", "deny": "π«", "escalate": "βΈοΈ"}.get(decision, "β") lines = [f"{icon} Simulation result: {decision.upper()}"] reasons = result.get("reasons", []) if reasons: lines.append(f" Reasons: {', '.join(reasons)}") for rr in result.get("rule_results", []): lines.append(f" Rule {rr.get('rule_index', '?')}: {rr.get('rule_type')} β {rr.get('decision')}") ctx = result.get("context", {}) if ctx: lines.append(f" Context: daily_spend={ctx.get('daily_spend', 0)}, balance={ctx.get('current_balance', 0)}") return "\n".join(lines) return _format_error(resp) - openterms_mcp_server.py:89-104 (schema)The tool schema definition for 'simulate_policy', describing its purpose and required input parameters.
{ "name": "simulate_policy", "description": ( "Test whether a hypothetical action would be allowed by the current policy " "WITHOUT actually issuing a receipt. Use this to pre-check before acting." ), "inputSchema": { "type": "object", "required": ["action_type", "terms_url"], "properties": { "action_type": {"type": "string", "enum": ["api_call", "data_access", "purchase", "custom"]}, "terms_url": {"type": "string", "description": "URL of the terms"}, "action_context": {"type": "object", "description": "Optional context metadata"}, }, }, },