Skip to main content
Glama
matteoantoci

MCP Bitpanda Server

get_asset_info

Retrieve detailed information for cryptocurrency assets using their trading symbols like BTC or XAU. Access asset data through the Bitpanda exchange programmatically.

Instructions

Retrieves detailed information for a specific asset by its symbol.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
symbolYesThe trading symbol of the asset (e.g., BTC, XAU)

Implementation Reference

  • The main handler function for the 'get_asset_info' tool. It takes the input symbol, calls findAssetBySymbol utility, and returns the asset info or throws an error.
    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}`);
      }
    };
  • Zod input schema shape 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;
    };
  • The registration function that registers all tools, including get_asset_info (imported and added to bitpandaToolDefinitions array at lines 10 and 32), 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);
        }
      });
  • Supporting utility function findAssetBySymbol that queries the Bitpanda API currencies endpoint to find and return asset info by symbol. Called directly by the get_asset_info 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}`);
      }
    };

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/matteoantoci/mcp-bitpanda'

If you have feedback or need assistance with the MCP directory API, please join our Discord server