search-spines-underground
Search the Spines Underground catalog by keyword to find curated products in poetry, philosophy, music theory, and more. Matches product names, descriptions, and shop names.
Instructions
Search Spine's Underground catalog by keyword. Searches product names, descriptions, and shop names.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Search term (e.g. "poetry", "philosophy", "music", "memory") |
Implementation Reference
- index.js:146-167 (handler)Handler for 'search-spines-underground' tool. Fetches the full catalog, filters products by keyword match across name, description, shop, agent_summary, and id fields, and returns matching results.
case 'search-spines-underground': { const catalog = await fetchJSON('/catalog'); const q = (args.query || '').toLowerCase(); const matches = catalog.catalog.filter(p => p.name.toLowerCase().includes(q) || p.description.toLowerCase().includes(q) || p.shop.toLowerCase().includes(q) || p.agent_summary.toLowerCase().includes(q) || p.id.toLowerCase().includes(q) ); return { content: [{ type: 'text', text: JSON.stringify({ query: args.query, results: matches, total: matches.length, full_catalog: `${API_BASE}/catalog`, }, null, 2), }], }; } - index.js:88-100 (registration)Tool registration (schema definition) for 'search-spines-underground' in the ListToolsRequestSchema handler. Lists the tool name, description, and input schema requiring a 'query' string parameter.
name: 'search-spines-underground', description: "Search Spine's Underground catalog by keyword. Searches product names, descriptions, and shop names.", inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'Search term (e.g. "poetry", "philosophy", "music", "memory")', }, }, required: ['query'], }, }, - index.js:106-118 (helper)Helper function fetchJSON used by the handler to fetch the catalog from the API. Handles 402 payment responses specially.
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(); }