> ## Documentation Index
> Fetch the complete documentation index at: https://docs.atxp.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Search

> Search the web

## Overview

Use the Search MCP server from your ATXP-powered agent to search the web and extract information.

## Example prompts

* "Search the web for the latest news on the US financial sector and its impact on the stock market."
* "Search for MCP servers that can be used with an ATXP agent."

## Tools

<AccordionGroup>
  <Accordion title="search_search">
    Executes a search query against the internet. An example of how it would be used is if you want to find the latest news on a topic.

    ### Arguments

    Accepts a JSON object with the following properties:

    <ParamField body="query" type="string" required>
      The search query to execute.
    </ParamField>

    ### Response

    Returns a JSON object with the following properties:

    <ResponseField name="status" type="string">
      The status of the search operation. Returns "success" when the search is completed successfully, otherwise returns "error".
    </ResponseField>

    <ResponseField name="errorMessage" type="string?">
      The error message if the search operation fails. This is only returned when `status === "error"`.
    </ResponseField>

    <ResponseField name="results" type="array?">
      The results of the search query. This is only returned when `status === "success"`.

      <Expandable title="Result object properties">
        <ResponseField name="title" type="string">
          The title of the result.
        </ResponseField>

        <ResponseField name="url" type="string">
          The URL of the result.
        </ResponseField>

        <ResponseField name="text" type="string">
          The text of the result.
        </ResponseField>

        <ResponseField name="publishedDate" type="string">
          The date at which the result was published.
        </ResponseField>
      </Expandable>
    </ResponseField>
  </Accordion>
</AccordionGroup>

## Usage

<Steps>
  <Step title="Define the Search service">
    Create a reusable service configuration that points to the MCP server and standardizes how you pass arguments and read results. This lets your agent easily interact with the Search tools in a consistent manner.

    ```typescript theme={null}
    const searchService = {
        mcpServer: 'https://search.mcp.atxp.ai/',
        searchToolName: 'search_search',
        description: 'ATXP Search MCP server',
        getArguments: (query: string) => ({ query }),
        getResult: (result: any) => JSON.parse(result.content[0].text)
      };
    ```
  </Step>

  <Step title="Create an ATXP client">
    <Tabs>
      <Tab title="Using an ATXP account">
        Create a client using an <a href="/developers/build-agents/create-account" target="_blank">ATXP account</a> by importing the ATXP client SDK and other dependencies.

        ```typescript theme={null}
        // Import the ATXP client SDK
        import { atxpClient, ATXPAccount } from '@atxp/client';

        // Read the ATXP account details from environment variables
        const atxpConnectionString = process.env.ATXP_CONNECTION;

        // Create a client using the `atxpClient` function
        const client = await atxpClient({
          mcpServer: searchService.mcpServer,
          account: new ATXPAccount(atxpConnectionString),
        });
        ```
      </Tab>

      <Tab title="Using a Base account">
        Create a client using a Base account by importing the ATXP client SDK and other dependencies.

        ```typescript theme={null}
        // Import the ATXP client SDK and Base account
        import { atxpClient } from '@atxp/client';
        import { BaseAccount } from '@atxp/base';

        // Read the Base account details from the environment variables
        const baseRpcUrl = process.env.BASE_RPC_URL;
        const basePrivateKey = process.env.BASE_PRIVATE_KEY;

        // Create a client using the `atxpClient` function
        const client = await atxpClient({
          mcpServer: searchService.mcpServer,
          account: new BaseAccount(baseRpcUrl, basePrivateKey),
        });
        ```
      </Tab>

      <Tab title="Using a Solana account">
        Create a client using a Solana account by importing the ATXP client SDK and other dependencies.

        ```typescript theme={null}
        // Import the ATXP client SDK and Solana account
        import { atxpClient } from '@atxp/client';
        import { SolanaAccount } from '@atxp/solana';

        // Read the Solana account details from the environment variables
        const solanaRpcUrl = process.env.SOLANA_RPC_URL;
        const solanaPrivateKey = process.env.SOLANA_PRIVATE_KEY;

        // Create a client using the `atxpClient` function
        const client = await atxpClient({
          mcpServer: searchService.mcpServer,
          account: new SolanaAccount(solanaRpcUrl, solanaPrivateKey),
        });
        ```
      </Tab>

      <Tab title="Using a Worldchain account">
        Create a client using a Worldchain account with MiniKit integration.

        ```typescript theme={null}
        // Import the ATXP client SDK and Worldchain account creator
        import { atxpClient } from '@atxp/client';
        import { createMiniKitWorldchainAccount } from '@atxp/worldchain';
        import { MiniKit } from '@worldcoin/minikit-js';

        // Create a Worldchain account using MiniKit
        const account = await createMiniKitWorldchainAccount({
          walletAddress: '0x1234...', // User's wallet address
          miniKit: MiniKit
        });

        // Create a client using the `atxpClient` function
        const client = await atxpClient({
          mcpServer: searchService.mcpServer,
          account,
        });
        ```
      </Tab>

      <Tab title="Using a Polygon account">
        **Browser applications:**

        ```typescript theme={null}
        // Import the ATXP client SDK and Polygon browser account
        import { atxpClient } from '@atxp/client';
        import { PolygonBrowserAccount } from '@atxp/polygon';

        // Initialize the Polygon browser account with wallet provider
        const account = await PolygonBrowserAccount.initialize({
          provider: window.ethereum, // or any EIP-1193 provider
          walletAddress: '0x1234...', // User's wallet address
        });

        // Create a client using the `atxpClient` function
        const client = await atxpClient({
          mcpServer: searchService.mcpServer,
          account,
        });
        ```

        **Server/CLI applications:**

        ```typescript theme={null}
        // Import the ATXP client SDK and Polygon server account
        import { atxpClient } from '@atxp/client';
        import { PolygonServerAccount } from '@atxp/polygon';

        // Read the Polygon account details from the environment variables
        const polygonRpcUrl = process.env.POLYGON_RPC_URL;
        const polygonPrivateKey = process.env.POLYGON_PRIVATE_KEY;

        // Create a Polygon server account
        const account = new PolygonServerAccount(
          polygonRpcUrl,
          polygonPrivateKey,
          137 // Chain ID: 137 = Polygon mainnet, 80002 = Amoy testnet
        );

        // Create a client using the `atxpClient` function
        const client = await atxpClient({
          mcpServer: searchService.mcpServer,
          account,
        });
        ```
      </Tab>
    </Tabs>
  </Step>

  <Step title="Use the Search service in your agent">
    Call the Search tool by passing your natural‑language instruction as the argument the `getArguments` method.

    Read the response using the `getResult` method.

    ```typescript theme={null}
    const prompt = "Search for MCP servers that can be used with an ATXP agent.";

    try {
      const result = await client.callTool({
          name: searchService.searchToolName,
          arguments: searchService.getArguments(prompt),
      });
      const searchResult = searchService.getResult(result);
      console.log('Status:', searchResult.status);
      if (searchResult.status === "success") {
        console.log('Results:', searchResult.results);
      } else {
        console.log('Error Message:', searchResult.errorMessage);
      }
    } catch (error) {
      console.error(`Error with ${searchService.description}:`, error);
      process.exit(1);
    }
    ```

    <Check>
      You should see the result of the search printed in your console.
    </Check>
  </Step>
</Steps>
