Follow a complete tutorial to build your first agent with ATXP integration.
Create a new repository from the template
Visit this link to create a new repository from the template. You can name your repository whatever you want, but we’ll call it agent-demo
in this tutorial. If you name your repository differently, make sure to replace agent-demo
with the name of your repository in the following steps.
Clone the repository
Clone the repository to your local machine. You can do this by running the following command in your terminal:
your-username
with your actual GitHub username, and agent-demo
with the name of your repository if you named it differently.git clone git@github.com:your-username/agent-demo.git
. If you haven’t set up SSH access with GitHub, you’ll need to supply your GitHub username and password when prompted to clone your repository.Install dependencies
Install the dependencies for the frontend and backend by running the following command in your terminal:
Create an ATXP account
Store your ATXP connection string in an environment variable
.env
file in the backend
directory of your project and set the ATXP_CONNECTION_STRING
environment variable to your connection string. The atxp-agent-starter template provides an example .env
file in the backend
directory calle env.example
.As you might guess from the name, that file is meant to be an example and not the actual .env
file that your project uses. Copy the env.example
file to .env
and then edit it with your connection string..env
file and set the ATXP_CONNECTION_STRING
environment variable to your connection string..env
file to version control. It is a good idea to add your .env
to your .gitignore
file to prevent it from being committed.Define MCP server helper objects
backend/server.ts
file for each of the MCP servers we want to use. The atxp-agent-starter template already contains an example helper object for the Image MCP server that is commented out. Let’s uncomment it.Create the ATXP client objects
callTool
function on the ATXP client object for each MCP server we want to use. We’ll wrap these calls in a try/catch
block to gracefully handle any errors that may occur.
Call the Image MCP server
Call the Filestore MCP server
try/catch
block nested inside of the try
block for our image generation tool call.First, let’s remove some code that we don’t need anymore.// Note: If you want to use ...
comment, which calls the Filestore MCP server’s tool to store the image.fileName
and imageUrl
properties to the newText
object, but these properties aren’t defined in the Text
interface. Let’s fix these type errors in the next step.Modify the `Text` interface
Text
interface to include the fileName
and imageUrl
properties. Make the following changes to the Text
interface in the backend/server.ts
file.newText
object to include the fileName
and imageUrl
properties. Make the following changes to the newText
object instantiation in the backend/server.ts
file.npm run build
, but we’re not done yet. When our agent finishes generating an image and storing it with the Filestore MCP server, we want to actually see the image in the frontend .Update the `frontend/src/App.tsx` file
Text
interface to include the imageUrl
and fileName
properties. Make the following changes to the Text
interface in the frontend/src/App.tsx
file.Display the image in the frontend
Text
interface on both the frontend to match the structure we are passed from the backend, we can update the frontend to display the image.Add the following lines to the frontend/src/App.tsx
file.npm run dev
from the root directory of your project to start the frontend and backend servers. If your browser doesn’t automatically open to http://localhost:3000, navigate there manually.
Submit a simple prompt like Make an image of a car
. You should see progress updates as your agent first generates the image and then store it at a publicly accessible URL, and finally see the image displayed!