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
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | The payment instruction ID | |
| cid | Yes | The CID to associate |
Implementation Reference
- src/index.ts:1275-1310 (handler)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); } } );