Skip to main content
Glama

get_payment_history

Retrieve recent L402 Lightning Network payment records from the current session to track autonomous Bitcoin transactions and API access purchases.

Instructions

List recent L402 payments made during this session.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoMaximum number of payments to return
sinceNoISO timestamp to filter payments from

Implementation Reference

  • The handler function 'get_payment_history' which retrieves and returns the payment history as a JSON string.
    async def get_payment_history(
        limit: int = 10,
        since: str | None = None,
        budget_manager: "BudgetManager | None" = None,
    ) -> str:
        """
        List recent L402 payments made during this session.
    
        Args:
            limit: Maximum number of payments to return
            since: ISO timestamp to filter payments from
            budget_manager: Budget manager instance
    
        Returns:
            JSON with list of payments
        """
        if not budget_manager:
            return json.dumps(
                {"success": False, "error": "Budget manager not initialized"}
            )
    
        try:
            # Parse since timestamp if provided
            since_dt = None
            if since:
                try:
                    since_dt = datetime.fromisoformat(since.replace("Z", "+00:00"))
                except ValueError:
                    return json.dumps(
                        {
                            "success": False,
                            "error": f"Invalid timestamp format: {since}. Use ISO format.",
                        }
                    )
    
            # Get payment history
            payments = budget_manager.get_history(limit=limit, since=since_dt)
    
            # Get budget status
            status = budget_manager.get_status()
    
            result = {
                "success": True,
                "payments": [p.to_dict() for p in payments],
                "count": len(payments),
                "total_payments": status["payment_count"],
                "session_summary": {
                    "total_spent": status["spent"],
                    "remaining_budget": status["remaining"],
                    "per_request_limit": status["limits"]["per_request"],
                    "per_session_limit": status["limits"]["per_session"],
                },
            }
    
            if payments:
                result["message"] = (
                    f"Showing {len(payments)} of {status['payment_count']} payments. "
                    f"Total spent: {status['spent']} sats."
                )
            else:
                result["message"] = "No payments recorded in this session."
    
            return json.dumps(result, indent=2)
  • The MCP tool definition and input schema registration for 'get_payment_history'.
    Tool(
        name="get_payment_history",
        description="List recent L402 payments made during this session.",
        inputSchema={
            "type": "object",
            "properties": {
                "limit": {
                    "type": "integer",
                    "description": "Maximum number of payments to return",
                    "default": 10,
                },
                "since": {
                    "type": "string",
                    "description": "ISO timestamp to filter payments from",
                },
            },
        },

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/refined-element/lightning-enable-mcp'

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