insumer_configure_nfts
Define up to 4 NFT collections that grant customers discount percentages (1-50%) at your merchant. Specify collection name, contract address, chain (EVM, Solana, XRPL, Bitcoin), and optional XRPL taxon. Owner-only action.
Instructions
Configure NFT collections that grant discounts at the merchant. Max 4 collections. Owner only.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Merchant ID | |
| nftCollections | Yes | NFT collection configurations (0-4) |
Implementation Reference
- src/index.ts:140-146 (schema)NftCollectionSchema: Zod schema defining the shape of each NFT collection configuration item (name, contractAddress, taxon, chainId, discount).
const NftCollectionSchema = z.object({ name: z.string().max(50).describe("NFT collection name"), contractAddress: z.string().describe("NFT contract address. For XRPL: use r-address of the NFT issuer."), taxon: z.number().int().optional().describe("XRPL NFT taxon for filtering by collection. Optional, XRPL only."), chainId: OnboardingChainId, discount: z.number().int().min(1).max(50).describe("Discount percentage (1-50)"), }); - src/index.ts:564-584 (registration)Tool registration via server.tool(...) for "insumer_configure_nfts" with schema (id + nftCollections array of NftCollectionSchema, max 4) and async handler.
server.tool( "insumer_configure_nfts", "Configure NFT collections that grant discounts at the merchant. Max 4 collections. Owner only.", { id: z.string().describe("Merchant ID"), nftCollections: z .array(NftCollectionSchema) .min(0) .max(4) .describe("NFT collection configurations (0-4)"), }, async (args) => { const { id, ...body } = args; const result = await apiCall( "PUT", `/merchants/${encodeURIComponent(id)}/nfts`, body ); return formatResult(result); } ); - src/index.ts:575-583 (handler)Handler function: destructures args to extract 'id', sends PUT request to /merchants/{id}/nfts with the rest as body, then formats the result.
async (args) => { const { id, ...body } = args; const result = await apiCall( "PUT", `/merchants/${encodeURIComponent(id)}/nfts`, body ); return formatResult(result); } - src/index.ts:17-40 (helper)apiCall helper: generic HTTP request function that adds API key header and returns JSON result with ok/data/error/meta.
async function apiCall( method: string, path: string, body?: Record<string, unknown> ): Promise<{ ok: boolean; data?: unknown; error?: unknown; meta?: unknown }> { if (!apiKey) { return { ok: false, error: "INSUMER_API_KEY is not set. Call the insumer_setup tool to generate a free API key instantly, then add it to your MCP config as INSUMER_API_KEY and restart." }; } const url = `${API_BASE}${path}`; const res = await fetch(url, { method, headers: { "Content-Type": "application/json", "X-API-Key": apiKey, }, body: body ? JSON.stringify(body) : undefined, }); return res.json() as Promise<{ ok: boolean; data?: unknown; error?: unknown; meta?: unknown; }>; } - src/index.ts:61-76 (helper)formatResult helper: wraps API response into MCP content result format, setting isError flag if not ok.
function formatResult(result: { ok: boolean; data?: unknown; error?: unknown; meta?: unknown; }) { if (result.ok) { return { content: [{ type: "text" as const, text: JSON.stringify(result, null, 2) }], }; } return { content: [{ type: "text" as const, text: JSON.stringify(result, null, 2) }], isError: true, }; }