Skip to main content
Glama
imbenrabi

Financial Modeling Prep MCP Server

getMarketRiskPremium

Read-onlyIdempotent

Retrieve the market risk premium for any date to calculate the additional expected return from stock market investments over risk-free assets, aiding investment decisions.

Instructions

Access the market risk premium for specific dates with the FMP Market Risk Premium API. Use this key financial metric to assess the additional return expected from investing in the stock market over a risk-free investment.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • MCP tool registration and handler for 'getMarketRiskPremium'. Registers the tool with no input schema, calls economicsClient.getMarketRiskPremium(), and returns the results as JSON.
    server.tool(
      "getMarketRiskPremium",
      "Access the market risk premium for specific dates with the FMP Market Risk Premium API. Use this key financial metric to assess the additional return expected from investing in the stock market over a risk-free investment.",
      {},
      async () => {
        try {
          const results = await economicsClient.getMarketRiskPremium();
          return {
            content: [{ type: "text", text: JSON.stringify(results, null, 2) }],
          };
        } catch (error) {
          return {
            content: [
              {
                type: "text",
                text: `Error: ${
                  error instanceof Error ? error.message : String(error)
                }`,
              },
            ],
            isError: true,
          };
        }
      }
    );
  • EconomicsClient.getMarketRiskPremium() method that calls the FMP API endpoint '/market-risk-premium' via the base FMPClient.get<T>() method.
    async getMarketRiskPremium(
      options?: {
        signal?: AbortSignal;
        context?: FMPContext;
      }
    ): Promise<MarketRiskPremium[]> {
      return super.get<MarketRiskPremium[]>(
        "/market-risk-premium", 
        {},
        options
      );
    }
  • MarketRiskPremium interface defining the return type: country, continent, countryRiskPremium, and totalEquityRiskPremium.
    export interface MarketRiskPremium {
      country: string;
      continent: string;
      countryRiskPremium: number;
      totalEquityRiskPremium: number;
    }
  • registerEconomicsTools function which registers the 'getMarketRiskPremium' tool (and others) on the MCP server.
    export function registerEconomicsTools(
      server: McpServer,
      accessToken?: string
    ): void {
  • FMPClient.get<T>() base method that handles HTTP GET requests, API key injection from context/instance/env, abort signals, and error handling for all API clients.
    protected async get<T>(
      endpoint: string,
      params: Record<string, any> = {},
      options?: {
        signal?: AbortSignal;
        context?: { config?: { FMP_ACCESS_TOKEN?: string } };
      }
    ): Promise<T> {
      try {
        // Try to get API key from context first, fall back to instance API key
        const apiKey = this.getApiKey(options?.context);
    
        const config: AxiosRequestConfig = {
          params: {
            ...params,
            apikey: apiKey,
          },
        };
    
        if (options?.signal) {
          config.signal = options.signal;
        }
    
        const response = await this.client.get<T>(endpoint, config);
        return response.data;
      } catch (error: unknown) {
        if (axios.isAxiosError(error)) {
          const axiosError = error as AxiosError<FMPErrorResponse>;
          throw new Error(
            `FMP API Error: ${
              axiosError.response?.data?.message || axiosError.message
            }`, { cause: error }
          );
        }
        throw new Error(
          `Unexpected error: ${
            error instanceof Error ? error.message : String(error)
          }`, { cause: error }
        );
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnlyHint=true, idempotentHint=true, and openWorldHint=true. The description adds minimal behavioral context beyond 'access' and does not disclose data freshness, rate limits, or potential result variations. With annotations covering safety, the description fails to add significant value.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description consists of two concise sentences that convey the tool's purpose and use case without extraneous information. It is well-structured and front-loaded.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The description mentions 'specific dates' but the input schema has no parameters to specify dates, creating confusion. Additionally, there is no output schema, and the description does not explain what the tool returns or how the market risk premium is presented (e.g., a single value, series, etc.). This completeness gap is significant given the contradiction between description and schema.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool has no parameters, and the schema coverage is 100% (empty). Per the calibration guide, 0 parameters scores a baseline of 4. The description does not need to add parameter info since none exist.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool accesses the market risk premium for specific dates using the FMP API. It provides context on the metric's financial relevance. While the name itself is descriptive, the description reinforces the purpose without explicitly differentiating from siblings, but the unique metric name suffices.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description mentions 'use this key financial metric to assess additional return expected,' but it does not provide guidance on when to use this tool versus alternatives, nor does it indicate when not to use it. There is no exclusion criteria or comparison with sibling tools.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/imbenrabi/Financial-Modeling-Prep-MCP-Server'

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