Skip to main content
Glama
ycjcl868

Fear & Greed Index MCP Server

get_fear_greed_index

Retrieve US stock market sentiment analysis with the Fear & Greed Index, including composite scores and seven individual indicators to assess market conditions.

Instructions

Get US stock market Fear & Greed Index data. Returns comprehensive market sentiment analysis including the main composite index and 7 individual indicators (market momentum, stock price strength/breadth, options sentiment, volatility, safe haven demand, junk bond demand). Each indicator includes score (0-100), rating, and timestamp. See schema for detailed field descriptions.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
dataYes

Implementation Reference

  • Handler function that calls fetchFearGreedData and returns the structured Fear & Greed Index data or error.
    async () => {
      try {
        const data = await fetchFearGreedData();
    
        return {
          isError: false,
          content: [
            {
              type: "text",
              text: JSON.stringify(data),
            },
          ],
          structuredContent: {
            data,
          },
        };
      } catch (error) {
        return {
          isError: true,
          content: [
            {
              type: "text",
              text: `Error fetching Fear and Greed Index: ${
                error instanceof Error ? error.message : String(error)
              }`,
            },
          ],
        };
      }
    }
  • src/server.ts:132-172 (registration)
    Registration of the 'get_fear_greed_index' tool with description, schemas, and handler.
    server.registerTool(
      "get_fear_greed_index",
      {
        description:
          "Get US stock market Fear & Greed Index data. Returns comprehensive market sentiment analysis including the main composite index and 7 individual indicators (market momentum, stock price strength/breadth, options sentiment, volatility, safe haven demand, junk bond demand). Each indicator includes score (0-100), rating, and timestamp. See schema for detailed field descriptions.",
        inputSchema: {},
        outputSchema: {
          data: fearGreedSchema,
        },
      },
      async () => {
        try {
          const data = await fetchFearGreedData();
    
          return {
            isError: false,
            content: [
              {
                type: "text",
                text: JSON.stringify(data),
              },
            ],
            structuredContent: {
              data,
            },
          };
        } catch (error) {
          return {
            isError: true,
            content: [
              {
                type: "text",
                text: `Error fetching Fear and Greed Index: ${
                  error instanceof Error ? error.message : String(error)
                }`,
              },
            ],
          };
        }
      }
    );
  • Zod schema defining the structure of the Fear & Greed Index data used in outputSchema.
    const fearGreedSchema = z.object({
      fear_and_greed: z
        .object({
          ...itemDataSchema,
          previous_close: z.number().describe("Previous day's closing score"),
          previous_1_week: z.number().describe("Score from 1 week ago"),
          previous_1_month: z.number().describe("Score from 1 month ago"),
          previous_1_year: z.number().describe("Score from 1 year ago"),
        })
        .describe("Main composite Fear & Greed Index with historical comparisons"),
      fear_and_greed_historical: z
        .object(itemDataSchema)
        .describe("Historical Fear & Greed Index data"),
      market_momentum_sp500: z
        .object(itemDataSchema)
        .describe(
          "S&P 500 momentum indicator - measures stock prices vs 125-day moving average"
        ),
      market_momentum_sp125: z
        .object(itemDataSchema)
        .describe("S&P 500 125-day moving average momentum"),
      stock_price_strength: z
        .object(itemDataSchema)
        .describe("Stock price strength - ratio of NYSE 52-week highs vs lows"),
      stock_price_breadth: z
        .object(itemDataSchema)
        .describe("Stock price breadth - McClellan Volume Summation Index"),
      put_call_options: z
        .object(itemDataSchema)
        .describe(
          "Put/Call options ratio - 5-day average (higher ratio indicates fear)"
        ),
      market_volatility_vix: z
        .object(itemDataSchema)
        .describe(
          "Market volatility - VIX fear index (higher values indicate fear)"
        ),
      market_volatility_vix_50: z
        .object(itemDataSchema)
        .describe("VIX 50-day moving average volatility"),
      junk_bond_demand: z
        .object(itemDataSchema)
        .describe(
          "Junk bond demand - yield spread between junk and investment-grade bonds"
        ),
      safe_haven_demand: z
        .object(itemDataSchema)
        .describe(
          "Safe haven demand - difference between 20-day stock and bond returns"
        ),
    });
  • Helper function that fetches raw data from CNN API, processes it, and validates with fearGreedSchema.
    async function fetchFearGreedData(): Promise<FearGreedData> {
      try {
        const userAgent = new UserAgent();
    
        const response = await fetch(
          "https://production.dataviz.cnn.io/index/fearandgreed/graphdata",
          {
            headers: {
              "User-Agent": userAgent.toString(),
              Accept: "application/json, text/plain, */*",
              "Accept-Language": "en-US,en;q=0.9",
              "Accept-Encoding": "gzip, deflate, br",
              Connection: "keep-alive",
              Referer: "https://www.cnn.com/",
              Origin: "https://www.cnn.com",
              "Cache-Control": "no-cache",
              Pragma: "no-cache",
            },
          }
        );
    
        if (!response.ok) {
          throw new Error(`HTTP error! status: ${response.status}`);
        }
    
        const responseData = await response.json();
        let result = {};
    
        Object.keys(responseData).forEach((k) => {
          const { data, ...rest } = responseData[k];
          result = {
            ...(result || {}),
            [k]: {
              ...rest,
              timestamp:
                typeof rest.timestamp === "number"
                  ? new Date(rest.timestamp).toISOString()
                  : rest.timestamp,
            },
          };
        });
        return fearGreedSchema.parse(result);
      } catch (error) {
        throw new Error(
          `Failed to fetch Fear and Greed data: ${
            error instanceof Error ? error.message : String(error)
          }`
        );
      }
    }
  • Base schema for individual Fear & Greed items, extended in fearGreedSchema.
    const itemDataSchema = {
      timestamp: z
        .string()
        .describe("ISO timestamp when the data was last updated"),
      score: z
        .number()
        .describe(
          "Fear & Greed score from 0-100 (0=extreme fear, 100=extreme greed)"
        ),
      rating: z
        .enum(["extreme fear", "fear", "neutral", "greed", "extreme greed"])
        .describe(
          "Textual rating based on the score: 0-25=extreme fear, 26-45=fear, 46-55=neutral, 56-75=greed, 76-100=extreme greed"
        ),
    };
Behavior4/5

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

With no annotations provided, the description carries the full burden. It effectively describes the tool's behavior: it returns comprehensive sentiment analysis with specific components (main index, 7 indicators), each with score, rating, and timestamp. It doesn't mention rate limits, authentication needs, or data freshness, but provides substantial behavioral context for a read-only operation.

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

Conciseness5/5

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

The description is well-structured and front-loaded with the core purpose, followed by detailed return value information. Every sentence adds value: the first states what it does, the second details the return structure, and the third directs to schema for field details. No wasted words.

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

Completeness5/5

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

Given the tool's complexity (returns multiple indicators with scores and ratings), the description provides complete context. It explains what the tool returns in detail, and since an output schema exists, it doesn't need to explain return values further. The combination of description and output schema coverage makes this fully adequate.

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 input schema has 0 parameters with 100% coverage, so the description doesn't need to compensate. The baseline for 0 parameters is 4, and the description appropriately focuses on output semantics rather than input parameters, which is correct given the tool's nature.

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

Purpose5/5

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

The description clearly states the tool's purpose with specific verb ('Get') and resource ('US stock market Fear & Greed Index data'). It distinguishes what it returns ('comprehensive market sentiment analysis including the main composite index and 7 individual indicators') and provides details about the indicators. No siblings exist, so differentiation isn't needed.

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

Usage Guidelines3/5

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

The description implies usage for obtaining market sentiment data but doesn't provide explicit guidance on when to use it versus alternatives. Since there are no sibling tools, there's no need for differentiation, but it lacks context about when this tool is appropriate versus other market analysis methods.

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/ycjcl868/mcp-server-fear-greed'

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