list_trades
Retrieve and view your complete trading history from Bitpanda, with paginated results showing newest trades first for easy tracking.
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 |
|---|---|---|---|
| type | No | One of `buy` or `sell` | |
| 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 |
Implementation Reference
- src/tools/trades.ts:57-89 (handler)Handler function that fetches trades from the Bitpanda API endpoint '/trades' using the provided input parameters (type, cursor, page_size), handles errors, and returns the paginated response.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)Zod input schema shape defining optional parameters: type (buy/sell), cursor (pagination), page_size.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)Exports the tool definition object for 'list_trades', bundling name, description, input schema shape, and handler reference for use in registration.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:41-57 (registration)Registers all Bitpanda tools (including list_trades via the bitpandaToolDefinitions array) with the MCP server by calling server.tool() for each.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); } }); };