Skip to main content
Glama
financial-datasets

Financial Datasets MCP Server

Official

get_historical_crypto_prices

Retrieve historical cryptocurrency prices by specifying ticker, date range, and interval. Use this tool to analyze and track crypto market trends over time.

Instructions

Gets historical prices for a crypto currency.

Args: ticker: Ticker symbol of the crypto currency (e.g. BTC-USD). The list of available crypto tickers can be retrieved via the get_available_crypto_tickers tool. start_date: Start date of the price data (e.g. 2020-01-01) end_date: End date of the price data (e.g. 2020-12-31) interval: Interval of the price data (e.g. minute, hour, day, week, month) interval_multiplier: Multiplier of the interval (e.g. 1, 2, 3)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
end_dateYes
intervalNoday
interval_multiplierNo
start_dateYes
tickerYes

Implementation Reference

  • The main handler function for the 'get_historical_crypto_prices' tool, registered via @mcp.tool(). It fetches historical cryptocurrency prices from the Financial Datasets API using the provided parameters, handles errors, and returns the data as formatted JSON.
    @mcp.tool() async def get_historical_crypto_prices( ticker: str, start_date: str, end_date: str, interval: str = "day", interval_multiplier: int = 1, ) -> str: """Gets historical prices for a crypto currency. Args: ticker: Ticker symbol of the crypto currency (e.g. BTC-USD). The list of available crypto tickers can be retrieved via the get_available_crypto_tickers tool. start_date: Start date of the price data (e.g. 2020-01-01) end_date: End date of the price data (e.g. 2020-12-31) interval: Interval of the price data (e.g. minute, hour, day, week, month) interval_multiplier: Multiplier of the interval (e.g. 1, 2, 3) """ # Fetch data from the API url = f"{FINANCIAL_DATASETS_API_BASE}/crypto/prices/?ticker={ticker}&interval={interval}&interval_multiplier={interval_multiplier}&start_date={start_date}&end_date={end_date}" data = await make_request(url) # Check if data is found if not data: return "Unable to fetch prices or no prices found." # Extract the prices prices = data.get("prices", []) # Check if prices are found if not prices: return "Unable to fetch prices or no prices found." # Stringify the prices return json.dumps(prices, indent=2)
  • Shared helper utility function that makes HTTP GET requests to the Financial Datasets API, handles authentication via API key from environment, and returns JSON data or error dictionary.
    async def make_request(url: str) -> dict[str, any] | None: """Make a request to the Financial Datasets API with proper error handling.""" # Load environment variables from .env file load_dotenv() headers = {} if api_key := os.environ.get("FINANCIAL_DATASETS_API_KEY"): headers["X-API-KEY"] = api_key async with httpx.AsyncClient() as client: try: response = await client.get(url, headers=headers, timeout=30.0) response.raise_for_status() return response.json() except Exception as e: return {"Error": str(e)}

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/financial-datasets/mcp-server'

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