get_stock_price
Retrieve real-time stock price data by inputting the stock symbol, enabling immediate access to market information through Alpha Vantage's financial API integration.
Instructions
Get real-time stock price information
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| symbol | Yes | The stock symbol (e.g., AAPL) |
Implementation Reference
- src/index.ts:219-234 (handler)The main handler function that executes the get_stock_price tool logic by querying the Alpha Vantage GLOBAL_QUOTE API endpoint and returning the response as formatted JSON text.private async getStockPrice(args: any) { const response = await this.axiosInstance.get('', { params: { function: 'GLOBAL_QUOTE', symbol: args.symbol, }, }); return { content: [ { type: 'text', text: JSON.stringify(response.data, null, 2), }, ], }; }
- src/index.ts:96-105 (schema)Input schema definition for the get_stock_price tool, specifying an object with a required 'symbol' string property.inputSchema: { type: 'object', properties: { symbol: { type: 'string', description: 'The stock symbol (e.g., AAPL)', }, }, required: ['symbol'], },
- src/index.ts:93-106 (registration)Registration of the get_stock_price tool in the ListToolsRequestHandler, providing name, description, and input schema.{ name: 'get_stock_price', description: 'Get real-time stock price information', inputSchema: { type: 'object', properties: { symbol: { type: 'string', description: 'The stock symbol (e.g., AAPL)', }, }, required: ['symbol'], }, },
- src/index.ts:53-54 (registration)Routing logic in the CallToolRequestHandler switch statement that dispatches to the getStockPrice handler.case 'get_stock_price': return await this.getStockPrice(request.params.arguments);