list_trades
Retrieve paginated trade history from the Bitpanda API, filtering by trade type (buy/sell) and using cursor-based pagination for efficient data handling.
Instructions
Lists all user's trades from the Bitpanda API. Newest trades come first. Response is cursor paginated.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cursor | No | Id of the last known trade by the client. Only trades after this id are returned. Empty or missing cursor parameter will return trades from the start. | |
| page_size | No | Size of a page for the paginated response | |
| type | No | One of `buy` or `sell` |
Implementation Reference
- src/tools/trades.ts:57-89 (handler)The handler function that executes the list_trades tool logic, fetching trades from the Bitpanda API using axios.const listTradesHandler = async (input: Input): Promise<Output> => { try { const apiKey = getBitpandaApiKey(); const url = `${BITPANDA_API_BASE_URL}/trades`; const params: any = {}; // Use any for now, refine later if needed if (input.type) { params.type = input.type; } 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', // Assuming JSON content type }, params, }); // Return the data received from the Bitpanda API return response.data; } catch (error: unknown) { console.error('Error fetching Bitpanda trades:', error); const message = error instanceof Error ? error.message : 'An unknown error occurred while fetching trades.'; // Re-throwing the error to be handled by the MCP server framework throw new Error(`Failed to fetch Bitpanda trades: ${message}`); } };
- src/tools/trades.ts:6-15 (schema)Input schema definition for the list_trades tool using Zod.const listTradesInputSchemaShape = { type: z.enum(['buy', 'sell']).optional().describe('One of `buy` or `sell`'), cursor: z .string() .optional() .describe( 'Id of the last known trade by the client. Only trades after this id are returned. Empty or missing cursor parameter will return trades from the start.' ), page_size: z.number().int().positive().optional().describe('Size of a page for the paginated response'), };
- src/tools/trades.ts:100-105 (registration)Tool definition export for list_trades, bundling name, description, schema, and handler.export const listTradesTool: BitpandaToolDefinition = { name: 'list_trades', description: "Lists all user's trades from the Bitpanda API. Newest trades come first. Response is cursor paginated.", inputSchemaShape: listTradesInputSchemaShape, handler: listTradesHandler, };
- src/tools/index.ts:24-35 (registration)Array of tool definitions including listTradesTool, used for bulk registration to 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)Registration function that calls server.tool for each tool, including list_trades.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); } }); };