Skip to main content
Glama
jackdark425

Financial Modeling Prep (FMP) MCP Server

by jackdark425

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
NameRequiredDescriptionDefault
symbolYesStock ticker symbol

Implementation Reference

  • 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);
        }
      }
    );
  • The input schema for 'get_analyst_ratings' defined using Zod.
    const SymbolOnlySchema = z.object({
      symbol: SymbolSchema.describe('Stock ticker symbol'),
    });
  • 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);
          }
        }
      );
    }

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/jackdark425/aigroup-fmp-mcp'

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