Skip to main content
Glama
kukapay

crypto-stocks-mcp

get_stock_price

Retrieve real-time stock prices for crypto-related companies by entering a ticker symbol. Returns current price, company name, and timestamp in a formatted table.

Instructions

Get real-time price for a specific stock in a table format.

Args: ticker (str): The stock ticker symbol (e.g., 'COIN' for Coinbase). Returns: str: An ASCII table string containing the ticker, company name, current price, and timestamp. Returns an error message if the ticker is invalid.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tickerYes

Implementation Reference

  • main.py:51-73 (handler)
    The handler function for the 'get_stock_price' tool. It checks if the ticker is valid using CRYPTO_STOCKS, fetches the current price using yfinance.Ticker, and formats the result as an ASCII table with ticker, name, price, and timestamp.
    def get_stock_price(ticker: str) -> str: """Get real-time price for a specific stock in a table format. Args: ticker (str): The stock ticker symbol (e.g., 'COIN' for Coinbase). Returns: str: An ASCII table string containing the ticker, company name, current price, and timestamp. 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) price = stock.info.get("regularMarketPrice", "N/A") table_data = [[ticker, CRYPTO_STOCKS[ticker], price, datetime.now().isoformat()]] return tabulate( table_data, headers=["Ticker", "Name", "Price", "Timestamp"], tablefmt="grid", stralign="left", floatfmt=".2f" )
  • main.py:10-27 (helper)
    Dictionary of supported crypto-related stock tickers and their full names, used by get_stock_price to validate tickers 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" }
  • main.py:51-51 (registration)
    The @mcp.tool() decorator registers the get_stock_price function as an MCP tool.
    def get_stock_price(ticker: str) -> str:
  • main.py:52-60 (schema)
    Type hints and docstring defining the input schema (ticker: str) and output (str table or error).
    """Get real-time price for a specific stock in a table format. Args: ticker (str): The stock ticker symbol (e.g., 'COIN' for Coinbase). Returns: str: An ASCII table string containing the ticker, company name, current price, and timestamp. Returns an error message if the ticker is invalid. """

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