Skip to main content
Glama
jstibal

Openterms-mcp

get_policy

Retrieve the active policy for your workspace to understand the rules and constraints governing agent actions. Use this on startup to ensure compliance with guardrails.

Instructions

Get the active policy (guardrails) for this workspace. Returns the rules that govern what this agent is allowed to do. An agent SHOULD call this on startup to understand its constraints.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handle_tool function dispatches 'get_policy' by making a GET request to /v1/policy and formatting the response. It parses the active policy JSON, checks if active, then displays rules (max_amount_per_receipt, daily_spend_cap, etc.) in a human-readable format.
    elif name == "get_policy":
        resp = client.get("/v1/policy", headers=_headers())
        if resp.status_code == 200:
            policy = resp.json()
            if not policy.get("active") and policy.get("active") is not True:
                if policy.get("version", 0) == 0:
                    return "No active policy. All actions are allowed."
            rules = policy.get("rules", [])
            lines = [
                f"Active policy (version {policy.get('version', '?')}):",
                f"  Rules ({len(rules)}):"
            ]
            for i, rule in enumerate(rules):
                rtype = rule.get("type", "unknown")
                if rtype in ("max_amount_per_receipt", "daily_spend_cap", "max_action_context_keys"):
                    lines.append(f"    {i+1}. {rtype}: limit={rule.get('limit')}")
                elif rtype == "escalate_above_amount":
                    lines.append(f"    {i+1}. {rtype}: threshold={rule.get('threshold')}")
                elif rtype in ("allowed_action_types", "blocked_action_types"):
                    lines.append(f"    {i+1}. {rtype}: {rule.get('values')}")
                elif rtype == "required_terms_url_prefix":
                    lines.append(f"    {i+1}. {rtype}: {rule.get('prefix')}")
                else:
                    lines.append(f"    {i+1}. {rtype}: {json.dumps(rule)}")
            return "\n".join(lines)
        return _format_error(resp)
  • Registration entry in the TOOLS list defining the 'get_policy' tool with description and an empty inputSchema (no parameters required).
    # --- MVP 2: Policy Tools ---
    {
        "name": "get_policy",
        "description": (
            "Get the active policy (guardrails) for this workspace. "
            "Returns the rules that govern what this agent is allowed to do. "
            "An agent SHOULD call this on startup to understand its constraints."
        ),
        "inputSchema": {"type": "object", "properties": {}},
    },
  • MCP server registration: the tool is listed via list_tools() and dispatched via call_tool() which calls handle_tool(name, arguments).
    @server.list_tools()
    async def list_tools():
        return [types.Tool(**t) for t in TOOLS]
    
    @server.call_tool()
    async def call_tool(name: str, arguments: dict):
        result = handle_tool(name, arguments or {})
        return [types.TextContent(type="text", text=result)]
  • app.py:602-609 (handler)
    API endpoint handler for GET /v1/policy. Called by the MCP server handler; retrieves the active policy from the database.
    @app.route('/v1/policy', methods=['GET'])
    @require_auth
    def get_policy():
        """Get the active policy profile for the workspace."""
        policy = db.get_active_policy(g.workspace_id)
        if not policy:
            return jsonify({'active': False, 'version': 0, 'rules': []})
        return jsonify(policy)
  • db.py:500-513 (helper)
    Database helper function get_active_policy that queries the policy_profile table for the active policy of a workspace.
    def get_active_policy(workspace_id):
        """Get the active policy profile for a workspace, or None."""
        conn = get_db()
        row = conn.execute(
            "SELECT * FROM policy_profile WHERE workspace_id = ? AND active = 1",
            (workspace_id,)
        ).fetchone()
        conn.close()
        if row:
            result = dict(row)
            if isinstance(result.get('rules'), str):
                result['rules'] = json.loads(result['rules'])
            return result
        return None
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It correctly indicates a read operation with no side effects, but lacks details such as whether the result is cached, update frequency, or authentication requirements. This is minimally adequate for a straightforward getter.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Three concise, front-loaded sentences with no wasted words. The first sentence states the main action, the second clarifies the return, and the third provides usage direction.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool has no parameters and no output schema, the description covers the core purpose and usage context (startup). It could optionally describe the return format (e.g., what fields the rules contain), but this is not critical for agent invocation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has zero parameters with 100% coverage, so no parameter information is needed from the description. The description adds value by explaining the purpose of the return value, which is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'Get' and the resource 'active policy (guardrails)', specifying it returns rules that govern agent actions. This distinguishes it from sibling tools like policy_decisions and simulate_policy, which likely involve more detailed or simulated policies.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explicitly advises calling this tool on startup to understand constraints, providing clear when-to-use guidance. It does not explicitly mention when not to use or alternatives, but the context is sufficiently clear for a simple read operation.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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