Skip to main content
Glama

createLink

Generate direct access links for IPFS files stored on Pinata. For public files, create gateway URLs; for private files, produce temporary download links with customizable expiration times.

Instructions

Create a direct access link for a file stored on Pinata IPFS. For public files returns a gateway URL, for private files generates a temporary download link.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cidYesThe CID of the file to create a link for
networkNoWhether the file is on public or private IPFSpublic
expiresNoExpiration time in seconds for private download links (default: 600)

Implementation Reference

  • The createLink tool handler - creates a direct access link for files stored on Pinata IPFS. For public files, it returns a gateway URL. For private files, it generates a temporary download link with configurable expiration time using the Pinata API.
    server.tool(
      "createLink",
      "Create a direct access link for a file stored on Pinata IPFS. For public files returns a gateway URL, for private files generates a temporary download link.",
      {
        cid: z.string().describe("The CID of the file to create a link for"),
        network: z
          .enum(["public", "private"])
          .default("public")
          .describe("Whether the file is on public or private IPFS"),
        expires: z
          .number()
          .default(600)
          .describe(
            "Expiration time in seconds for private download links (default: 600)"
          ),
      },
      async ({ cid, network, expires = 600 }) => {
        try {
          if (!GATEWAY_URL) {
            throw new Error("GATEWAY_URL environment variable is not set");
          }
    
          if (network === "public") {
            const fileUrl = `https://${GATEWAY_URL}/ipfs/${cid}`;
            return {
              content: [
                {
                  type: "text",
                  text: `✅ Public IPFS link:\n${fileUrl}`,
                },
              ],
            };
          } else {
            const filePath = `https://${GATEWAY_URL}/files/${cid}`;
            const apiUrl = `https://api.pinata.cloud/v3/files/private/download_link`;
            const date = Math.floor(new Date().getTime() / 1000);
    
            const payload = {
              url: filePath,
              expires,
              date,
              method: "GET",
            };
    
            const linkResponse = await fetch(apiUrl, {
              method: "POST",
              headers: getHeaders(),
              body: JSON.stringify(payload),
            });
    
            if (!linkResponse.ok) {
              const errorText = await linkResponse.text();
              throw new Error(
                `Failed to create download link: ${linkResponse.status} ${linkResponse.statusText}. Response: ${errorText}`
              );
            }
    
            const linkData = await linkResponse.json();
            const expirationTime = new Date(
              (date + expires) * 1000
            ).toLocaleString();
    
            return {
              content: [
                {
                  type: "text",
                  text: `✅ Private IPFS temporary link:\n${linkData.data}\n\nExpires: ${expirationTime} (${expires} seconds from creation)`,
                },
              ],
            };
          }
        } catch (error) {
          return errorResponse(error);
        }
      }
    );
  • The tool schema definition for createLink - defines the input parameters using Zod validation: cid (required string), network (enum 'public' or 'private', default 'public'), and expires (number, default 600 seconds).
    {
      cid: z.string().describe("The CID of the file to create a link for"),
      network: z
        .enum(["public", "private"])
        .default("public")
        .describe("Whether the file is on public or private IPFS"),
      expires: z
        .number()
        .default(600)
        .describe(
          "Expiration time in seconds for private download links (default: 600)"
        ),
    },
Behavior3/5

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

With no annotations provided, the description carries the full burden. It discloses key behavioral traits: it creates links, handles both public (gateway URL) and private (temporary download link) files, and mentions expiration for private links. However, it omits details like rate limits, authentication needs, or error conditions.

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 front-loaded and efficient with two sentences that directly explain the tool's function and outcomes. Every sentence earns its place by clarifying the tool's behavior without unnecessary details.

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

Completeness3/5

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

Given no annotations and no output schema, the description is moderately complete for a 3-parameter tool. It covers the basic purpose and behavioral context but lacks details on return values, error handling, or advanced usage scenarios, leaving some gaps for an AI 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 already documents all parameters well. The description adds marginal value by hinting at the 'network' parameter's effect (public vs. private outcomes) and 'expires' usage for private links, but doesn't provide additional syntax or format details beyond the schema.

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 ('create a direct access link') and resource ('file stored on Pinata IPFS'), distinguishing it from siblings like 'createPrivateDownloadLink' by covering both public and private cases. It precisely explains what the tool does without being tautological.

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

Usage Guidelines3/5

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

The description implies usage for generating file access links on IPFS, but does not explicitly state when to use this tool versus alternatives like 'createPrivateDownloadLink' or 'fetchFromGateway'. It provides some context but lacks clear exclusions or named alternatives.

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