Skip to main content
Glama

searchFiles

Find files in your Pinata IPFS storage by filename, content ID, or file type to locate specific content across public or private networks.

Instructions

Search for files in your Pinata account by name, CID, or MIME type. Returns a list of files matching the given criteria.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
networkNoWhether to search in public or private IPFSpublic
nameNoFilter by filename
cidNoFilter by content ID (CID)
mimeTypeNoFilter by MIME type
limitNoMaximum number of results to return
pageTokenNoToken for pagination

Implementation Reference

  • Handler function that executes the searchFiles tool logic - constructs API query parameters, calls the Pinata API to search files by name/CID/MIME type, and returns the results
    async ({ network, name, cid, mimeType, limit, pageToken }) => {
      try {
        const params = new URLSearchParams();
        if (name) params.append("name", name);
        if (cid) params.append("cid", cid);
        if (mimeType) params.append("mimeType", mimeType);
        if (limit) params.append("limit", limit.toString());
        if (pageToken) params.append("pageToken", pageToken);
    
        const url = `https://api.pinata.cloud/v3/files/${network}?${params.toString()}`;
    
        const response = await fetch(url, {
          method: "GET",
          headers: getHeaders(),
        });
    
        if (!response.ok) {
          throw new Error(
            `Failed to search files: ${response.status} ${response.statusText}`
          );
        }
    
        const data = await response.json();
        return successResponse(data);
      } catch (error) {
        return errorResponse(error);
      }
    }
  • Zod schema defining the input parameters for searchFiles: network (public/private), name, cid, mimeType, limit, and pageToken for filtering and pagination
    {
      network: z
        .enum(["public", "private"])
        .default("public")
        .describe("Whether to search in public or private IPFS"),
      name: z.string().optional().describe("Filter by filename"),
      cid: z.string().optional().describe("Filter by content ID (CID)"),
      mimeType: z.string().optional().describe("Filter by MIME type"),
      limit: z
        .number()
        .optional()
        .describe("Maximum number of results to return"),
      pageToken: z.string().optional().describe("Token for pagination"),
    },
  • src/index.ts:169-214 (registration)
    Tool registration using server.tool() with name 'searchFiles', description, input schema, and async handler function
    server.tool(
      "searchFiles",
      "Search for files in your Pinata account by name, CID, or MIME type. Returns a list of files matching the given criteria.",
      {
        network: z
          .enum(["public", "private"])
          .default("public")
          .describe("Whether to search in public or private IPFS"),
        name: z.string().optional().describe("Filter by filename"),
        cid: z.string().optional().describe("Filter by content ID (CID)"),
        mimeType: z.string().optional().describe("Filter by MIME type"),
        limit: z
          .number()
          .optional()
          .describe("Maximum number of results to return"),
        pageToken: z.string().optional().describe("Token for pagination"),
      },
      async ({ network, name, cid, mimeType, limit, pageToken }) => {
        try {
          const params = new URLSearchParams();
          if (name) params.append("name", name);
          if (cid) params.append("cid", cid);
          if (mimeType) params.append("mimeType", mimeType);
          if (limit) params.append("limit", limit.toString());
          if (pageToken) params.append("pageToken", pageToken);
    
          const url = `https://api.pinata.cloud/v3/files/${network}?${params.toString()}`;
    
          const response = await fetch(url, {
            method: "GET",
            headers: getHeaders(),
          });
    
          if (!response.ok) {
            throw new Error(
              `Failed to search files: ${response.status} ${response.statusText}`
            );
          }
    
          const data = await response.json();
          return successResponse(data);
        } catch (error) {
          return errorResponse(error);
        }
      }
    );
  • Helper function getHeaders() that returns the Authorization header with Bearer token for authenticated API requests to Pinata
    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 successResponse() that formats successful API responses as text content with JSON stringified data
    const successResponse = (data: unknown) => ({
      content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }],
    });
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 tool returns a list of files but doesn't describe pagination behavior (implied by 'pageToken' parameter), rate limits, authentication requirements, or error conditions. For a search tool with 6 parameters, this leaves significant gaps in understanding how it behaves.

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 efficiently structured in two clear sentences: one stating the search functionality and criteria, another stating the return value. Every word contributes meaning with zero waste or redundancy.

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 the tool's moderate complexity (6 parameters, search functionality) and lack of both annotations and output schema, the description is minimally adequate. It covers the basic purpose but lacks details about behavioral traits, usage context, and return format that would be helpful 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 thoroughly. The description adds minimal value by mentioning three filter criteria (name, CID, MIME type) but doesn't provide additional context beyond what's in the schema. This meets the baseline for high schema coverage.

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 tool searches for files by specific criteria (name, CID, or MIME type) and returns matching files, providing a specific verb ('search') and resource ('files in your Pinata account'). However, it doesn't explicitly differentiate from sibling tools like 'getFileById' or 'listGroups', which reduces it from a perfect score.

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 mentions what the tool does but provides no guidance on when to use it versus alternatives like 'getFileById' (for specific files) or 'listGroups' (for broader listings). There's no mention of prerequisites, performance considerations, or typical use cases.

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