get_analyst_ratings
Retrieve analyst ratings and upgrades/downgrades for any stock to inform investment decisions and track market sentiment.
Instructions
Get analyst ratings and upgrades/downgrades for a stock
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| symbol | Yes | Stock ticker symbol |
Implementation Reference
- src/tools/analysis.ts:77-91 (handler)The handler for 'get_analyst_ratings' that fetches analyst ratings data from the FMP API using the '/grades' endpoint.
server.registerTool( 'get_analyst_ratings', { description: 'Get analyst ratings and upgrades/downgrades for a stock', inputSchema: SymbolOnlySchema, }, async (args: z.infer<typeof SymbolOnlySchema>) => { try { const data = await fetchFMP<AnalystRating[]>(`/grades?symbol=${args.symbol.toUpperCase()}`); return jsonResponse(data); } catch (error) { return errorResponse(error); } } ); - src/tools/analysis.ts:20-22 (schema)The input schema for 'get_analyst_ratings' defined using Zod.
const SymbolOnlySchema = z.object({ symbol: SymbolSchema.describe('Stock ticker symbol'), }); - src/tools/analysis.ts:37-132 (registration)The registration function for analyst tools, including 'get_analyst_ratings'.
export function registerAnalysisTools(server: any) { // Analyst Estimates server.registerTool( 'get_analyst_estimates', { description: 'Get analyst financial estimates for a stock (revenue, EPS forecasts)', inputSchema: AnalystEstimatesSchema, }, async (args: z.infer<typeof AnalystEstimatesSchema>) => { try { const period = args.period || 'annual'; const limit = args.limit || 10; const data = await fetchFMP<AnalystEstimate[]>( `/analyst-estimates?symbol=${args.symbol.toUpperCase()}&period=${period}&limit=${limit}` ); return jsonResponse(data); } catch (error) { return errorResponse(error); } } ); // Price Target server.registerTool( 'get_price_target', { description: 'Get analyst price target summary for a stock', inputSchema: SymbolOnlySchema, }, async (args: z.infer<typeof SymbolOnlySchema>) => { try { const data = await fetchFMP<PriceTarget[]>(`/price-target-summary?symbol=${args.symbol.toUpperCase()}`); return jsonResponse(data); } catch (error) { return errorResponse(error); } } ); // Analyst Ratings server.registerTool( 'get_analyst_ratings', { description: 'Get analyst ratings and upgrades/downgrades for a stock', inputSchema: SymbolOnlySchema, }, async (args: z.infer<typeof SymbolOnlySchema>) => { try { const data = await fetchFMP<AnalystRating[]>(`/grades?symbol=${args.symbol.toUpperCase()}`); return jsonResponse(data); } catch (error) { return errorResponse(error); } } ); // Insider Trading server.registerTool( 'get_insider_trading', { description: 'Get recent insider trading activity for a stock', inputSchema: InsiderTradingSchema, }, async (args: z.infer<typeof InsiderTradingSchema>) => { try { const limit = args.limit || 100; const data = await fetchFMP<InsiderTrading[]>( `/insider-trading/search?symbol=${args.symbol.toUpperCase()}&limit=${limit}` ); return jsonResponse(data); } catch (error) { return errorResponse(error); } } ); // Institutional Holders server.registerTool( 'get_institutional_holders', { description: 'Get institutional ownership (13F filings) for a stock', inputSchema: InstitutionalHoldersSchema, }, async (args: z.infer<typeof InstitutionalHoldersSchema>) => { try { const limit = args.limit || 100; const data = await fetchFMP<InstitutionalHolder[]>( `/institutional-ownership/latest?symbol=${args.symbol.toUpperCase()}&limit=${limit}` ); return jsonResponse(data); } catch (error) { return errorResponse(error); } } ); }