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

Usage

1

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.
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)
  };
2

Create an ATXP client

Create a client using an ATXP account by importing the ATXP client SDK and other dependencies.
// 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),
});
3

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.
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);
}
You should see the result of the search printed in your console.