Skip to main content
Glama

testAuthentication

Verify Pinata JWT authentication status to ensure API access for IPFS file operations.

Instructions

Verify that your Pinata JWT is valid and working

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • src/index.ts:130-163 (registration)
    Tool registration and handler for testAuthentication - verifies Pinata JWT validity by making a GET request to the Pinata API
    server.tool(
      "testAuthentication",
      "Verify that your Pinata JWT is valid and working",
      {},
      async () => {
        try {
          const response = await fetch(
            "https://api.pinata.cloud/data/testAuthentication",
            {
              method: "GET",
              headers: getHeaders(),
            }
          );
    
          if (!response.ok) {
            throw new Error(
              `Authentication failed: ${response.status} ${response.statusText}`
            );
          }
    
          const data = await response.json();
          return {
            content: [
              {
                type: "text",
                text: `✅ Authentication successful!\n\n${JSON.stringify(data, null, 2)}`,
              },
            ],
          };
        } catch (error) {
          return errorResponse(error);
        }
      }
    );
  • Handler function that executes the authentication test by calling Pinata's testAuthentication API endpoint
    async () => {
      try {
        const response = await fetch(
          "https://api.pinata.cloud/data/testAuthentication",
          {
            method: "GET",
            headers: getHeaders(),
          }
        );
    
        if (!response.ok) {
          throw new Error(
            `Authentication failed: ${response.status} ${response.statusText}`
          );
        }
    
        const data = await response.json();
        return {
          content: [
            {
              type: "text",
              text: `✅ Authentication successful!\n\n${JSON.stringify(data, null, 2)}`,
            },
          ],
        };
      } catch (error) {
        return errorResponse(error);
      }
    }
  • Helper function that constructs headers with Bearer token authentication using 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",
      };
    };
  • Helper function that formats error responses in a consistent MCP format
    const errorResponse = (error: unknown) => ({
      content: [
        {
          type: "text" as const,
          text: `Error: ${error instanceof Error ? error.message : String(error)}`,
        },
      ],
      isError: true,
    });

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