Skip to main content
Glama

get_invoice

Create a Lightning Network invoice to pay for web search queries. Submit payment in sats to access pay-per-use semantic search without API keys. Provide your agent ID to unlock lower rates based on karma score.

Instructions

Get a Lightning invoice to pay before searching.

agent_id: your identity in Giskard Marks (optional). High karma = lower price.
Tiers: no mark=10 sats | karma 1-20=7 sats | 21-50=5 sats | 50+=3 sats.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
agent_idNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • server.py:75-94 (handler)
    Main handler function for 'get_invoice' tool. Decorated with @mcp.tool(), it takes an optional agent_id, applies karma-based pricing discounts, creates a Lightning invoice via create_invoice(), and returns payment_request and payment_hash for the user to pay before searching.
    @mcp.tool()
    def get_invoice(agent_id: str = "") -> str:
        """Get a Lightning invoice to pay before searching.
    
        agent_id: your identity in Giskard Marks (optional). High karma = lower price.
        Tiers: no mark=10 sats | karma 1-20=7 sats | 21-50=5 sats | 50+=3 sats."""
        agent_id = sanitize_agent_id(agent_id)
        price, karma = karma_discount(agent_id, SEARCH_PRICE_SATS)
        invoice = create_invoice(price, "Giskard Search")
    
        discount_note = ""
        if agent_id and price < SEARCH_PRICE_SATS:
            discount_note = f"\nKarma discount applied ({karma} karma): {SEARCH_PRICE_SATS} → {price} sats."
    
        return (
            f"Pay {price} sats to search.{discount_note}\n\n"
            f"payment_request: {invoice['payment_request']}\n"
            f"payment_hash: {invoice['payment_hash']}\n\n"
            f"After paying, call search_web or search_news with the payment_hash."
        )
  • server.py:75-75 (registration)
    Registration of the 'get_invoice' tool via the @mcp.tool() decorator from FastMCP framework. This registers the function as an MCP tool named 'get_invoice'.
    @mcp.tool()
  • Helper function create_invoice() that makes HTTP POST request to phoenixd Lightning node to create an actual Lightning invoice with specified amount and description. Returns payment_request and payment_hash.
    def create_invoice(amount: int, description: str) -> dict:
        response = httpx.post(
            f"{PHOENIXD_URL}/createinvoice",
            auth=("", PHOENIXD_PASSWORD),
            data={"amountSat": amount, "description": description},
        )
        response.raise_for_status()
        data = response.json()
        return {"payment_request": data["serialized"], "payment_hash": data["paymentHash"]}
  • Helper module providing karma_discount() and sanitize_agent_id() functions. Applies tiered pricing based on agent karma scores: no mark=10 sats | karma 1-20=7 sats | 21-50=5 sats | 50+=3 sats.
    """
    Módulo compartido — karma-tiered pricing para Giskard MCP servers.
    
    Cadena: Marks (identidad) → Argentum (karma) → precio del servicio
    
    Uso:
        from karma_pricing import karma_discount
    
        price = karma_discount(agent_id, base_price=21)
    
    KNOWN GAP: agent_id es autodeclarado. Sin firma criptográfica todavía.
    Cualquier failure en Marks/Argentum retorna base_price sin romper el flujo.
    """
    import re
    import httpx
    
    ARGENTUM_URL = "http://localhost:8017"
    MARKS_URL    = "http://localhost:8015"
    
    # Descuentos: (karma_minimo, fraccion_del_precio_base)
    # Se aplica floor() para quedarse en sats enteros
    TIERS = [
        (50, 0.25),   # 75% off
        (21, 0.50),   # 50% off
        (1,  0.70),   # 30% off
        (0,  1.00),   # precio base
    ]
    
    
    def sanitize_agent_id(agent_id: str) -> str:
        return re.sub(r"[^a-zA-Z0-9\-_]", "", agent_id)[:64]
    
    
    def _verify_mark(agent_id: str) -> bool:
        try:
Behavior4/5

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

No annotations provided, so description carries full burden. Discloses pricing tiers (3-10 sats), karma system mechanics, and identity requirements. Missing: invoice expiration, payment confirmation flow, or side effects of generating an invoice.

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 dense sentences with zero waste: purpose front-loaded, followed by parameter semantics, then pricing table. Every word earns its place; no redundancy despite complex pricing logic.

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?

Appropriate for tool complexity (1 param). Covers payment method differentiation, pricing behavior, and parameter meaning. Output schema exists so return values needn't be described. Minor gap: could clarify Lightning Network specifics or invoice expiration.

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

Parameters5/5

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

Schema has 0% description coverage. Description fully compensates by explaining agent_id as 'your identity in Giskard Marks', noting it's optional, and detailing the business logic impact (high karma = lower price with specific tier breakdown).

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?

States specific action (Get), resource (Lightning invoice), and workflow context (to pay before searching). Explicitly distinguishes from sibling get_arbitrum_invoice by specifying 'Lightning' (Bitcoin) vs Arbitrum (Ethereum L2).

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

Usage Guidelines3/5

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

Implies sequence ('before searching') suggesting prerequisite usage, but lacks explicit when/when-not guidance comparing it to get_arbitrum_invoice or stating conditions for choosing Lightning over other payment methods.

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/giskard09/giskard-search'

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