Overview

Use the Filestore MCP server from your ATXP-powered agent to store, retrieve, and delete files.

Example prompts

  • “Upload the file example.txt to the filestore.”
  • “Download the file example.txt from the filestore.”
  • “Delete the file example.txt from the filestore.”

Tools

Usage

1

Define the Filestore 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 Filestore tools in a consistent manner.
const filestoreService = {
    mcpServer: 'https://filestore.mcp.atxp.ai/',
    writeFileToolName: 'filestore_write',
    description: 'ATXP Filestore MCP server',
    getArguments: (sourceURL: string) => ({ sourceURL }),
    getResult: (result: any) => {
      const jsonResult = result.content[0].text
      return JSON.parse(jsonResult);
    }
  };
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: filestoreService.mcpServer,
  account: new ATXPAccount(atxpConnectionString),
});
3

Use the Filestore service in your agent

Call the Filestore tool by passing your natural-language instruction as the argument the getArguments method.Read the response using the getResult method.
const sourceURL = "https://media2.giphy.com/media/v1.Y2lkPTc5MGI3NjExN3FycXEzcnVpeDJiZnZlMThoc3R2aDdnM2NrY2hxY3J3eHFqaG92cyZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/DYH297XiCS2Ck/giphy.gif"

try {
  const writeResult = await client.callTool({
      name: filestoreService.writeFileToolName,
      arguments: filestoreService.getArguments(sourceURL),
  });
  const writeResult = filestoreService.getResult(writeResult);
  console.log('Status:', writeResult.status);
  console.log('Filename:', writeResult.filename);
  console.log('URL:', writeResult.url);
} catch (error) {
  console.error(`Error with ${filestoreService.description}:`, error);
  process.exit(1);
}
You should see the result of the filestore operation printed in your console.