Skip to main content
Glama
kukapay

crypto-stocks-mcp

get_historical_prices

Fetch historical stock price data for crypto-related stocks in a table format, including date, closing price, and volume, over a specified number of days.

Instructions

Fetch historical stock prices for the given ticker over the specified number of days in a table format.

Args: ticker (str): The stock ticker symbol (e.g., 'COIN' for Coinbase). days (int, optional): Number of days for historical data (default: 30). Returns: str: An ASCII table string containing the date, closing price, and volume for the specified stock. Returns an error message if the ticker is invalid.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
daysNo
tickerYes

Implementation Reference

  • main.py:77-107 (handler)
    The handler function that implements the logic for fetching historical stock prices using yfinance, validating the ticker against CRYPTO_STOCKS, and formatting the data into an ASCII table using tabulate.
    def get_historical_prices(ticker: str, days: int = 30) -> str: """Fetch historical stock prices for the given ticker over the specified number of days in a table format. Args: ticker (str): The stock ticker symbol (e.g., 'COIN' for Coinbase). days (int, optional): Number of days for historical data (default: 30). Returns: str: An ASCII table string containing the date, closing price, and volume for the specified stock. Returns an error message if the ticker is invalid. """ if ticker not in CRYPTO_STOCKS: return f"Error: Unknown ticker {ticker}" stock = yf.Ticker(ticker) end_date = datetime.now() start_date = end_date - timedelta(days=days) hist = stock.history(start=start_date, end=end_date) # Format historical data as a table table_data = [ [index.strftime("%Y-%m-%d"), row["Close"], row["Volume"]] for index, row in hist.iterrows() ] return tabulate( table_data, headers=["Date", "Close", "Volume"], tablefmt="grid", stralign="left", floatfmt=".2f" )
  • main.py:76-76 (registration)
    The @mcp.tool() decorator registers the get_historical_prices function as an MCP tool.
    @mcp.tool()
  • main.py:10-27 (helper)
    The CRYPTO_STOCKS dictionary used by get_historical_prices to validate ticker symbols and provide company names.
    CRYPTO_STOCKS = { "BMNR": "BitMine Immersion Technologies, Inc.", "CRCL": "Circle Internet Group Inc.", "SBET": "SharpLink Gaming Inc.", "SRM": "Tron Inc.", "DFDV": "DeFi Development Corp.", "MSTR": "MicroStrategy Incorporated", "COIN": "Coinbase Global Inc.", "MARA": "Marathon Digital Holdings", "RIOT": "Riot Platforms Inc.", "HIVE": "HIVE Digital Technologies", "CORZ": "Core Scientific Inc.", "IREN": "Iris Energy Limited", "CLSK": "CleanSpark Inc.", "HUT": "Hut 8 Corp", "CIFR": "Cipher Mining Inc.", "BITF": "Bitfarms Ltd" }

Other Tools

Related Tools

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/kukapay/crypto-stocks-mcp'

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