get_asset_info
Retrieve detailed asset information using the asset's trading symbol with the Model Context Protocol on Bitpanda Server. Input the symbol to access key data in a structured format.
Instructions
Retrieves detailed information for a specific asset by its symbol.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| symbol | Yes | The trading symbol of the asset (e.g., BTC, XAU) |
Implementation Reference
- src/tools/assetInfo.ts:19-32 (handler)The main handler function for the 'get_asset_info' tool. It takes input symbol, calls the helper utility to find the asset, and returns the asset info or throws an error.// Define the handler function for the get_asset_info tool const assetInfoHandler = async (input: Input): Promise<Output> => { try { const foundAsset = await findAssetBySymbol(input.symbol); // Return the found asset object return foundAsset; } catch (error: unknown) { console.error('Error fetching asset info:', error); const message = error instanceof Error ? error.message : 'An unknown error occurred while fetching asset info.'; // Re-throwing the error to be handled by the MCP server framework throw new Error(`Failed to fetch asset info: ${message}`); } };
- src/tools/assetInfo.ts:4-18 (schema)Zod input schema for the symbol parameter and TypeScript type definitions for input and output of the get_asset_info tool.// Define the input schema shape for the get_asset_info tool const assetInfoInputSchemaShape = { symbol: z.string().describe('The trading symbol of the asset (e.g., BTC, XAU)'), }; type RawSchemaShape = typeof assetInfoInputSchemaShape; type Input = z.infer<z.ZodObject<RawSchemaShape>>; // Define the expected output structure (simplified, based on the documentation summary) type Output = { type: string; attributes: Record<string, any>; // Use Record<string, any> for flexibility id: string; };
- src/tools/assetInfo.ts:42-48 (registration)The tool definition object that bundles the name, description, schema, and handler, exported for registration in index.ts.// Export the tool definition for get_asset_info export const assetInfoTool: BitpandaToolDefinition = { name: 'get_asset_info', description: 'Retrieves detailed information for a specific asset by its symbol.', inputSchemaShape: assetInfoInputSchemaShape, handler: assetInfoHandler, };
- src/tools/index.ts:24-35 (registration)List of all tool definitions including assetInfoTool, which is used to register the get_asset_info tool to 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/utils/assetUtils.ts:22-49 (helper)Supporting utility function that performs the actual API call to Bitpanda currencies endpoint, searches across asset types for the given symbol, and returns the matching asset object. This is the core logic invoked by the tool handler.export const findAssetBySymbol = async (symbol: string): Promise<BitpandaAsset> => { try { const currenciesResponse = await axios.get(`${BITPANDA_API_V3_BASE_URL}/currencies`); const currenciesData = currenciesResponse.data.data.attributes; const assetTypes = ['commodities', 'cryptocoins', 'etfs', 'etcs', 'fiat_earns']; let foundAsset: BitpandaAsset | null = null; for (const type of assetTypes) { if (currenciesData[type] && Array.isArray(currenciesData[type])) { foundAsset = currenciesData[type].find((asset: any) => asset.attributes?.symbol === symbol); if (foundAsset) { break; // Found the asset, stop searching } } } if (!foundAsset) { throw new Error(`Asset with symbol "${symbol}" not found.`); } return foundAsset; } catch (error: unknown) { console.error(`Error finding asset by symbol "${symbol}":`, error); const message = error instanceof Error ? error.message : 'An unknown error occurred while finding the asset.'; throw new Error(`Failed to find asset by symbol: ${message}`); } };