Skip to main content
Glama

deleteFile

Remove files from your Pinata IPFS storage by specifying the file ID to manage storage space and content organization.

Instructions

Delete a file from your Pinata account by its ID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
networkNoWhether the file is in public or private IPFSpublic
idYesThe unique ID of the file to delete

Implementation Reference

  • src/index.ts:293-331 (registration)
    The deleteFile tool is registered here with its schema and handler. It takes parameters for 'network' (public/private IPFS, defaults to public) and 'id' (file ID). The handler makes a DELETE request to the Pinata API to remove the file.
    server.tool(
      "deleteFile",
      "Delete a file from your Pinata account by its ID",
      {
        network: z
          .enum(["public", "private"])
          .default("public")
          .describe("Whether the file is in public or private IPFS"),
        id: z.string().describe("The unique ID of the file to delete"),
      },
      async ({ network, id }) => {
        try {
          const url = `https://api.pinata.cloud/v3/files/${network}/${id}`;
    
          const response = await fetch(url, {
            method: "DELETE",
            headers: getHeaders(),
          });
    
          if (!response.ok) {
            throw new Error(
              `Failed to delete file: ${response.status} ${response.statusText}`
            );
          }
    
          const data = await response.json();
          return {
            content: [
              {
                type: "text",
                text: `✅ File deleted successfully\n\n${JSON.stringify(data, null, 2)}`,
              },
            ],
          };
        } catch (error) {
          return errorResponse(error);
        }
      }
    );
  • Schema definition for deleteFile tool parameters using Zod validation: network (enum: 'public' | 'private', default: 'public') and id (required string).
    {
      network: z
        .enum(["public", "private"])
        .default("public")
        .describe("Whether the file is in public or private IPFS"),
      id: z.string().describe("The unique ID of the file to delete"),
    },
  • Handler function for deleteFile that constructs the API URL, makes a DELETE request to Pinata's v3 files endpoint, and returns a success message with the response data or an error response.
    async ({ network, id }) => {
      try {
        const url = `https://api.pinata.cloud/v3/files/${network}/${id}`;
    
        const response = await fetch(url, {
          method: "DELETE",
          headers: getHeaders(),
        });
    
        if (!response.ok) {
          throw new Error(
            `Failed to delete file: ${response.status} ${response.statusText}`
          );
        }
    
        const data = await response.json();
        return {
          content: [
            {
              type: "text",
              text: `✅ File deleted successfully\n\n${JSON.stringify(data, null, 2)}`,
            },
          ],
        };
      } catch (error) {
        return errorResponse(error);
      }
    }
  • Helper function used by deleteFile handler to get authenticated request headers including the JWT Bearer token for Pinata API authentication.
    const getHeaders = () => {
      if (!PINATA_JWT) {
        throw new Error("PINATA_JWT environment variable is not set");
      }
      return {
        Authorization: `Bearer ${PINATA_JWT}`,
        "Content-Type": "application/json",
      };
    };
  • Helper function for consistent error responses used by deleteFile handler to format errors in a standardized way with isError flag set to true.
    // Helper for consistent error responses
    const errorResponse = (error: unknown) => ({
      content: [
        {
          type: "text" as const,
          text: `Error: ${error instanceof Error ? error.message : String(error)}`,
        },
      ],
      isError: true,
    });
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool deletes a file, implying a destructive mutation, but doesn't mention critical aspects like whether deletion is permanent, requires specific permissions, has rate limits, or what happens on success/failure. This leaves significant gaps for safe agent operation.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core action ('Delete a file') without unnecessary words. Every part of the sentence contributes directly to understanding the tool's function, making it highly concise and well-structured.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a destructive tool with no annotations and no output schema, the description is insufficient. It lacks details on behavioral traits (e.g., permanence, error handling), usage context relative to siblings, and output expectations, making it incomplete for safe and effective agent use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description mentions the 'id' parameter ('by its ID'), adding some context beyond the schema's description. However, it doesn't address the 'network' parameter or provide additional details like format examples or constraints. With 100% schema description coverage, the baseline is 3, and the description adds minimal value.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Delete') and resource ('a file from your Pinata account by its ID'), making the purpose immediately understandable. However, it doesn't explicitly differentiate from sibling tools like 'deleteFileVectors' or 'deleteGroup', which would require a more specific scope statement to earn a 5.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'deleteFileVectors' or 'deleteGroup', nor does it mention prerequisites (e.g., needing the file ID from a previous operation). It simply states what the tool does without context for selection among siblings.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/PinataCloud/pinata-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server