Skip to main content
Glama

createPrivateDownloadLink

Generate temporary download links to access private IPFS files from Pinata, with customizable expiration times for secure sharing.

Instructions

Generate a temporary download link for accessing a private IPFS file from Pinata

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cidYesThe content ID (CID) of the private file
expiresNoExpiration time in seconds (default: 600 = 10 minutes)

Implementation Reference

  • Complete implementation of createPrivateDownloadLink tool - includes registration, schema definition (cid string, expires number with default 600), and handler logic that generates temporary download links for private IPFS files via Pinata API
    server.tool(
      "createPrivateDownloadLink",
      "Generate a temporary download link for accessing a private IPFS file from Pinata",
      {
        cid: z.string().describe("The content ID (CID) of the private file"),
        expires: z
          .number()
          .default(600)
          .describe("Expiration time in seconds (default: 600 = 10 minutes)"),
      },
      async ({ cid, expires }) => {
        try {
          if (!GATEWAY_URL) {
            throw new Error("GATEWAY_URL environment variable is not set");
          }
    
          const apiUrl = `https://api.pinata.cloud/v3/files/private/download_link`;
          const url = `https://${GATEWAY_URL}/files/${cid}`;
          const date = Math.floor(new Date().getTime() / 1000);
    
          const payload = {
            url,
            expires,
            date,
            method: "GET",
          };
    
          const response = await fetch(apiUrl, {
            method: "POST",
            headers: getHeaders(),
            body: JSON.stringify(payload),
          });
    
          if (!response.ok) {
            throw new Error(
              `Failed to create download link: ${response.status} ${response.statusText}`
            );
          }
    
          const data = await response.json();
          const expirationTime = new Date((date + expires) * 1000).toLocaleString();
    
          return {
            content: [
              {
                type: "text",
                text: `✅ Private download link created!\n\nURL: ${data.data}\n\nExpires: ${expirationTime} (${expires} seconds from creation)`,
              },
            ],
          };
        } catch (error) {
          return errorResponse(error);
        }
      }
    );
  • getHeaders() helper function that constructs authentication headers for Pinata API requests using the PINATA_JWT environment variable
    const getHeaders = () => {
      if (!PINATA_JWT) {
        throw new Error("PINATA_JWT environment variable is not set");
      }
      return {
        Authorization: `Bearer ${PINATA_JWT}`,
        "Content-Type": "application/json",
      };
    };
  • errorResponse() helper function that formats error responses consistently across all tools
    // 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 mentions the link is 'temporary' but doesn't specify if it's read-only, requires permissions, has rate limits, or what happens on expiration. For a tool that likely involves access control, this is insufficient.

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 purpose without unnecessary details. Every word earns its place, 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?

Given the tool's complexity (generating access links for private files), no annotations, and no output schema, the description is incomplete. It lacks details on authentication needs, return values (e.g., link format), error conditions, or how it differs from similar tools, leaving significant gaps for an agent.

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?

Schema description coverage is 100%, so the schema fully documents both parameters (cid and expires). The description adds no additional meaning beyond what's in the schema, such as CID format details or expiration constraints, meeting the baseline for high schema coverage.

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

Purpose5/5

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

The description clearly states the specific action ('Generate a temporary download link') and the resource ('private IPFS file from Pinata'), distinguishing it from sibling tools like 'createLink' or 'fetchFromGateway' by specifying it's for private files and temporary access.

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 'createLink' or 'fetchFromGateway', nor does it mention prerequisites such as authentication or file privacy status. It lacks explicit context for tool selection.

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