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
| Name | Required | Description | Default |
|---|---|---|---|
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); } } ); - src/index.ts:134-162 (handler)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); } } - src/index.ts:100-108 (helper)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", }; }; - src/index.ts:111-119 (helper)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, });