Skip to main content

一个获取实时股票数据服务和分析的MCP服务器

Project description

实时股票分析 MCP 服务

  • 这是一个实时股票数据服务的MCP(Model Context Protocol)服务器。它通过东方财富网获取金融数据,并将这些数据以工具的形式暴露给支持MCP的AI模型。
  • 免费获取数据,免登录,免数据源token
  • 部分功能支持B股,H股

功能特性

  • 📊 查找股票
  • 📈 K线数据查询(日线、周线、月线等)
  • 📉 技术指标分析
  • 💰 基本面数据分析
  • 📊 财务分析
  • 📈 市场行情跟踪
  • 🤖 智能点评和评分
    共33个MCP工具

环境要求

  • Python 3.12+
  • Windows/Linux/MacOS
  • uv 包管理器

安装步骤

1. 安装 uv 包管理器

Windows (PowerShell):

powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"

Linux/MacOS:

curl -LsSf https://astral.sh/uv/install.sh | sh

2. 克隆或下载项目

git clone https://github.com/DannyWongIsAvailable/real-time-stock-mcp-service.git
cd real-time-stock-mcp-service

3. 使用 uv 安装依赖

uv sync

使用方法

直接运行服务器

uv run app.py

client 中配置

编辑 Claude Desktop 的配置文件:

Windows: %APPDATA%\Claude\claude_desktop_config.json
MacOS: ~/Library/Application Support/Claude/claude_desktop_config.json

添加以下配置:

{
  "mcpServers": {
    "real-time-stock-mcp-service": {
      "command": "uv",
      "args": [
        "--directory",
        "C:\\path\\to\\real-time-stock-mcp-service",
        "run",
        "stock-mcp"
      ]
    }
  }
}

注意:将路径替换为你的实际项目路径。 视频教程参考:

项目结构

real-time-stock-mcp-service/
├── mcp_server.py              # MCP服务器主文件
├── pyproject.toml             # 项目配置文件
├── README.md                  # 项目说明文档
└── src/
    ├── crawler/               # 网络爬虫模块
    │   ├── base_crawler.py       # 爬虫基类
    │   ├── basic_data.py         # 基础数据爬虫(股票搜索、交易日信息)
    │   ├── real_time_data.py     # 实时数据爬虫
    │   ├── technical_data.py     # 技术数据爬虫(K线数据)
    │   └── ...              
    ├── data_source_interface.py  # 数据源接口定义
    ├── stock_data_source.py      # 数据源实现
    ├── mcp_tools/                # 各个MCP工具模块
    │   ├── kline_data.py         # K线数据工具
    │   ├── real_time_data.py     # 实时数据工具
    │   └── ...
    └── utils/                    # 工具模块
        ├── markdown_formatter.py # Markdown格式化工具
        └── utils.py              # 通用工具

核心设计

本项目采用依赖注入设计模式:

  1. crawler 模块获取数据
  2. data_source_interface.py 定义抽象数据源接口
  3. stock_data_source.py 提供具体实现
  4. 各工具模块通过依赖注入获取数据源实例

这种设计使得:

  • ✅ 易于扩展新功能
  • ✅ 可以轻松切换不同数据源
  • ✅ 便于单元测试
  • ✅ 代码解耦,维护性强

工具模块

项目包含33个MCP工具模块,每个模块提供特定领域的功能:

  • search.py - 股票搜索和交易日信息
  • real_time_data.py - 实时股票行情数据
  • kline_data.py - K线数据和技术指标
  • fundamental.py - 基本面数据(主营构成、经营范围等)
  • valuation.py - 估值分析数据(市盈率、市净率等)
  • financial_analysis.py - 财务分析数据(财务比率、业绩概况等)
  • market.py - 市场行情数据(板块行情、资金流向等)
  • smart_review.py - 智能点评和评分

开发指南

详情请查看开发指南

注意事项

⚠️ 重要提醒

  1. 本服务提供的数据仅供参考,不构成投资建议
  2. 请遵守数据使用协议和相关法律法规

许可证

MIT License

贡献

欢迎提交 Issue 和 Pull Request!

联系方式

如有问题,请提交 Issue 或联系项目开发者。

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

real_time_stock_mcp_service-0.1.4.tar.gz (48.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

real_time_stock_mcp_service-0.1.4-py3-none-any.whl (66.7 kB view details)

Uploaded Python 3

File details

Details for the file real_time_stock_mcp_service-0.1.4.tar.gz.

File metadata

File hashes

Hashes for real_time_stock_mcp_service-0.1.4.tar.gz
Algorithm Hash digest
SHA256 0e3b146277e960b1a3e72ac8a346f5ab6d9f25210013256dcfde617ac16b3dd2
MD5 0dbe0a5e4229f00bcba9a2a69f5ece0a
BLAKE2b-256 99db9b948e94e8bb72e18b69020c59861235e54c5cb1894636af10c47253ef3a

See more details on using hashes here.

File details

Details for the file real_time_stock_mcp_service-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for real_time_stock_mcp_service-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 799268bcf5773892519fc8e5f2626b2befc4e36071028b5c076169c5f0cc2b4e
MD5 b2be4699321de1fe89bb1445f51b2f20
BLAKE2b-256 3d167ad959fb1405d071b8d167627cfc8b14cae5063721336b13cf25d1bd6497

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page