buy-from-spines-underground
Purchase paid digital content from Spine's Underground by paying USDC on Base. Receive the content inline after completing the payment challenge.
Instructions
Purchase paid content from Spine's Underground. Returns x402 payment challenge (HTTP 402) — pay USDC on Base to receive content inline. 10 paid products: $1.99–$4.99.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| product_id | Yes | Product ID to purchase (e.g. philosophy_of_spine, field_songs, temple_dawn) |
Implementation Reference
- index.js:136-139 (handler)Handler for the 'buy-from-spines-underground' tool. Calls fetchJSON on /buy/{product_id} and returns the result inline. For paid products, the API may return a 402 payment challenge (x402 protocol) handled by the fetchJSON helper.
case 'buy-from-spines-underground': { const data = await fetchJSON(`/buy/${args.product_id}`); return { content: [{ type: 'text', text: JSON.stringify(data, null, 2) }] }; } - index.js:55-67 (registration)Registration of the 'buy-from-spines-underground' tool in the ListToolsRequestSchema handler. Defines the tool name, description, and input schema requiring 'product_id'.
{ name: 'buy-from-spines-underground', description: 'Purchase paid content from Spine\'s Underground. Returns x402 payment challenge (HTTP 402) — pay USDC on Base to receive content inline. 10 paid products: $1.99–$4.99.', inputSchema: { type: 'object', properties: { product_id: { type: 'string', description: 'Product ID to purchase (e.g. philosophy_of_spine, field_songs, temple_dawn)', }, }, required: ['product_id'], }, - index.js:58-67 (schema)Input schema for the tool: requires a 'product_id' string. No output schema defined; returns raw JSON text content.
inputSchema: { type: 'object', properties: { product_id: { type: 'string', description: 'Product ID to purchase (e.g. philosophy_of_spine, field_songs, temple_dawn)', }, }, required: ['product_id'], }, - index.js:106-118 (helper)Helper function fetchJSON that makes requests to the API. Handles HTTP 402 responses by returning the PAYMENT-REQUIRED header info (x402 protocol) for paid purchases.
async function fetchJSON(path) { const res = await fetch(`${API_BASE}${path}`); if (res.status === 402) { const paymentHeader = res.headers.get('PAYMENT-REQUIRED'); return { status: 402, message: 'Payment required. This product costs USDC on Base via x402 protocol.', payment_challenge: paymentHeader, instructions: 'Decode the PAYMENT-REQUIRED header (base64 JSON) to get payment details. Sign a USDC transfer and re-request with PAYMENT-SIGNATURE header.', }; } return res.json(); }