list_commodity_transactions
Retrieve paginated lists of all commodity transactions from the Bitpanda API, sorted by newest first. Use cursor pagination to manage and access transaction data efficiently.
Instructions
Lists all user's commodity transactions from the Bitpanda API. Newest commodity transactions come first. Response is cursor paginated.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cursor | No | Id of the last known commodity transaction by the client. Only commodity transactions after this id are returned. Empty or missing cursor parameter will return commodity transactions from the start. | |
| page_size | No | Size of a page for the paginated response |
Implementation Reference
- src/tools/commodity.ts:87-117 (handler)The handler function that executes the tool logic: fetches commodity transactions from Bitpanda API using the provided cursor and page_size parameters, handles errors, and returns paginated data.const listCommodityTransactionsHandler = async (input: Input): Promise<Output> => { try { const apiKey = getBitpandaApiKey(); const url = `${BITPANDA_API_BASE_URL}/assets/transactions/commodity`; const params: any = {}; // Use any for now, refine later if needed if (input.cursor) { params.cursor = input.cursor; } if (input.page_size) { params.page_size = input.page_size; } const response = await axios.get<Output>(url, { headers: { 'X-Api-Key': apiKey, 'Content-Type': 'application/json', }, params, }); // Return the data received from the Bitpanda API return response.data; } catch (error: unknown) { console.error('Error fetching Bitpanda commodity transactions:', error); const message = error instanceof Error ? error.message : 'An unknown error occurred while fetching commodity transactions.'; // Re-throwing the error to be handled by the MCP server framework throw new Error(`Failed to fetch Bitpanda commodity transactions: ${message}`); } };
- src/tools/commodity.ts:6-14 (schema)Input schema shape using Zod, defining optional cursor (string) for pagination and page_size (positive integer).const listCommodityTransactionsInputSchemaShape = { cursor: z .string() .optional() .describe( 'Id of the last known commodity transaction by the client. Only commodity transactions after this id are returned. Empty or missing cursor parameter will return commodity transactions from the start.' ), page_size: z.number().int().positive().optional().describe('Size of a page for the paginated response'), };
- src/tools/index.ts:24-35 (registration)The tool is included in the array of Bitpanda tools (line 31 specifically adds listCommodityTransactionsTool), which are then registered with the MCP server.const bitpandaToolDefinitions: BitpandaToolDefinition[] = [ listTradesTool, // Add the listTradesTool to the array listAssetWalletsTool, // Add the listAssetWalletsTool to the array listFiatWalletsTool, // Add the listFiatWalletsTool to the array listFiatTransactionsTool, // Add the listFiatTransactionsTool to the array listCryptoWalletsTool, // Add the listCryptoWalletsTool to the array listCryptoTransactionsTool, // Add the listCryptoTransactionsTool to the array listCommodityTransactionsTool, // Add the listCommodityTransactionsTool to the array assetInfoTool, // Add the assetInfoTool to the array // ohlcTool, // Add the ohlcTool to the array // Other tools will be added here as they are implemented ];
- src/tools/index.ts:41-57 (registration)Function that registers all tools from the bitpandaToolDefinitions array with the MCP server using server.tool(), including the list_commodity_transactions tool.export const registerBitpandaTools = (server: McpServer): void => { bitpandaToolDefinitions.forEach((toolDef) => { try { // Pass the raw shape to the inputSchema parameter, assuming SDK handles z.object() server.tool(toolDef.name, toolDef.description, toolDef.inputSchemaShape, async (input) => { const result = await toolDef.handler(input); // Assuming the handler returns the data directly, wrap it in the MCP content format return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }], }; }); console.log(`Registered Bitpanda tool: ${toolDef.name}`); } catch (error) { console.error(`Failed to register tool ${toolDef.name}:`, error); } }); };
- src/tools/commodity.ts:128-134 (registration)Exports the tool definition object, which bundles the name, description, input schema shape, and handler for use in registration.export const listCommodityTransactionsTool: BitpandaToolDefinition = { name: 'list_commodity_transactions', description: "Lists all user's commodity transactions from the Bitpanda API. Newest commodity transactions come first. Response is cursor paginated.", inputSchemaShape: listCommodityTransactionsInputSchemaShape, handler: listCommodityTransactionsHandler, };