Skip to main content
Glama

search_web

Search the web and pay per query with Lightning Network or Arbitrum ETH, eliminating API key requirements for AI agents.

Instructions

Search the web. Pay with Lightning (payment_hash) or Arbitrum ETH (tx_hash).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes
payment_hashNo
tx_hashNo
max_resultsNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The main search_web tool handler. It validates payment (Lightning via payment_hash or Arbitrum ETH via tx_hash) and returns web search results. Decorated with @mcp.tool() for MCP registration.
    @mcp.tool()
    def search_web(query: str, payment_hash: str = "", tx_hash: str = "", max_results: int = 5) -> str:
        """Search the web. Pay with Lightning (payment_hash) or Arbitrum ETH (tx_hash)."""
        if payment_hash:
            if not check_invoice(payment_hash):
                return "Lightning payment not settled. Call get_invoice first."
        elif tx_hash:
            ok, pid = arb_pay.verify_tx(tx_hash, "search")
            if not ok:
                return "Arbitrum payment not found or already used. Call get_arbitrum_invoice first."
            arb_pay.mark_used(pid)
        else:
            return "Provide payment_hash (Lightning) or tx_hash (Arbitrum)."
        return do_search(query, max_results)
  • Helper function get_invoice that creates a Lightning invoice for the search_web tool. It calculates karma-based discounts and returns payment request details that the user must pay before calling search_web.
    @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."
        )
  • Core search helper function that performs the actual DuckDuckGo web search using the DDGS library. Called by search_web after payment verification.
    def do_search(query: str, max_results: int = 5) -> str:
        with DDGS() as ddgs:
            results = list(ddgs.text(query, max_results=max_results))
        if not results:
            return "No results found."
        return "\n---\n".join(f"**{r['title']}**\n{r['href']}\n{r['body']}" for r in results)
Behavior3/5

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

With no annotations provided, the description carries full burden. It successfully discloses the payment requirement (critical behavioral context not evident in the schema), but omits other essential behaviors such as what happens when payment is missing/invalid, rate limits, or whether the payment parameters are mutually exclusive.

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

Conciseness4/5

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

Extremely concise at two sentences with no filler. Every sentence earns its place by establishing function and payment mechanism. However, the brevity may be excessive given the tool's complexity (paid API, four parameters, 0% schema coverage).

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

Completeness2/5

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

Given the combination of zero schema descriptions, no annotations, a paid-service model with cryptocurrency payments, and four parameters, the description is insufficient. It lacks explanation of payment flow logic, default behaviors, or result characteristics despite the presence of an output schema reducing the need for return value documentation.

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 description coverage is 0%, requiring the description to compensate. It adds semantic meaning for 'payment_hash' (Lightning) and 'tx_hash' (Arbitrum ETH), but completely ignores 'query' (despite being required) and 'max_results', leaving half the parameter set undocumented.

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

Purpose4/5

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

The description clearly states the core action ('Search the web') and implicitly distinguishes from sibling 'search_news' by specifying 'web' as the target resource. However, it lacks specificity about what search index or results format to expect.

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

Usage Guidelines2/5

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

While it mentions payment methods available (Lightning or Arbitrum ETH), it fails to provide guidance on when to select this tool versus siblings like 'search_news', or when to use which payment option (payment_hash vs tx_hash). No prerequisites or exclusions are stated.

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