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.
Create a client using an ATXP account by importing the ATXP client SDK and other dependencies.
Copy
Ask AI
// Import the ATXP client SDKimport { atxpClient, ATXPAccount } from '@atxp/client';// Read the ATXP account details from environment variablesconst atxpConnectionString = process.env.ATXP_CONNECTION;// Create a client using the `atxpClient` functionconst 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.
Copy
Ask AI
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.