provider_activity
View receipt activity against your terms URL, including stats, unique agents, and recent receipts, using your provider API key.
Instructions
View receipt activity against your terms URL (requires provider API key via OPENTERMS_PROVIDER_KEY). Shows stats, unique agents, and recent receipts for your API.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Max receipts to return (default 10) |
Implementation Reference
- openterms_mcp_server.py:391-414 (handler)The handler function for provider_activity. Calls GET /v1/provider/stats with provider headers, returns stats including provider_id, verification status, receipt counts by period, unique agents, and action type breakdown.
elif name == "provider_activity": if not PROVIDER_KEY: return "❌ OPENTERMS_PROVIDER_KEY not set. Register as a provider first." # Get stats resp = client.get("/v1/provider/stats", headers=_provider_headers()) if resp.status_code != 200: return _format_error(resp) stats = resp.json() lines = [ f"📊 Provider Activity", f" Provider: {stats.get('provider_id', 'n/a')}", f" Verified: {'✅' if stats.get('verified') else '❌'}", f" Receipts (total): {stats.get('receipts_total', 0)}", f" Receipts (24h): {stats.get('receipts_24h', 0)}", f" Receipts (7d): {stats.get('receipts_7d', 0)}", f" Receipts (30d): {stats.get('receipts_30d', 0)}", f" Unique agents: {stats.get('unique_agents', 0)}", ] breakdown = stats.get('action_type_breakdown', {}) if breakdown: lines.append(" Action types:") for atype, count in breakdown.items(): lines.append(f" {atype}: {count}") return "\n".join(lines) - openterms_mcp_server.py:135-147 (schema)The input schema for provider_activity, defined in the TOOLS list. It has an optional 'limit' integer parameter.
{ "name": "provider_activity", "description": ( "View receipt activity against your terms URL (requires provider API key via OPENTERMS_PROVIDER_KEY). " "Shows stats, unique agents, and recent receipts for your API." ), "inputSchema": { "type": "object", "properties": { "limit": {"type": "integer", "description": "Max receipts to return (default 10)"}, }, }, }, - openterms_mcp_server.py:21-148 (registration)Tool registration: provider_activity is registered in the TOOLS list (line 136). The MCP server exposes it via list_tools() which converts TOOLS into Tool objects, and call_tool() which routes to handle_tool('provider_activity', ...).
TOOLS = [ # --- MVP 1 Tools --- { "name": "issue_receipt", "description": ( "Issue a cryptographically signed terms receipt BEFORE your agent takes an action. " "Returns an Ed25519-signed receipt proving consent to terms. " "If this returns POLICY_DENIED or POLICY_ESCALATION_REQUIRED, STOP and notify the user." ), "inputSchema": { "type": "object", "required": ["agent_id", "action_type", "terms_url", "terms_hash"], "properties": { "agent_id": {"type": "string", "description": "Identifier for this agent"}, "action_type": {"type": "string", "enum": ["api_call", "data_access", "purchase", "custom"]}, "terms_url": {"type": "string", "description": "URL of the terms being agreed to"}, "terms_hash": {"type": "string", "description": "SHA-256 hash of the terms document (64 hex chars)"}, "timestamp": {"type": "string", "description": "ISO 8601 timestamp (defaults to now)"}, "pricing_version": {"type": "string", "description": "Pricing version (defaults to 2025-01)"}, "action_context": {"type": "object", "description": "Optional metadata (provider, model, endpoint, etc.)"}, }, }, }, { "name": "verify_receipt", "description": "Verify a receipt's cryptographic integrity. Public — no API key needed.", "inputSchema": { "type": "object", "required": ["receipt_id", "canonical_hash", "signature", "key_id"], "properties": { "receipt_id": {"type": "string"}, "canonical_hash": {"type": "string"}, "signature": {"type": "string"}, "key_id": {"type": "string"}, }, }, }, { "name": "check_balance", "description": "Check workspace USDC balance (minor units, 1 USDC = 1,000,000).", "inputSchema": {"type": "object", "properties": {}}, }, { "name": "get_pricing", "description": "Get current per-receipt pricing. Public — no API key needed.", "inputSchema": {"type": "object", "properties": {}}, }, { "name": "list_receipts", "description": "List recent receipts for this workspace.", "inputSchema": { "type": "object", "properties": { "limit": {"type": "integer", "description": "Max receipts to return (default 10, max 50)"}, "action_type": {"type": "string", "description": "Filter by action type"}, }, }, }, # --- 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": {}}, }, { "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"}, }, }, }, { "name": "policy_decisions", "description": ( "View recent policy evaluation decisions (allow/deny/escalate) for this workspace. " "Useful for auditing and understanding what the policy engine has been doing." ), "inputSchema": { "type": "object", "properties": { "limit": {"type": "integer", "description": "Max decisions to return (default 10)"}, "decision": {"type": "string", "enum": ["allow", "deny", "escalate"], "description": "Filter by decision type"}, }, }, }, # --- MVP 3: Provider Verification Tools --- { "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"}, }, }, }, { "name": "provider_activity", "description": ( "View receipt activity against your terms URL (requires provider API key via OPENTERMS_PROVIDER_KEY). " "Shows stats, unique agents, and recent receipts for your API." ), "inputSchema": { "type": "object", "properties": { "limit": {"type": "integer", "description": "Max receipts to return (default 10)"}, }, }, }, ] - openterms_mcp_server.py:158-162 (helper)Helper function that builds HTTP headers with the provider API key (OPENTERMS_PROVIDER_KEY) for authenticating provider-specific API calls like provider_activity.
def _provider_headers(): h = {"Content-Type": "application/json"} if PROVIDER_KEY: h["Authorization"] = f"Bearer {PROVIDER_KEY}" return h