Skip to main content
Glama

finance_stock_price

Retrieve current stock prices for any ticker symbol using a public API. Enter a symbol like AAPL or MSFT to get real-time market data.

Instructions

Get current stock price from public API

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
symbolYesStock ticker symbol (e.g. AAPL, MSFT, GOOGL)

Implementation Reference

  • The handler implementation for finance_stock_price tool, which fetches data from the Yahoo Finance API.
    server.tool("finance_stock_price", "Get current stock price from public API", {
      symbol: z.string().describe("Stock ticker symbol (e.g. AAPL, MSFT, GOOGL)")
    }, async ({ symbol }) => {
      try {
        const data = await safeFetch(`https://query1.finance.yahoo.com/v8/finance/chart/${symbol.toUpperCase()}?range=1d&interval=1m`);
        const meta = data.chart.result[0].meta;
        const change = ((meta.regularMarketPrice - meta.previousClose) / meta.previousClose) * 100;
        return { content: [{ type: "text", text: `**${symbol.toUpperCase()}**\nPrice: ${formatCurrency(meta.regularMarketPrice)}\nPrev Close: ${formatCurrency(meta.previousClose)}\nChange: ${formatPercent(change)}\nVolume: ${meta.regularMarketVolume?.toLocaleString() || "N/A"}\nExchange: ${meta.exchangeName}` }] };
      } catch {
        return { content: [{ type: "text", text: `Could not fetch ${symbol}. Try common tickers: AAPL, MSFT, GOOGL, AMZN, TSLA, NVDA` }] };
      }
    });

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/ElromEvedElElyon/claw-mcp-toolkit'

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