Metadata-Version: 2.4
Name: mcp-finance-news
Version: 0.1.1
Summary: 金融资讯 MCP Server — 市场脉搏/个股新闻/资金流向/22+垂直领域新闻, 数据源TianAPI+Tushare
Author: Finance News Team
License-Expression: MIT
License-File: LICENSE
Keywords: finance,mcp,news,northbound,stock,tianapi,tushare
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Office/Business :: Financial
Requires-Python: >=3.10
Requires-Dist: httpx>=0.27.0
Requires-Dist: mcp[cli]>=1.9.2
Provides-Extra: dev
Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
Requires-Dist: pytest>=8.0; extra == 'dev'
Description-Content-Type: text/markdown

# 📰 mcp-finance-news

**金融资讯 MCP Server** — 市场脉搏、个股新闻、北向资金流向、22+垂直领域新闻，一个 Server 全搞定。

合并自 2 个扣子技能：投资要闻追踪 / 新闻资讯。

数据源：[TianAPI](https://www.tianapi.com/)（22+分类新闻 + 财经要闻）+ [Tushare](https://tushare.pro/)（北向资金，可选）。

---

## 🛠 工具列表

| 工具 | 功能 | 典型场景 |
|------|------|---------|
| `market_pulse` | 市场脉搏：财经要闻 + 北向资金 | "今天市场有什么消息" "财经要闻" |
| `stock_news` | 个股动态：按股票代码/名称查新闻 | "茅台最近有什么新闻" "600519消息" |
| `fund_flow` | 资金流向：北向资金近N日净买入 | "北向资金最近5天流入多少" |
| `news_query` | 垂直领域新闻：22+分类精准查询 | "AI最近有什么新闻" "科技+财经" |

---

## 📦 安装

```bash
pip install mcp-finance-news
```

或从源码安装：

```bash
git clone https://github.com/yourname/mcp-finance-news.git
cd mcp-finance-news
pip install -e .
```

## ⚙️ 配置

### 必需

[TianAPI](https://www.tianapi.com/) API 密钥（免费注册即得）：

```bash
export TIANAPI_KEY="your_api_key_here"
```

### 可选

[Tushare Pro](https://tushare.pro/) Token（用于北向资金数据，2000积分起）：

```bash
export TUSHARE_TOKEN="your_tushare_token_here"
```

> 不设置 TUSHARE_TOKEN 时，`market_pulse` 仍可返回财经要闻（跳过北向资金），`fund_flow` 会提示需要 Token。

## 🚀 使用

### 命令行

```bash
# STDIO 模式 (默认)
mcp-finance-news

# 或
python -m mcp_finance_news
```

### MCP 客户端配置

在 Claude Desktop / Cherry Studio / ChatBox 等 MCP 客户端中添加：

```json
{
  "mcpServers": {
    "finance-news": {
      "command": "mcp-finance-news",
      "env": {
        "TIANAPI_KEY": "your_tianapi_key",
        "TUSHARE_TOKEN": "your_tushare_token"
      }
    }
  }
}
```

### 开发测试

```bash
# 安装 FastMCP CLI
pip install "mcp[cli]"

# 交互式测试
mcp dev src/mcp_finance_news/server.py
```

---

## 💡 工具详细说明

### market_pulse — 市场脉搏

```python
# 今日财经要闻
market_pulse()

# 过滤关键词
market_pulse(keyword="降息")

# 指定条数
market_pulse(num=20)
```

返回：财经新闻列表 + 北向资金最新5日数据（需TUSHARE_TOKEN）

### stock_news — 个股新闻

```python
# 按股票代码
stock_news(symbol="600519")

# 按股票名称
stock_news(symbol="比亚迪")
```

返回：该股票相关新闻列表

### fund_flow — 北向资金流向

```python
# 最近5日
fund_flow()

# 最近10日
fund_flow(days=10)
```

返回：近N个交易日沪股通/深股通/北向/南向资金净买入（百万元），含趋势判断

### news_query — 垂直领域新闻

```python
# 单分类
news_query(category="AI")

# 多分类组合
news_query(category="AI,科技,财经")

# 带关键词
news_query(category="财经", keyword="降息")

# 指定条数
news_query(category="体育", num=20)
```

**支持的分类**：AI、财经、科技、IT、互联网、游戏、动漫、影视、体育、NBA、足球、CBA、健康、旅游、汽车、环保、军事、科学探索、VR、社会、国内、国际、娱乐、电竞、女性、综合

---

## 📋 环境变量

| 变量 | 必需 | 说明 |
|------|------|------|
| `TIANAPI_KEY` | ✅ | 天聚数行API密钥，新闻查询必需 |
| `TUSHARE_TOKEN` | ❌ | Tushare Pro Token，北向资金查询需要(2000积分起) |

---

## 📄 License

MIT
