insumer_configure_tokens
Set discount tiers for own and partner tokens. Define up to 8 tokens with balance thresholds and discount percentages to enable token-based pricing for merchants. Owner access required.
Instructions
Configure merchant token discount tiers. Set own token and/or partner tokens. Max 8 tokens total. Owner only.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Merchant ID | |
| ownToken | No | Merchant's own token configuration, or null to remove | |
| partnerTokens | No | Partner token configurations |
Implementation Reference
- src/index.ts:131-138 (schema)TokenConfigSchema – defines the input schema for token configuration (symbol, chainId, contractAddress, decimals, currency, tiers). Used by the insumer_configure_tokens tool.
const TokenConfigSchema = z.object({ symbol: z.string().max(10).describe("Token symbol, e.g. 'UNI'"), chainId: OnboardingChainId, contractAddress: z.string().describe("Token contract address. For XRPL: use r-address issuer for trust line tokens, or 'native' for XRP."), decimals: z.number().int().min(0).max(18).optional().describe("Token decimals (0-18, default 18)"), currency: z.string().optional().describe("XRPL trust line currency code (e.g. 'RLUSD', 'USDC', or 'USD'). Required for XRPL trust line tokens. Standard codes ≤ 3 chars; longer names like 'RLUSD' are auto hex-encoded by the API."), tiers: z.array(TierSchema).min(1).max(4).describe("1-4 discount tiers"), }); - src/index.ts:125-129 (schema)TierSchema – defines a discount tier (name, threshold, discount). Nested inside TokenConfigSchema.
const TierSchema = z.object({ name: z.string().max(30).describe("Tier name, e.g. 'Gold', 'Silver'"), threshold: z.number().positive().describe("Minimum token balance for this tier"), discount: z.number().int().min(1).max(50).describe("Discount percentage (1-50)"), }); - src/index.ts:540-562 (registration)Registration of the 'insumer_configure_tokens' tool on the MCP server via server.tool(), including the description, input schema, and handler callback.
server.tool( "insumer_configure_tokens", "Configure merchant token discount tiers. Set own token and/or partner tokens. Max 8 tokens total. Owner only.", { id: z.string().describe("Merchant ID"), ownToken: TokenConfigSchema.nullable() .optional() .describe("Merchant's own token configuration, or null to remove"), partnerTokens: z .array(TokenConfigSchema) .optional() .describe("Partner token configurations"), }, async (args) => { const { id, ...body } = args; const result = await apiCall( "PUT", `/merchants/${encodeURIComponent(id)}/tokens`, body ); return formatResult(result); } ); - src/index.ts:553-561 (handler)Handler function executed when the tool is called. Extracts 'id' and remaining body, then makes a PUT API call to /merchants/{id}/tokens and formats the result.
async (args) => { const { id, ...body } = args; const result = await apiCall( "PUT", `/merchants/${encodeURIComponent(id)}/tokens`, body ); return formatResult(result); } - src/index.ts:17-40 (helper)apiCall – shared HTTP helper used by the handler to make authenticated API requests.
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; }>; }