cnnfag
This server provides access to CNN's Fear and Greed Index data.
Get the current index score (0-100) and its rating (e.g., fear, neutral, greed)
Retrieve the index values for the previous close, one week ago, one month ago, and one year ago
View the seven component indicators (market momentum, stock price strength, stock price breadth, put/call options, market volatility, junk bond demand, and safe haven demand), each with its own score and rating
Optionally include about a year of daily historical values for the index and each indicator
Useful for tracking market sentiment and informing investment decisions
Allows querying the CNN Fear & Greed Index, providing the current score and rating, past values, daily history, and component indicator breakdowns.
cnn-fear-and-greed-parse
Go package for CNN's Fear & Greed Index, a 0–100 gauge of US stock market sentiment. It returns the current score and rating, the values for the previous close, week, month and year, about a year of daily history, and the seven component indicators (market momentum, stock price strength, stock price breadth, put/call options, market volatility, junk bond demand, safe haven demand), each with its own score, rating and history of raw values. The module also ships a CLI and an MCP server, and has no dependencies outside the Go standard library.
Install
go get github.com/wildsurfer/cnn-fear-and-greed-parse/v2Related MCP server: Fear & Greed Index MCP Server
Usage
package main
import (
"context"
"fmt"
cnnfag "github.com/wildsurfer/cnn-fear-and-greed-parse/v2"
)
func main() {
result, err := cnnfag.Get(context.Background())
if err != nil {
panic(err)
}
fmt.Printf("Now: %.0f (%s)\n", result.Score, result.Rating)
fmt.Printf("One year ago: %.0f\n", result.OneYearAgo)
fmt.Printf("History: %d daily points since %s\n",
len(result.History), result.History[0].Date.Format("2006-01-02"))
fmt.Printf("VIX indicator: %.0f (%s)\n",
result.MarketVolatility.Score, result.MarketVolatility.Rating)
}Output:
Now: 64 (greed)
One year ago: 58
History: 250 daily points since 2025-08-11
VIX indicator: 50 (neutral)An Indicator's History holds the raw underlying series (the S&P 500 level for momentum, the VIX level for volatility, ratios and spreads for the rest), and its Score is CNN's 0–100 normalization. To use your own http.Client (timeout, proxy), replace cnnfag.HTTPClient.
CLI
For cron jobs and shell pipelines, without writing Go:
go install github.com/wildsurfer/cnn-fear-and-greed-parse/v2/cmd/cnnfag@latest$ cnnfag
64 (greed) as of 2026-08-11T00:00:00Z
previous close 64 · week ago 60 · month ago 47 · year ago 58
$ cnnfag -json | jq .score
64.3714285714286-json prints the full result, including the daily history. -timeout changes the request timeout (default 15s).
MCP server
cnnfag mcp runs a Model Context Protocol server over stdio, so AI assistants can query the index. It exposes one tool, get_fear_and_greed, with an optional include_history argument. Configuration for MCP clients:
{
"mcpServers": {
"cnnfag": {
"command": "cnnfag",
"args": ["mcp"]
}
}
}The client must be able to find the binary: use the full path (usually ~/go/bin/cnnfag) if your MCP client does not inherit your shell's PATH. Like the rest of the module, the server is built on the standard library only.
The server is also published to the MCP Registry as io.github.wildsurfer/cnnfag, with a container image at ghcr.io/wildsurfer/cnnfag for clients that prefer Docker over a local binary.
How it works
CNN does not offer a documented public API. This package requests the JSON endpoint that the Fear & Greed page itself uses:
https://production.dataviz.cnn.io/index/fearandgreed/graphdataThe endpoint rejects requests that do not look like they come from a browser, so the package sends browser-like User-Agent and Referer headers. This is the same data source used by the known wrappers in other languages.
A scheduled CI job runs the test suite against the real endpoint once a week, so a change on CNN's side is detected within days.
Migrating from v1
v2 is a full rewrite: CNN removed the HTML page that v1 parsed, so v1 stopped working and its data model no longer matches what CNN publishes. Update the import path first:
import cnnfag "github.com/wildsurfer/cnn-fear-and-greed-parse/v2"Then adjust the calls:
v1 | v2 |
|
|
|
|
|
|
|
|
| same field names, now plain |
| removed; CNN's API has no labels for past periods, but every |
|
|
| removed; the needle image no longer exists |
|
|
|
|
| removed with the image API |
— |
|
Scores changed from rounded integers to the exact floats CNN serves, so 44 in v1 corresponds to something like 43.71 in v2. Round with %.0f or math.Round if you need the old look.
Project history
v1 (2021) parsed the HTML of money.cnn.com/data/fear-and-greed with goquery and could also download the index needle image. CNN removed that page, which broke parsing, and the image no longer exists. v2 (2026) is a rewrite on the JSON endpoint with a smaller API, historical data and zero dependencies. The last v1 release is tagged v1.2.0.
Data disclaimer
This package is not affiliated with or endorsed by CNN. The Fear & Greed Index and its values belong to CNN (Warner Bros. Discovery). The MIT license covers only the code in this repository and gives you no rights to CNN's data. CNN's Terms of Use permit personal use of site content and restrict commercial exploitation. If you use this data in a product, compliance is your responsibility, and the endpoint can change or disappear at any time.
License
Available Tools
1 toolget_fear_and_greedA
CNN's Fear & Greed index for the US stock market: current score (0-100) and rating, values for the previous close, week, month and year, and the seven component indicators (market momentum, stock price strength and breadth, put/call options, volatility, junk bond and safe haven demand), each with its own score and rating.
| Name | Required | Description | Default |
|---|---|---|---|
| include_history | No | Include about a year of daily values for the index and each indicator. Off by default to keep the response small. |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Although no annotations are provided, the tool name 'get_fear_and_greed' and the description ('returns the index') make it evident that this is a read-only retrieval operation with no side effects. It does not mention any destructive actions, authentication needs, or rate limits, but none are expected for a simple getter.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is concise but informative, starting with the primary output (current score and rating) and then listing the additional data. It is well-structured and every sentence adds value without redundancy.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
The description gives a complete overview of the returned data, including the seven component indicators and their scores/ratings. While there is no output schema, the description is sufficiently detailed for an agent to know what to expect and how to use the result.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The schema covers the parameter completely, and the description adds meaningful detail beyond the schema by specifying 'about a year of daily values' and the default behavior ('Off by default'). This helps the agent understand the impact of setting the parameter.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states that the tool returns the CNN Fear & Greed index with current score, rating, historical values, and seven component indicators. It is specific and unambiguous, naming the exact resource and the data provided.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description explains the sole parameter `include_history`, stating that it adds about a year of daily values and is off by default. This gives clear guidance on when to set it, and there are no alternative tools to differentiate from.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
1 tool update
v2.2.0- First observed
get_fear_and_greed
TDQS
Scored across 1 tool
Only one tool exists, so there is no possibility of ambiguity or overlap.
The single tool name 'get_fear_and_greed' is clear, descriptive, and follows a standard verb_noun pattern.
A single-purpose server for retrieving the Fear & Greed index is well-scoped; one tool is appropriate and not excessive.
The tool covers the full scope of the domain—current score, historical values, and all component indicators—leaving no obvious gaps.
Maintenance
Related MCP Connectors
GuruFocus MCP — wraps the GuruFocus Data API (gurufocus.com/data-api)
News sentiment score trends for any topic over time. Free key at trendsapi.ai
Scrape stock quotes, historical prices, and financial statements from Yahoo Finance.
Related MCP Servers
- AlicenseBqualityFmaintenanceA mcp server that provides real-time and historical Crypto Fear & Greed Index data.352MIT
- AlicenseAqualityDmaintenanceA Model Context Protocol server that provides real-time CNN Fear & Greed Index data for the US stock market, including current sentiment scores and historical comparisons.139 npm4MIT
- FlicenseAqualityCmaintenanceExposes overseas and domestic macro/market statistics as MCP tools, including market sentiment and valuation indices like CNN Fear & Greed and KOSPI Buffett Index.4-
- AlicenseAqualityCmaintenanceProvides crypto market intelligence including price quotes, momentum analysis, trending coins, and a composite scored verdict, using the free CoinGecko API.4MIT