Skip to main content
Glama

x402_web_search

Search the web for information and get ranked results with titles, URLs, and snippets. Use domain filters to focus research and optionally include synthesized answers summarizing findings.

Instructions

Search the web and return ranked results via Tavily — title, URL, snippet, and relevance score. Price: $0.01 USDC per search (paid mode) | Free test: returns fixture data.

Optional synthesized answer summarizing results. Use include_domains/exclude_domains for focused research. Per-wallet daily limit: 50 queries (resets midnight UTC). Without X402_PRIVATE_KEY, only the free test endpoint is available.

Returns: query, results array (title, url, snippet, score), optional answer field.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSearch query (max 400 chars)
max_resultsNoNumber of results to return (1-10, default: 5)
include_answerNoInclude a synthesized answer above the results (may be null if Tavily cannot synthesize)
include_domainsNoRestrict results to these domains only (max 20)
exclude_domainsNoExclude these domains from results (max 20)

Implementation Reference

  • The x402_web_search tool handler is defined in src/index.ts. It handles both paid searches (via Tavily if PRIVATE_KEY is set) and a free test mode.
    server.tool(
      "x402_web_search",
      `Search the web and return ranked results via Tavily — title, URL, snippet, and relevance score.
    Price: $0.01 USDC per search (paid mode) | Free test: returns fixture data.
    
    Optional synthesized answer summarizing results. Use include_domains/exclude_domains for focused research.
    Per-wallet daily limit: 50 queries (resets midnight UTC).
    Without X402_PRIVATE_KEY, only the free test endpoint is available.
    
    Returns: query, results array (title, url, snippet, score), optional answer field.`,
      {
        query: z.string().min(1).max(400).describe("Search query (max 400 chars)"),
        max_results: z.number().int().min(1).max(10).default(5)
          .describe("Number of results to return (1-10, default: 5)"),
        include_answer: z.boolean().default(false)
          .describe("Include a synthesized answer above the results (may be null if Tavily cannot synthesize)"),
        include_domains: z.array(z.string()).max(20).optional()
          .describe("Restrict results to these domains only (max 20)"),
        exclude_domains: z.array(z.string()).max(20).optional()
          .describe("Exclude these domains from results (max 20)"),
      },
      async (params) => {
        const base = APIS.search.baseUrl;
        try {
          const usePaid = !!PRIVATE_KEY;
          if (usePaid) {
            const payload: Record<string, unknown> = {
              query: params.query,
              max_results: params.max_results,
              include_answer: params.include_answer,
            };
            if (params.include_domains) payload.include_domains = params.include_domains;
            if (params.exclude_domains) payload.exclude_domains = params.exclude_domains;
            const data = await apiPost(base, "/search", payload, true);
            return textResult({ mode: "paid", cost: "$0.01", ...data });
          } else {
            const data = await apiGet(base, "/search/test");
            return textResult({
              mode: "free_test",
              note: "Free test — returns fixture data. Set X402_PRIVATE_KEY for live web search.",
              ...data,
            });
          }
        } catch (err: any) {
          return errorResult(err.message);
        }
      }
    );
Behavior5/5

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

With no annotations, description carries full burden and excels: discloses pricing ($0.01 USDC), free mode limitations (fixture data), rate limiting (50/day, midnight UTC reset), authentication requirements (X402_PRIVATE_KEY), and return structure (query, results array, optional answer). No contradictions.

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?

Information-dense with no filler. Front-loaded with core purpose, followed by cost, usage tips, limits, auth, and returns. Every sentence conveys distinct operational information (price, limits, auth, returns).

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?

Comprehensive despite lack of output schema: explicitly documents return fields (query, results array with sub-fields, optional answer). Covers payment behavior essential for this tool type. No gaps given the medium complexity and rich schema coverage.

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

Parameters4/5

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

Schema has 100% description coverage (baseline 3). Description adds value by explaining include_answer produces a 'synthesized answer' and that domain filters are for 'focused research', providing usage intent beyond raw schema definitions.

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?

Opens with specific verb 'Search' and resource 'the web', distinguishes from sibling tools like crawl_site or scrape_url by specifying 'return ranked results via Tavily'. Clearly identifies the core functionality and data returned (title, URL, snippet, score).

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?

Provides clear prerequisites (X402_PRIVATE_KEY for paid mode, free test available otherwise) and rate limits (50 queries/day). Mentions 'focused research' as a use case for domain filters. Lacks explicit 'when not to use' comparison to siblings like x402_crawl_site, but payment requirements implicitly guide selection.

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/jameswilliamwisdom/x402-mcp-server'

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