Skip to main content
Glama
jstibal

Openterms-mcp

verify_receipt_by_hash

Verify consent receipt validity using its cryptographic hash to confirm authorization before processing requests. Returns verification results and receipt details.

Instructions

Verify a receipt by its canonical hash. Public — no API key needed. Use this to check if an agent has a valid consent receipt before serving a request. Returns receipt details and cryptographic verification result.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
canonical_hashYesThe canonical hash of the receipt to verify

Implementation Reference

  • app.py:525-550 (handler)
    The actual core logic function for verifying the receipt.
    def verify_receipt_by_hash(canonical_hash):
        """Public endpoint: verify a receipt by its canonical hash. No auth required.
        This is the endpoint providers' SDKs call to verify an agent's receipt."""
        receipt = db.get_receipt_by_hash(canonical_hash)
        if not receipt:
            return error_response('RECEIPT_NOT_FOUND', 'No receipt found with this hash', 404)
    
        # Verify the cryptographic signature
        km = get_key_manager()
        service = ReceiptService(km)
    
        # Build minimal receipt dict for verification
        verify_result = service.verify_receipt(receipt)
    
        # Return public-safe receipt data (strip workspace_id for privacy)
        return jsonify({
            'valid': verify_result.get('valid', False),
            'receipt_id': receipt['receipt_id'],
            'canonical_hash': receipt['canonical_hash'],
            'agent_id': receipt['agent_id'],
            'action_type': receipt['action_type'],
            'terms_url': receipt['terms_url'],
            'terms_hash': receipt['terms_hash'],
            'amount_charged': receipt['amount_charged'],
            'timestamp': receipt['timestamp'],
            'signature': receipt['signature'],
  • Registration of the tool in the MCP server.
    {
        "name": "verify_receipt_by_hash",
        "description": (
            "Verify a receipt by its canonical hash. Public — no API key needed. "
            "Use this to check if an agent has a valid consent receipt before serving a request. "
            "Returns receipt details and cryptographic verification result."
        ),
        "inputSchema": {
            "type": "object",
            "required": ["canonical_hash"],
            "properties": {
                "canonical_hash": {"type": "string", "description": "The canonical hash of the receipt to verify"},
            },
        },
    },
  • The MCP server handler that dispatches the request to the underlying API endpoint.
    elif name == "verify_receipt_by_hash":
        canonical_hash = arguments["canonical_hash"]
        resp = client.get(f"/v1/receipts/verify/{canonical_hash}", headers=_headers(auth=False))
        if resp.status_code == 200:
            data = resp.json()
            valid = data.get("valid", False)
            status = "✅ VALID" if valid else "❌ INVALID"
            verification = data.get("verification", {})
Behavior4/5

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

No annotations provided, but description discloses authentication requirements (no API key needed) and return value structure ('receipt details and cryptographic verification result'). Does not mention idempotency, caching, or error conditions.

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?

Four sentences with zero waste: purpose (sentence 1), auth (sentence 2), usage context (sentence 3), return value (sentence 4). Front-loaded with the core action and appropriately dense.

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

Completeness5/5

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

For a single-parameter verification tool without output schema, description adequately covers purpose, prerequisites, domain context (consent receipts), and return value semantics. No significant gaps given the tool's simplicity.

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

Parameters3/5

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

Schema has 100% description coverage ('The canonical hash of the receipt to verify'), establishing baseline 3. Description references 'canonical hash' but does not add format constraints, examples, or validation rules beyond the schema.

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?

Description provides specific verb (verify), resource (receipt), and distinguishing scope (by canonical hash). It clearly differentiates from sibling tool 'verify_receipt' by specifying the hash-based lookup method.

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?

Explicitly states when to use ('check if an agent has a valid consent receipt before serving a request') and provides important usage constraint ('Public — no API key needed'). Lacks explicit 'when not to use' or named alternatives.

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