get_ticker_price
Fetch real-time stock prices using a ticker symbol with this tool, enabling quick access to up-to-date market data for informed decision-making.
Instructions
Get current price for a stock ticker
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| symbol | Yes | Stock ticker symbol |
Implementation Reference
- src/index.ts:150-174 (handler)The main handler function for the 'get_ticker_price' tool. It makes an API call to Alpha Vantage for intraday time series data and extracts the latest open price.private async handleGetTickerPrice(args: any) { const response = await this.axiosInstance.get('', { params: { function: 'TIME_SERIES_INTRADAY', symbol: args.symbol, interval: '1min', outputsize: 'compact' } }); const latestData = response.data['Time Series (1min)']; const latestTimestamp = Object.keys(latestData)[0]; const price = latestData[latestTimestamp]['1. open']; return { content: [{ type: 'text', text: JSON.stringify({ symbol: args.symbol, price: price, timestamp: latestTimestamp }, null, 2) }] }; }
- src/index.ts:56-65 (schema)Input schema definition for the 'get_ticker_price' tool, specifying a required 'symbol' string parameter.inputSchema: { type: 'object', properties: { symbol: { type: 'string', description: 'Stock ticker symbol' } }, required: ['symbol'] }
- src/index.ts:53-66 (registration)Tool registration in the ListTools response, including name, description, and schema.{ name: 'get_ticker_price', description: 'Get current price for a stock ticker', inputSchema: { type: 'object', properties: { symbol: { type: 'string', description: 'Stock ticker symbol' } }, required: ['symbol'] } },
- src/index.ts:114-115 (registration)Dispatch case in the CallToolRequestHandler that routes to the specific handler.case 'get_ticker_price': return await this.handleGetTickerPrice(request.params.arguments);