list_commodity_transactions
Retrieve and paginate your commodity transaction history from Bitpanda, showing newest transactions first to track trading activity.
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)Handler function that fetches commodity transactions from the Bitpanda API endpoint /assets/transactions/commodity using the provided cursor and page_size parameters.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 definition for the tool using Zod, defining optional cursor and page_size parameters.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:41-57 (registration)Registers all Bitpanda tools, including list_commodity_transactions, with the MCP server using server.tool() in a loop over the tool definitions.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)Defines and exports the tool definition object including name, description, input schema, and handler for 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, };