Skip to main content
Glama
Real-time Stock MCP Service

Real-time Stock MCP Service

实时股票分析 MCP 服务


这是一个实时股票数据服务的MCP服务器。它通过东方财富网和雪球网获取金融数据,并将这些数据以工具的形式暴露给支持MCP的Agent。

代码仓库: https://github.com/DannyWongIsAvailable/real-time-stock-mcp-service.git

  • 免费免登录获取数据

功能特性

  • 📊 查找股票

  • 📈 K线数据查询(支持B股,H股,大盘,分时图)

  • 📉 技术指标分析 (MA,MACD,BOLL,RSI等等)

  • 💰 基本面数据分析(主营构成、经营范围等)

  • 📊 财务分析(财务比率、业绩概况等)

  • 💰 估值分析数据(市盈率、市净率等)

  • 📈 市场行情跟踪(板块行情、同行对比、资金流向等)

  • 🤖 智能点评和评分

共34个MCP工具

Related MCP server: cn-financial-mcp

使用方法

您可以通过以下3种方式使用本服务:

1. 魔搭社区免费云资源一键部署

您可以在魔搭社区MCP实验场中在线体验该服务,也支持客户端远程连接(streamable HTTP或SSE协议)

https://modelscope.cn/mcp/servers/DannyWong/real-time-stock-mcp

2. 本地stdio模式(安装软件包运行)

添加以下配置:

{
  "mcpServers": {
    "stock-mcp": {
      "command": "uvx",
      "args": [
        "real-time-stock-mcp-service"
      ],
      "env": {
        "EASTMONEY_COOKIE": "从浏览器复制的东方财富 Cookie",
        "XUEQIU_COOKIE": "从浏览器复制的雪球 Cookie"
      }
    }
  }
}

3. 本地stdio模式(源代码运行)

{
  "mcpServers": {
    "stock-mcp": {
      "command": "path/to/python.exe",
      "args": ["-m", "stock_mcp"],
      "cwd": "path/to/real-time-stock-mcp-service",
      "env": {
        "EASTMONEY_COOKIE": "从浏览器复制的东方财富 Cookie",
        "XUEQIU_COOKIE": "从浏览器复制的雪球 Cookie"
      }
    }
  }
}

注意: 将路径替换为你的实际项目路径。

部分接口(如东方财富 datacenter、雪球实时行情/K 线)需要浏览器 Cookie 才能正常访问。请在 MCP 配置的 env 字段中设置:

环境变量

说明

EASTMONEY_COOKIE

东方财富 Cookie,用于 datacenter、push2 等接口

XUEQIU_COOKIE

雪球 Cookie,用于实时行情、K 线等接口

LOG_LEVEL

可选,日志级别,默认 INFO

获取 Cookie:

  1. 浏览器登录 eastmoney.com 或 xueqiu.com

  2. 打开开发者工具(F12)→ Network → 任意请求 → Request Headers

  3. 复制 Cookie 字段的完整内容,填入 MCP 配置对应环境变量

Cookie 会过期,若出现 403 或数据异常,重新复制并更新配置后重启 MCP 服务即可。

安全提示: 请勿将 Cookie 写入源码或提交到 Git,仅保存在本机 MCP 配置中。

视频教程参考:

核心设计

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

  1. crawler 模块获取数据

  2. data_source_interface.py 定义抽象数据源接口

  3. stock_data_source.py 提供具体实现

  4. 各工具模块通过依赖注入获取数据源实例

这种设计使得:

  • ✅ 易于扩展新功能

  • ✅ 可以轻松切换不同数据源

  • ✅ 便于单元测试

  • ✅ 代码解耦,维护性强

工具模块

项目包含34个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. 仅允许个人学习、研究、使用,禁止用于商业用途。严禁滥用!

  3. 请遵守数据使用协议和相关法律法规

开源协议

MIT License

贡献

欢迎提交 Issue 和 Pull Request!

联系方式

如有问题,请提交 Issue 或联系项目开发者。
求一个star,感激不尽!

Available Tools

34 tools
get_billboard_dataB

获取指定交易日的龙虎榜数据,包括股票基本信息、行情数据、资金流向等。

Args: trade_date: 交易日期,格式为 YYYY-MM-DD。 page_size: 返回数据条数,默认为10条。

Returns: 格式化的龙虎榜数据,以Markdown表格形式展示

Examples: - get_billboard_data("2025-11-28") - get_billboard_data("2025-11-28", 20)

Inputs: trade_date (required), page_size. Returns: result

get_business_reviewA

获取经营评述

Args: stock_code: 股票代码,要在数字后加上交易所代码,格式如300750.SZ

Returns: 经营评述文本

Examples: - get_business_review("688041.SH")

Inputs: stock_code (required). Returns: result

get_business_scopeB

获取主营业务范围

Args: stock_code: 股票代码,要在数字后加上交易所代码,格式如300750.SZ

Returns: 主营业务范围文本

Examples: - get_business_scope("300750.SZ")

Inputs: stock_code (required). Returns: result

get_current_count_changesC

获取当日异动对数据对比情况

Returns: 格式化的当日异动对数据对比情况,以Markdown表格形式展示

Examples: - get_current_stock_count_changes()

Inputs: no named parameters. Returns: result

get_current_plate_changesA

获取当日板块异动数据,包括各板块的涨跌幅、主力资金流向以及板块内异动个股等信息(异动总次数降序)。

Args: page_size: 返回数据条数,默认为10条

Returns: 格式化的当日板块异动数据,以Markdown表格形式展示

Examples: - get_current_plate_changes() - get_current_plate_changes(30)

Inputs: page_size. Returns: result

get_dupont_analysis_comparisonB

获取杜邦分析比较数据

Args: stock_code: 股票代码,要在数字后加上交易所代码,格式如600000.SH

Returns: 杜邦分析比较数据的Markdown表格

Examples: - get_dupont_analysis_comparison("600000.SH")

Inputs: stock_code (required). Returns: result

get_financial_ratiosA

获取指定股票的财务比率数据,包括盈利能力、偿债能力、运营能力等关键财务指标。

Args: stock_code: 股票代码,要在数字后加上交易所代码,格式如300750.SZ

Returns: 财务比率数据的Markdown表格

Examples: - get_financial_ratios("300750.SZ")

Inputs: stock_code (required). Returns: result

get_financial_summaryA

获取指定股票的业绩概况数据,包括历史各期的营业收入、净利润等财务指标。

Args: stock_code: 股票代码,要在数字后加上交易所代码,格式如688041.SH date_type_code: 报告类型代码 "001" - 一季度报告 "002" - 半年度报告 "003" - 三季度报告 "004" - 年度报告

Returns: 业绩概况数据的Markdown表格

Examples: - get_financial_summary("688041.SH") - get_financial_summary("688041.SH", "003")

Inputs: stock_code (required), date_type_code. Returns: result

get_growth_comparisonB

获取成长性比较数据

Args: stock_code: 股票代码,要在数字后加上交易所代码,格式如300750.SZ

Returns: 成长性比较数据的Markdown表格

Examples: - get_growth_comparison("300750.SZ")

Inputs: stock_code (required). Returns: result

get_historical_fund_flowA

获取指定股票最近N个交易日的资金流向数据,包括主力资金、散户资金、中单资金等的流入流出情况。

Args: stock_code: 股票代码,要在数字后带上交易所代码,格式如688041.SH limit: 返回数据条数,默认为10条

Returns: 格式化的历史资金流向数据,以Markdown表格形式展示

Examples: - get_historical_fund_flow("688041.SH") - get_historical_fund_flow("688041.SH", 20)

Inputs: stock_code (required), limit. Returns: result

get_holder_numberA

获取指定股票的股东户数数据,包括历史各期的股东人数及对应的收盘价。

Args: stock_code: 股票代码,要在数字后加上交易所代码,格式如688041.SH

Returns: 股东户数数据的Markdown表格

Examples: - get_holder_number("688041.SH")

Inputs: stock_code (required). Returns: result

get_industry_profit_comparisonA

获取指定股票的同行业公司盈利对比数据,包括同行业公司的基本财务和盈利指标。

Args: stock_code: 股票代码,要在数字后加上交易所代码,格式如688041.SH

Returns: 行业公司盈利数据的Markdown表格

Examples: - get_industry_profit_comparison("688041.SH")

Inputs: stock_code (required). Returns: result

get_institutional_ratingB

获取机构评级数据

Args: stock_code: 股票代码,纯数字,如688041 begin_time: 开始时间,格式如2025-10-23 end_time: 结束时间,格式如2025-12-07

Returns: 机构评级数据的Markdown表格

Examples: - get_institutional_rating("688041", "2025-01-01", "2025-12-31")

Inputs: stock_code (required), begin_time (required), end_time (required). Returns: result

get_intraday_changesA

获取指定股票的分时图盘口异动数据,包括重要交易事件和异常波动信息。

Args: stock_code: 股票代码,要在数字后加上交易所代码,格式如300750.SZ

Returns: 分时图盘口异动数据的Markdown表格

Examples: - get_intraday_changes("300750.SZ")

Inputs: stock_code (required). Returns: result

get_klineA

获取指定股票在指定日期范围内的K线数据,支持A股,B股,H股,大盘

Args: stock_code: 股票代码,要在数字后加上交易所代码,格式如300750.SZ start_date: 开始日期 (YYYY-MM-DD格式) end_date: 结束日期 (YYYY-MM-DD格式) frequency: K线周期,可选值: "d"(日), "w"(周), "m"(月), "5"(5分钟), "15"(15分钟), "30"(30分钟), "60"(60分钟)

Returns: K线数据的Markdown表格

Examples: - get_kline("300750.SZ", "2024-01-01", "2024-01-31") - get_kline("300750.SZ", "2024-10-01", "2024-10-31", "w")

Inputs: stock_code (required), start_date (required), end_date (required), frequency. Returns: result

get_last_trading_dayB

获取最新的交易日历信息,包括最近的交易日和休市日。

Returns: 最近交易日信息的Markdown表格

Examples: - get_last_trading_day()

Inputs: no named parameters. Returns: result

get_macroeconomic_researchB

获取宏观研究报告数据,推荐填入最新的日期以紧跟时事

Args: begin_time: 开始时间 end_time: 结束时间

Returns: 格式化的宏观研究报告数据,以Markdown表格形式展示

Examples: - get_macroeconomic_research("2025-12-01", "2025-12-12")

Inputs: begin_time (required), end_time (required). Returns: result

get_main_businessA

获取主营构成分析

Args: stock_code: 股票代码,要在数字后加上交易所代码,格式如300750.SZ

Returns: 主营业务构成数据的Markdown表格

Examples: - get_main_business("300059.SZ")

Inputs: stock_code (required). Returns: result

get_main_financial_dataA

获取公司主要财务数据

Args: stock_code: 股票代码,要在数字后加上交易所代码,格式如300750.SZ

Returns: 公司主要财务数据的Markdown表格

Examples: - get_main_financial_data("300750.SZ")

Inputs: stock_code (required). Returns: result

get_main_force_controlB

获取个股主力控盘数据

Args: stock_code: 股票代码,要在数字后加上交易所代码,格式如300750.SZ Examples: - get_main_force_control("300750.SZ")

Inputs: stock_code (required). Returns: result

get_market_performanceA

获取股票市场表现数据,包括与大盘和行业板块的涨跌对比

Args: secucode: 股票代码,包含交易所代码,如 300750.SZ

Returns: 格式化的市场表现数据,以Markdown表格形式展示

Examples: - get_market_performance("300750.SZ")

Inputs: secucode (required). Returns: result

get_participation_wishC

获取个股市场参与意愿数据

Args: stock_code: 股票代码,要在数字后加上交易所代码,格式如300750.SZ Examples: - get_participation_wish("300750.SZ")

Inputs: stock_code (required). Returns: result

get_plate_fund_flowA

获取板块资金流今日排行,包括行业板块、概念板块、地域板块等的资金流入流出情况。

Args: plate_type: 板块类型参数 - 1: 地域板块
- 2: 行业板块 (默认) - 3: 概念板块 page_size: 返回数据条数,默认为10条

Returns: 格式化的板块资金流数据,以Markdown表格形式展示

Examples: - get_plate_fund_flow() - get_plate_fund_flow(1) - get_plate_fund_flow(3) - get_plate_fund_flow(2, 20)

Inputs: plate_type, page_size. Returns: result

get_plate_quotationB

获取东方财富网的涨跌幅前N板块行情数据,包括行业板块、概念板块、地域板块等。

Args: plate_type: 板块类型参数 - 1: 地域板块
- 2: 行业板块 (默认) - 3: 概念板块 page_size: 返回数据条数,默认为10条

Returns: 格式化的板块行情数据,以Markdown表格形式展示

Examples: - get_plate_quotation() - get_plate_quotation(1) - get_plate_quotation(3) - get_plate_quotation(2, 20)

Inputs: plate_type, page_size. Returns: result

get_real_time_dataA

获取指定股票的实时股票数据,包括价格、涨跌幅、成交量等信息。

Args: symbol: 股票代码,数字后带上交易所代码,格式如688041.SH

Returns: 格式化的实时股票数据,以Markdown表格形式展示

Examples: - get_real_time_data("688041.SH")

Inputs: symbol (required). Returns: result

get_real_time_market_indicesA

获取实时大盘指数数据,包括上证指数、深证成指、创业板指等的实时行情。

Returns: 格式化的实时大盘指数数据,以Markdown表格形式展示

Examples: - get_real_time_market_indices()

Inputs: no named parameters. Returns: result

get_smart_scoreA

获取股票智能评分数据

Args: stock_code: 股票代码,要在数字后加上交易所代码,格式如300750.SZ Examples: - get_smart_score("300750.SZ")

Inputs: stock_code (required). Returns: result

get_smart_score_rankB

获取个股智能评分排名数据

Args: stock_code: 股票代码,要在数字后加上交易所代码,格式如300750.SZ Examples: - get_smart_score_rank("300750.SZ")

Inputs: stock_code (required). Returns: result

get_stock_billboard_dataB

获取龙虎榜上榜历史数据(历次上榜)

Args: stock_code: 股票代码,数字后带上交易所代码,格式如688041.SH page_size: 返回数据条数,默认为10条

Returns: 格式化的龙虎榜上榜历史数据,以Markdown表格形式展示

Examples: - get_historical_billboard_data("688041.SH") - get_historical_billboard_data("688041.SH", 20)

Inputs: stock_code (required), page_size. Returns: result

get_technical_indicatorsA

获取指定股票的技术指标数据,包括MACD、KDJ、RSI、BOLL等技术指标和技术分析。

Args: stock_code: 股票代码,要在数字后加上交易所代码,格式如300750.SZ page_size: 返回数据条数,默认为30条

Returns: 技术指标数据的Markdown表格

Examples: - get_technical_indicators("300750.SZ") - get_technical_indicators("300750.SZ", 20)

Inputs: stock_code (required), page_size. Returns: result

get_top_rated_stocksB

获取全市场高评分个股

Args: page_size: 返回排名前几条 Examples: get_top_rated_stocks(10)

Inputs: page_size. Returns: result

get_valuation_analysisA

获取指定股票的所有估值分析数据,包括市盈率、市净率、市销率和市现率的当前值和历史分位数。

Args: stock_code: 股票代码,要在数字后加上交易所代码,格式如300750.SZ date_type: 时间周期类型 1 - 1年 2 - 3年 3 - 5年 4 - 10年

Returns: 所有估值分析数据的Markdown表格

Examples: - get_valuation_analysis("300750.SZ", 3) - get_valuation_analysis("300750.SZ", 2)

Inputs: stock_code (required), date_type. Returns: result

get_valuation_comparisonB

获取估值比较数据

Args: stock_code: 股票代码,要在数字后加上交易所代码,格式如600000.SH

Returns: 估值比较数据的Markdown表格

Examples: - get_valuation_comparison("600000.SH")

Inputs: stock_code (required). Returns: result

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.5/5.0

    Scored across 34 tools

    Disambiguation4/5

    Most tools target distinct aspects (real-time, K-line, financials, technicals, etc.), but some overlap exists among financial analysis tools (e.g., get_main_financial_data, get_financial_summary, get_financial_ratios) that might confuse an agent.

    Naming Consistency5/5

    All tools consistently use the 'get_' prefix followed by descriptive snake_case names (verb_noun pattern). No mixing of conventions or ambiguous names.

    Tool Count4/5

    34 tools is high but justified by the broad scope of stock data (real-time, history, fundamentals, technicals, plates). Could potentially consolidate a few, but overall reasonable for a comprehensive data service.

    Completeness4/5

    Covers most major data categories for stock analysis (search, quotes, K-line, financials, technical indicators, fund flow, plates, ratings). Minor gaps like missing options or bond data, but core needs are met.

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      D
      maintenance
      MCP server that wraps SFC financial data API into 32 tools for comprehensive A-share market data, including real-time quotes, rankings, limit-up statistics, news, themes, financials, charts, research reports, and watchlists.
      -
    • A
      license
      Not graded
      quality
      D
      maintenance
      Provides access to Chinese mainland financial data including A-stock quotes, financial statements, industry analysis, and macroeconomics through 42 MCP tools, with automatic data source fallback and no API key required.
      46
      Apache 2.0
    • A
      license
      A
      quality
      D
      maintenance
      Provides access to Chinese A-share market financial data, including historical K-line, real-time quotes, financial statements, shareholder information, and technical indicators, via MCP protocol.
      12
      13 npm
      3
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Provides 46 no-authentication A-share (Chinese stock market) data tools covering quotes, financials, capital flows, sectors, announcements, macro data, and more, callable from any MCP client without API keys.
      106 npm
      2
      Apache 2.0