Skip to main content
Glama
jstibal

Openterms-mcp

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
NameRequiredDescriptionDefault
action_typeYes
terms_urlYesURL of the terms
action_contextNoOptional context metadata

Implementation Reference

  • 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)
  • 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"},
            },
        },
    },

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/jstibal/openterms-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server