Skip to main content
Glama

x402_research

Detects input type, calls up to 5 x402 endpoints simultaneously with automatic payment, and returns combined results for intelligence on domains, IPs, addresses, drugs, or sports.

Instructions

Run comprehensive research by calling multiple x402 endpoints in parallel.

Given a subject (domain, IP, address, drug name, or sport), this tool:

  1. Detects the input type automatically

  2. Finds all relevant x402 endpoints (local registry)

  3. Calls up to 5 endpoints simultaneously with automatic payment

  4. Returns all results combined for synthesis

This is the fastest way to get a complete intelligence picture on any subject.

Input types (auto-detected):

  • Domain "stripe.com" → calls security + company + threat + compliance + sales (~$0.64)

  • IP "8.8.8.8" → calls threat intelligence (~$0.10)

  • Address "123 Main St Milwaukee WI" → calls property/location (~$0.10)

  • Drug "ibuprofen" → calls health intelligence (~$0.10)

  • Sport "nba" → calls sports intelligence (~$0.12)

Set max_cost to control budget per research call (default: $1.00).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
subjectYesThe subject to research: domain, IP, address, drug name, or sport
max_costNoMaximum total cost in USD (default: 1.00). Cheapest endpoints called first.

Implementation Reference

  • cli.js:559-663 (handler)
    Main handler for the x402_research tool. Validates subject, detects input type (domain/IP/address/drug/sport), selects cheapest endpoints within budget (up to 5 parallel calls), calls them concurrently via AgentCash, then formats and returns a combined intelligence report.
    async function handleResearch(args) {
      const subject = args.subject;
      const budget = args.max_cost ?? 1.00;
    
      if (!subject || subject.length < 2) {
        return { content: [{ type: 'text', text: 'Subject must be at least 2 characters.' }], isError: true };
      }
    
      const inputType = detectInputType(subject);
    
      if (inputType === 'unknown') {
        return {
          content: [{
            type: 'text',
            text: `Could not determine the type of "${subject}". Provide a domain (stripe.com), IP (8.8.8.8), address (123 Main St Milwaukee WI), drug name (ibuprofen), or sport (nba).`,
          }],
          isError: true,
        };
      }
    
      // Find matching endpoints from local registry
      let endpoints;
      if (inputType === 'domain') {
        endpoints = REGISTRY.filter(ep => ep.input.type === 'domain' || ep.input.type === 'ip_or_domain');
      } else if (inputType === 'ip_or_domain') {
        endpoints = REGISTRY.filter(ep => ep.input.type === 'ip_or_domain');
      } else {
        endpoints = REGISTRY.filter(ep => ep.input.type === inputType);
      }
    
      if (endpoints.length === 0) {
        return {
          content: [{
            type: 'text',
            text: `No endpoints found for input type "${inputType}". Available: domain, IP, address, drug name, sport.`,
          }],
          isError: true,
        };
      }
    
      // Select endpoints within budget (cheapest first)
      endpoints.sort((a, b) => a.price - b.price);
      const selected = [];
      let runningCost = 0;
      for (const ep of endpoints) {
        if (runningCost + ep.price <= budget && selected.length < MAX_PARALLEL_CALLS) {
          selected.push(ep);
          runningCost += ep.price;
        }
      }
    
      if (selected.length === 0) {
        return {
          content: [{
            type: 'text',
            text: `Budget of $${budget.toFixed(2)} is too low. Cheapest endpoint costs $${endpoints[0].price.toFixed(2)}.`,
          }],
          isError: true,
        };
      }
    
      // Build URLs and call in parallel
      const calls = selected.map(ep => {
        const paramValue = encodeURIComponent(subject);
        const url = `${ep.url}?${ep.input.param}=${paramValue}`;
        return { endpoint: ep, url };
      });
    
      const results = await Promise.all(
        calls.map(async ({ endpoint, url }) => {
          const result = await callX402Endpoint(url);
          return {
            name: endpoint.name,
            price: endpoint.price,
            success: result.success,
            data: result.success ? result.data : null,
            error: result.success ? null : result.error,
          };
        })
      );
    
      // Format combined results
      const lines = [`## x402 Intelligence Report: ${subject}\n`];
      let totalCost = 0;
      let successCount = 0;
    
      for (const r of results) {
        if (r.success) {
          successCount++;
          totalCost += r.price;
          lines.push(`### ${r.name} ($${r.price.toFixed(2)})`);
          lines.push('```json');
          lines.push(JSON.stringify(r.data, null, 2).slice(0, 3000));
          lines.push('```\n');
        } else {
          lines.push(`### ${r.name} — FAILED`);
          lines.push(`Error: ${r.error}\n`);
        }
      }
    
      lines.push('---');
      lines.push(`**Summary:** ${successCount}/${results.length} endpoints called. Total cost: $${totalCost.toFixed(2)} USDC.`);
    
      return { content: [{ type: 'text', text: lines.join('\n') }] };
    }
  • Schema/definition for the x402_research tool, including its input schema (subject string, max_cost number) and description explaining the parallel research behavior.
      {
        name: 'x402_research',
        description: `Run comprehensive research by calling multiple x402 endpoints in parallel.
    
    Given a subject (domain, IP, address, drug name, or sport), this tool:
      1. Detects the input type automatically
      2. Finds all relevant x402 endpoints (local registry)
      3. Calls up to 5 endpoints simultaneously with automatic payment
      4. Returns all results combined for synthesis
    
    This is the fastest way to get a complete intelligence picture on any subject.
    
    Input types (auto-detected):
      - Domain "stripe.com" → calls security + company + threat + compliance + sales (~$0.64)
      - IP "8.8.8.8" → calls threat intelligence (~$0.10)
      - Address "123 Main St Milwaukee WI" → calls property/location (~$0.10)
      - Drug "ibuprofen" → calls health intelligence (~$0.10)
      - Sport "nba" → calls sports intelligence (~$0.12)
    
    Set max_cost to control budget per research call (default: $1.00).`,
        inputSchema: {
          type: 'object',
          properties: {
            subject: {
              type: 'string',
              description: 'The subject to research: domain, IP, address, drug name, or sport',
            },
            max_cost: {
              type: 'number',
              description: 'Maximum total cost in USD (default: 1.00). Cheapest endpoints called first.',
            },
          },
          required: ['subject'],
        },
      },
  • cli.js:678-696 (registration)
    Registration of x402_research in the MCP CallToolRequestSchema handler — maps the name 'x402_research' to the handleResearch function.
    server.setRequestHandler(CallToolRequestSchema, async (request) => {
      const { name, arguments: args } = request.params;
    
      switch (name) {
        case 'x402_discover':
          return handleDiscover(args);
        case 'x402_call':
          return handleCall(args);
        case 'x402_balance':
          return handleBalance();
        case 'x402_research':
          return handleResearch(args);
        default:
          return {
            content: [{ type: 'text', text: `Unknown tool: ${name}. Available: x402_discover, x402_call, x402_balance, x402_research` }],
            isError: true,
          };
      }
    });
  • Helper function that auto-detects the input type of the research subject (domain, IP, address, sport, drug) using regex patterns — used by handleResearch.
    function detectInputType(subject) {
      const s = subject.trim();
      if (/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(s)) return 'ip_or_domain';
      if (/^[a-zA-Z0-9][a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(s)) return 'domain';
      if (/\d+.*[a-zA-Z]+.*[a-zA-Z]{2,}/.test(s) && s.includes(' ')) return 'address';
      if (/^(nba|nfl|mlb|nhl|mls|epl|soccer|basketball|football|baseball|hockey)$/i.test(s)) return 'sport';
      if (s.length < 50) return 'drug_or_food';
      return 'unknown';
    }
Behavior3/5

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

No annotations are provided, so the description carries the full burden. It discloses parallel calling, automatic payment, and cost control via max_cost. However, it omits details like authentication requirements, error handling, rate limits, and potential side effects.

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?

The description is well-structured with a clear main sentence, followed by bullet points and examples. It is concise yet informative, with no redundant sentences. Every part contributes to understanding the tool's functionality.

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?

Given no output schema or annotations, the description covers the essential aspects: input processing, parallel execution, and cost management. It lacks details on return format and error scenarios, but these are mitigated by the tool's simplicity and the combined results description.

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?

The input schema has 100% description coverage. The description significantly adds value by explaining the subject parameter's auto-detection behavior and providing concrete examples. For max_cost, it clarifies that cheapest endpoints are called first, which is not evident from the schema alone.

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?

The description clearly states the tool's purpose: running comprehensive research by calling multiple x402 endpoints in parallel. It specifies the input types (domain, IP, address, drug, sport) and the workflow (auto-detection, endpoint selection, parallel calls). This distinguishes it from siblings like x402_call, which likely calls a single endpoint.

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?

The description provides clear usage context, including when to use (fastest way to get intelligence) and examples for each input type. However, it does not explicitly mention when not to use or compare with sibling tools like x402_call or x402_discover.

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/8randonpickart5/x402-buyer-mcp'

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