Skip to main content

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

Takes file data and saves it to the file store. For example, if you need to save a file between conversations, you can use this tool.

Arguments

Accepts a JSON object with the following properties:
base64Content
string
The base64 encoded content of the file to save.
sourceUrl
string
The URL of a file to copy contents from.
contentType
string
The content type of the file to save
fileExtension
string
The file extension of the file to save
makePublic
boolean
Whether to make the file public.

Response

Returns a JSON object with the following properties:
status
string
The status of the save file operation. The status key will have the value “success” when the file is saved successfully.
filename
string
The name of the file that was saved.
url
string
The URL that the file is accessible at.
Returns the contents of a file from the file store. For example, if you need to read a file between conversations, you can use this tool.

Arguments

Accepts a JSON object with the following properties:
fileId
string
required
The ID of the file to read.

Response

Returns a JSON object with the following properties:
status
string
The status of the read file operation. The status key will have the value “success” when the file is read successfully.
filename
string
The name of the file that was read.
base64Content
string
The base64 encoded content of the file that was read.
Deletes a file from the file store. For example, if you need to delete a file between conversations, you can use this tool.

Arguments

Accepts a JSON object with the following properties:
filename
string
required
The name of the file to delete.

Response

Returns a JSON object with the following properties:
status
string
The status of the delete file operation. The status key will have the value “success” when the file is deleted successfully.
filename
string
The name of the file that was deleted.

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

  • Using an ATXP account
  • Using a Base account
  • Using a Solana account
  • Using a Worldchain account
  • Using a Polygon account
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.
I