Overview
In this tutorial, you’ll build a simple command-line client that uses ATXP to search the web. Starting from an empty directory, you’ll learn how to set up a project, install dependencies, configure authentication, and make your first MCP server call. By the end of this tutorial, you’ll have a working CLI that can search the web using the Search MCP server.Prerequisites
- Node.js installed (version 18 or higher recommended)
- An ATXP account with a connection string (learn how to create an account)
- A terminal or command prompt
Step 1: Create your project
First, let’s create a new directory for your project and navigate into it:package.json file with default values.
Step 2: Install dependencies
Install the ATXP client SDK and dotenv for managing environment variables:@atxp/client package provides everything you need to connect to MCP servers and make tool calls. The dotenv package helps you securely manage your connection string.
Step 3: Set up your environment variables
Create a.env file in your project directory to store your ATXP connection string:
.env file in your text editor and add your ATXP connection string:
.env
If you don’t have an ATXP connection string yet, follow the account creation guide to get one.
Step 4: Write your CLI script
Create a new file calledindex.js:
index.js in your text editor.
Step 4a: Load dependencies and create an account
Add the imports and create an ATXP account from your connection string:index.js
Step 4b: Connect to the Search MCP server
Create a client that connects to the Search MCP server:index.js
Step 4c: Call the search tool and display results
Call the search tool and output the results:index.js
Complete code
Your fullindex.js file should look like this:
index.js
Step 5: Run your CLI
Now you’re ready to run your CLI! Execute the following command:Congratulations! You’ve successfully built a working ATXP client that can search the web using MCP servers.
Understanding the code
Let’s break down what your CLI does:- Import dependencies: You import the ATXP client SDK and load environment variables
- Create account: You create an
ATXPAccountinstance using your connection string - Create client: You use
atxpClient()to create a client connected to the Search MCP server - Call tool: You use
client.callTool()to invoke thesearch_searchtool with a query - Parse results: You parse the JSON response and display the search results
Customizing your CLI
Now that you have a working CLI, try customizing it:Change the search query
Modify thequery argument in the callTool() call:
Accept command-line arguments
Make your CLI accept a search query as a command-line argument:Try different MCP servers
Explore other MCP servers by changing themcpServer URL. Check out the MCP Servers documentation to see what’s available.
Next steps
Explore MCP Servers
Discover other MCP servers you can use in your applications, from image generation to file storage.
Build a paid MCP server
Learn how to build and monetize your own MCP server with ATXP integration.
Client SDK Reference
Dive deeper into the ATXP Client SDK documentation and learn about advanced features.
Join the community
Join the ATXP community on Discord to ask questions, share your projects, and get help.