🚀 MCP Server恐懼與貪婪指數
這是一個基於模型上下文協議(MCP)的服務器,可提供美國股市的CNN恐懼與貪婪指數。該服務器能夠獲取實時市場情緒數據,並以structuredContent和文本content兩種形式呈現。



✨ 主要特性
- 實時恐懼與貪婪指數:獲取當前市場情緒得分(0 - 100)。
- 歷史數據對比:查看前一交易日、上週、上月和去年的數據。
- 詳細市場指標:訪問各個組成部分的得分,包括:
- 市場動量(標準普爾500指數和標準普爾125指數)
- 股票價格強度與廣度
- 看跌/看漲期權比率
- 市場波動率(VIX)
- 垃圾債券需求
- 避險資產需求
- 靈活輸出格式:可選擇結構化的Markdown格式或原始JSON格式。
📦 安裝指南
環境要求
- Node.js 18 或更高版本
- VS Code、Cursor、Windsurf、Claude Desktop 或其他 MCP 客戶端
本地安裝(標準輸入輸出)
首先,使用客戶端安裝恐懼與貪婪MCP服務器。典型的配置如下:
{
"mcpServers": {
"mcp-server-fear-greed": {
"command": "npx",
"args": [
"-y",
"mcp-server-fear-greed@latest"
]
}
}
}
在VS Code中安裝
你也可以使用VS Code命令行界面安裝mcp-server-fear-greed MCP服務器:
code --add-mcp '{"name":"mcp-server-fear-greed","command":"npx","args":["mcp-server-fear-greed@latest"]}'
安裝完成後,恐懼與貪婪MCP服務器即可在VS Code中與GitHub Copilot代理一起使用。
在Cursor中安裝
前往Cursor設置 -> MCP -> 添加新的MCP服務器。自定義名稱,輸入npx mcp-server-fear-greed。你還可以通過點擊編輯來驗證配置或添加命令參數。
{
"mcpServers": {
"mcp-server-fear-greed": {
"command": "npx",
"args": [
"mcp-server-fear-greed@latest"
]
}
}
}
在Windsurf中安裝
遵循Windsurf MCP 文檔。使用以下配置:
{
"mcpServers": {
"mcp-server-fear-greed": {
"command": "npx",
"args": [
"mcp-server-fear-greed@latest"
]
}
}
}
在Claude Desktop中安裝
遵循MCP安裝 指南,使用以下配置:
{
"mcpServers": {
"mcp-server-fear-greed": {
"command": "npx",
"args": [
"mcp-server-fear-greed@latest"
]
}
}
}
遠程安裝(SSE / 可流式HTTP)
同時,使用--port $your_port參數啟動瀏覽器MCP,可將其轉換為SSE和可流式HTTP服務器。
npx mcp-server-fear-greed --port 8089
你可以使用以下兩個MCP服務器遠程端點之一:
- 可流式HTTP(推薦):
http://127.0.0.1::8089/mcp
- SSE:
http://127.0.0.1::8089/sse
然後在MCP客戶端配置中,將url設置為SSE端點:
{
"mcpServers": {
"mcp-server-fear-greed": {
"url": "http://127.0.0.1::8089/sse"
}
}
}
將url設置為可流式HTTP端點:
{
"mcpServers": {
"mcp-server-fear-greed": {
"type": "streamable-http",
"url": "http://127.0.0.1::8089/mcp"
}
}
}
內存調用
如果你的MCP客戶端是基於JavaScript / TypeScript開發的,你可以直接使用進程內調用,避免要求用戶安裝命令行界面來使用恐懼與貪婪MCP。
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
import { InMemoryTransport } from '@modelcontextprotocol/sdk/inMemory.js';
import { createServer } from 'mcp-server-fear-greed';
const client = new Client(
{
name: 'test fear greed client',
version: '1.0',
},
{
capabilities: {},
},
);
const server = createServer();
const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();
await Promise.all([
client.connect(clientTransport),
server.connect(serverTransport),
]);
const result = await client.listTools();
console.log(result);
const toolResult = await client.callTool({
name: 'get_fear_greed_index',
arguments: {
format: 'json'
},
});
console.log(toolResult);
📚 詳細文檔
工具:get_fear_greed_index
獲取當前的恐懼與貪婪指數及相關市場指標。
參數
format(可選):輸出格式
"structured"(默認):返回格式化的Markdown數據
"json":返回原始JSON數據
使用示例
await client.callTool("get_fear_greed_index");
await client.callTool("get_fear_greed_index", { format: "json" });
響應結構
該工具返回的數據結構如下:
{
"fear_and_greed": {
"score": 75,
"rating": "greed",
"timestamp": "2025-07-18T23:59:57+00:00",
"previous_close": 75.31,
"previous_1_week": 75.26,
"previous_1_month": 54.29,
"previous_1_year": 45.94
},
"fear_and_greed_historical": {
"timestamp": 1752883197000,
"score": 75,
"rating": "greed"
},
"market_momentum_sp500": {
"timestamp": 1752871567000,
"score": 61.2,
"rating": "greed"
},
"market_momentum_sp125": {
"timestamp": 1752871567000,
"score": 61.2,
"rating": "greed"
},
"stock_price_strength": {
"timestamp": 1752883197000,
"score": 80,
"rating": "extreme greed"
},
"stock_price_breadth": {
"timestamp": 1752883197000,
"score": 84,
"rating": "extreme greed"
},
"put_call_options": {
"timestamp": 1752871897000,
"score": 79.6,
"rating": "extreme greed"
},
"market_volatility_vix": {
"timestamp": 1752869701000,
"score": 50,
"rating": "neutral"
},
"market_volatility_vix_50": {
"timestamp": 1752869701000,
"score": 50,
"rating": "neutral"
},
"junk_bond_demand": {
"timestamp": 1752877800000,
"score": 88.8,
"rating": "extreme greed"
},
"safe_haven_demand": {
"timestamp": 1752868799000,
"score": 81.4,
"rating": "extreme greed"
}
}
恐懼與貪婪指數評級
該指數使用以下評級標準:
- 0 - 25:極度恐懼
- 26 - 45:恐懼
- 46 - 55:中性
- 56 - 75:貪婪
- 76 - 100:極度貪婪
開發
訪問 http://127.0.0.1:6274/:
npm run dev
錯誤處理
服務器包含全面的錯誤處理機制:
- 捕獲並報告網絡請求失敗情況。
- 優雅處理無效的API響應。
- 用合理的默認值填充缺失的數據字段。
- 所有錯誤均包含詳細的描述信息。