Skip to main content
Glama

addCidToPaymentInstruction

Associates a CID with a payment instruction to enable x402 monetization for IPFS content on Pinata MCP server.

Instructions

Associate a CID with a payment instruction for x402 monetization

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesThe payment instruction ID
cidYesThe CID to associate

Implementation Reference

  • The complete implementation of the addCidToPaymentInstruction tool, including its registration with the MCP server and the handler function that makes a PUT request to the Pinata API to associate a CID with a payment instruction.
    server.tool(
      "addCidToPaymentInstruction",
      "Associate a CID with a payment instruction for x402 monetization",
      {
        id: z.string().describe("The payment instruction ID"),
        cid: z.string().describe("The CID to associate"),
      },
      async ({ id, cid }) => {
        try {
          const url = `https://api.pinata.cloud/v3/x402/payment_instructions/${id}/cids/${cid}`;
    
          const response = await fetch(url, {
            method: "PUT",
            headers: getHeaders(),
          });
    
          if (!response.ok) {
            throw new Error(
              `Failed to add CID to payment instruction: ${response.status} ${response.statusText}`
            );
          }
    
          const data = await response.json();
          return {
            content: [
              {
                type: "text",
                text: `✅ CID added to payment instruction successfully!\n\n${JSON.stringify(data, null, 2)}`,
              },
            ],
          };
        } catch (error) {
          return errorResponse(error);
        }
      }
    );

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