金融数据服务

一个提供股票市场数据、新闻、金融信息等全面金融数据的MCP服务器。

  • by AgentX-ai
  • Python
  • 本地部署
  • 53 星标
  • 更新于
在 GitHub 查看 AgentX-ai/yahoo-finance-server

使用说明

雅虎金融MCP服务器

📈 一个模型上下文协议(MCP)服务器,让你的人工智能与雅虎财经进行交互 -获取全面的股市数据、新闻、财务等。

✨ 特性

  • 📊 股票数据 -获取全面的股票信息,包括公司详细信息、财务和交易指标
  • 📰 消息流 -获取与特定股票代码相关的最新新闻文章
  • 🔍 搜索 -查找有新闻结果的股票、ETF和其他金融工具
  • 🏆 顶级实体 -按行业获取表现最佳的公司、ETF和共同基金
  • 📈 价格历史记录 -获取具有可自定义时段和间隔的历史价格数据
  • ⚡ 期权链 -获取股票的期权链数据,包括看涨期权和看跌期权
  • 💰 收益 -访问收益数据,包括即将到来的收益日期
  • 🌐 代理支持 -适用于HTTP/HTTPS/SOCKS代理
  • 🚀 快速异步 -使用asyncio的非阻塞操作
  • 🔧 轻松集成 -AI助手的标准MCP协议

🚀 快速开始

先决条件

  • Python 3.11或更高版本
  • pip或uvx包管理器
  • (可选)代理服务器,提高可靠性

安装

使用uvx(推荐)

# Install with namespace
uvx yahoo-finance-server

使用pip

pip install yahoo-finance-server

来源

git clone https://github.com/AgentX-ai/AgentX-mcp-servers.git
cd AgentX-mcp-servers/yahoo_finance_server
pip install -e .

配置

代理设置(推荐)

为了提高可靠性并避免速率限制,请设置代理:

# HTTP/HTTPS proxy
export PROXY_URL="http://proxy.example.com:8080"

# SOCKS proxy with auth
export PROXY_URL="socks5://user:pass@127.0.0.1:1080/"

运行服务器

# Basic run (stdio transport)
yahoo-finance-server

# Run with proxy
PROXY_URL="http://127.0.0.1:7890" yahoo-finance-server

# Run with HTTP transport
yahoo-finance-server --transport http --host localhost --port 3000

# Run with HTTP transport and proxy
PROXY_URL="http://127.0.0.1:7890" yahoo-finance-server --transport http --host 0.0.0.0 --port 8080
运输选项

标准传输(默认)

  • 最适合开发和AI助手集成
  • 通过stdin/stdout管道进行通信
  • 用途: yahoo-finance-server 或 yahoo-finance-server --transport stdio

HTTP传输

  • StreamableHttp传输(取代弃用的SSE)
  • 允许基于web的连接和远程访问
  • 用途: yahoo-finance-server --transport http --host localhost --port 3000
  • 检查器URL: http://localhost:3000

🛠️ api参考

可用工具

1. 获取股票信息

获取全面的股票信息,包括公司详细信息、财务和交易指标。

{
  "name": "get-ticker-info",
  "arguments": {
    "symbol": "AAPL"
  }
}

2. 获取股票行情新闻

获取股票代码的最新新闻文章。

{
  "name": "get-ticker-news",
  "arguments": {
    "symbol": "AAPL",
    "count": 10
  }
}

3. 搜索

搜索股票、ETF和其他金融工具的相关新闻。

{
  "name": "search",
  "arguments": {
    "query": "Apple Inc",
    "count": 10
  }
}

4. 获取顶级实体

获得行业中表现最佳的实体。

{
  "name": "get-top-entities",
  "arguments": {
    "entity_type": "companies", // Options: "etfs", "mutual_funds", "companies", "growth_companies", "performing_companies"
    "sector": "technology", // See supported sectors below
    "count": 10
  }
}

支持的行业:

  • 基本材料
  • 通信服务
  • 消费者周期性
  • 消费者防御
  • 能量
  • 金融服务
  • 医疗保健
  • 工业股
  • 不动产
  • 技术
  • 公用事业

5. 获取价格历史记录

获取具有可自定义时段和间隔的历史价格数据。

{
  "name": "get-price-history",
  "arguments": {
    "symbol": "AAPL",
    "period": "1y", // Options: 1d, 5d, 1mo, 3mo, 6mo, 1y, 2y, 5y, 10y, ytd, max
    "interval": "1d" // Options: 1m, 2m, 5m, 15m, 30m, 60m, 90m, 1h, 1d, 5d, 1wk, 1mo, 3mo
  }
}

6. 股票期权链

获取股票的期权链数据。

{
  "name": "ticker-option-chain",
  "arguments": {
    "symbol": "AAPL",
    "option_type": "call", // Options: "call", "put", "both"
    "date": "2024-01-19" // Optional: YYYY-MM-DD format
  }
}

7. 股票收益

获取收益数据,包括历史和即将到来的收益。

{
  "name": "ticker-earning",
  "arguments": {
    "symbol": "AAPL",
    "period": "annual", // Options: "annual", "quarterly"
    "date": "2023-12-31" // Optional: YYYY-MM-DD format
  }
}

🧪 测试

使用MCP检查器

使用标准传输(默认)

npx @modelcontextprotocol/inspector yahoo-finance-server

使用HTTP传输

# Terminal 1: Start server with HTTP transport
yahoo-finance-server --transport http --host localhost --port 3000

# Terminal 2: Connect inspector to HTTP server
npx @modelcontextprotocol/inspector http://localhost:3000

手动测试

python -c "
import asyncio
from yahoo_finance_server.helper import get_ticker_info

async def test():
    info = await get_ticker_info('AAPL')
    print(f'✅ Stock: {info[\"longName\"]}')

asyncio.run(test())
"

📋 需求

  • Python 3.11+
  • 融资==0.2.62
  • 请求>=2.31.0
  • 熊猫>=2.0.0
  • mcp>=1.9.3

🤝 贡献

  1. 分叉存储库
  2. 创建要素分支
  3. 进行更改
  4. 添加测试
  5. 提交拉取请求

📄 许可证

MIT许可证-请参阅 许可证 文件以获取详细信息。

🔗 链接


制作❤️ 金融界