# Mcp Finance

> 全市场实时行情 MCP Server 让 AI 助手直接查询 A股/港股/美股/期货行情、计算技术指标、筛选股票、回测策略、生成 K 线图表

- **Type:** MCP server
- **Install:** `agentstack add mcp-ojkkk-mcp-finance`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [ojkkk](https://agentstack.voostack.com/s/ojkkk)
- **Installs:** 0
- **Category:** [Integrations](https://agentstack.voostack.com/c/integrations)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [ojkkk](https://github.com/ojkkk)
- **Source:** https://github.com/ojkkk/mcp-finance

## Install

```sh
agentstack add mcp-ojkkk-mcp-finance
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

---

## ⚡ 快速开始

```bash
pip install mcp-markets

# 方式一：作为 MCP Server 运行（供 Claude / Codex / Cursor 调用）
python -m mcp_finance.server

# 方式二：启动内置 Web Dashboard
mcp-dashboard              # 默认 http://localhost:8080
```

> Python 3.10+ · 零配置即可使用 · 可选设置 `TUSHARE_TOKEN` 环境变量启用高级财务数据

---

## ✨ 核心能力一览

| 模块 | 功能 | 亮点 |
|------|------|------|
| 📈 **实时行情** | A股/港股/美股/期货/指数 | easy-tdx 毫秒级，三源自动降级 |
| 📊 **K线数据** | 日/周/月/分钟 K线，前/后复权 | A股 800 条，港美股 yfinance 兜底 |
| 🔬 **技术指标** | MA·MACD·KDJ·RSI·BOLL·WR·BIAS | 金叉/死叉/超买超卖自动识别 |
| 🔍 **选股器** | 11 维条件筛选 + 五因子排名 | 动量·价值·质量·增长·波动 |
| 🧪 **策略回测** | 9 大策略 + 参数优化 | Backtrader 事件驱动，125× 性能提升 |
| 💼 **组合分析** | 多股对比 + 相关性矩阵 + 组合回测 | 支持等权/自定义权重 |
| 🏢 **基本面** | 财务指标 / 机构持仓 / 研报 / 龙虎榜 | AKShare + Tushare 双源 |
| 🖥️ **Web 看板** | Flask 实时行情 Dashboard | Plotly + ECharts 交互图表 |

---

## 🏗️ 四数据源架构

```mermaid
graph LR
    A["📡 数据源层"] --> B["⚡ easy-tdx通达信 TCP ·  C["🌐 AKShare新浪 / 同花顺 / 东方财富"]
    A --> D["🌍 yfinanceYahoo Finance 兜底"]
    A --> E["📈 Tushare深度财务 · Token 鉴权"]

    B --> F["🔧 31 MCP Tools"]
    C --> F
    D --> F
    E --> F

    F --> G["📈 行情实时价 / 批量 / K线"]
    F --> H["🔬 技术分析MA·MACD·KDJ·RSI·BOLL"]
    F --> I["📋 选股条件筛选 · 五因子排名"]
    F --> J["⚙️ 回测9 策略 · 贝叶斯优化"]
    F --> K["📊 组合多股对比 · 相关性 · Portfolio"]
    F --> L["🏢 基本面财务 · 研报 · 龙虎榜 · 大宗"]
    F --> M["🖥️ DashboardFlask Web · 实时刷新"]

    style A fill:#1e1b4b,stroke:#6366f1,color:#fff
    style F fill:#0f172a,stroke:#334155,color:#fff
    style G fill:#312e81,color:#fff
    style H fill:#312e81,color:#fff
    style I fill:#312e81,color:#fff
    style J fill:#312e81,color:#fff
    style K fill:#312e81,color:#fff
    style L fill:#312e81,color:#fff
    style M fill:#be185d,color:#fff
```

---

## 🎯 全部 31 个 MCP 工具

### 行情报价

| 工具 | 功能 | 数据源 | 延迟 |
|------|------|--------|------|
| `get_realtime_quote` | 单股实时行情（现价/涨跌幅/量比/换手率） | easy-tdx → AKShare → yfinance |  响应式布局 · Plotly / ECharts 交互图表 · 实时行情自动刷新

---

## 🔌 配置 MCP 客户端

Claude Desktop

```json
{
  "mcpServers": {
    "mcp-finance": {
      "command": "python",
      "args": ["-m", "mcp_finance.server"]
    }
  }
}
```

Codex

```bash
codex mcp add mcp-finance -- python -m mcp_finance.server
```

Cursor / VS Code

```json
{
  "mcpServers": {
    "mcp-finance": {
      "type": "stdio",
      "command": "python",
      "args": ["-m", "mcp_finance.server"]
    }
  }
}
```

> **可选：启用 Tushare 财务数据** — 设置环境变量 `TUSHARE_TOKEN=你的token`（注册 [tushare.pro](https://tushare.pro) 免费获取）。未设置时自动降级，不影响基础功能。

---

## 🧪 测试 & 开发

```bash
git clone https://github.com/ojkkk/mcp-finance.git
cd mcp-finance
pip install -e ".[dev]"

# 运行测试
pytest tests/ -v

# 代码检查
ruff check mcp_finance/
```

---

## 🌟 AI 对话示例

| 场景 | 自然语言提问 |
|------|------------|
| 行情 | "茅台现在什么价？" / "腾讯港股和苹果美股今天表现如何？" |
| 技术分析 | "茅台 MACD 金叉了吗？RSI 到什么位置了？" |
| 选股 | "找涨超 3%、量比>1.5、PE **本工具仅供学习交流，所有数据仅供参考，不构成任何投资建议。**

- 数据来源于第三方公开接口与网页爬虫，**不作准确性、完整性、及时性保证**
- **无自有数据源**，全部依赖 easy-tdx（通达信公开 TCP）/ AKShare（网页爬虫）/ yfinance / Tushare
- 数据**无合规商业授权**，个人非商用无问题，**企业商用存在版权与合规风险**
- 回测结果不代表未来表现，**历史收益不预示未来收益**
- **作者不对任何投资损失承担责任** · 投资有风险，入市需谨慎

---

## 📄 License

MIT © [mcp-finance](https://github.com/ojkkk/mcp-finance)

## Source & license

This open-source MCP server is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [ojkkk](https://github.com/ojkkk)
- **Source:** [ojkkk/mcp-finance](https://github.com/ojkkk/mcp-finance)
- **License:** MIT

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/mcp-ojkkk-mcp-finance
- Seller: https://agentstack.voostack.com/s/ojkkk
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
