Skip to main content
Glama
MCP Stock Assistant

MCP Stock Assistant

MCP Stock Assistant

一个基于模型上下文协议 (MCP) 的股票信息服务器,使用东方财富API提供实时股票数据。

功能特性

  • 📈 获取实时股票数据(支持股票代码或名称查询)

  • 📊 获取股票历史K线数据(日K、周K、月K)

  • 🏛️ 获取大盘指数信息(上证指数、深证成指)

  • 💹 详细的买卖盘口信息

  • 📋 支持中国A股市场(沪深两市)

  • 🔍 智能股票搜索(支持股票名称模糊匹配)

Related MCP server: Stock Data MCP Server

安装说明

  1. 克隆仓库:

    git clone <repository-url>
    cd mcp-stock
  2. 安装依赖:

    pnpm install
  3. 构建项目:

    pnpm run build

使用方法

配置MCP客户端

在Claude Desktop或其他MCP客户端的配置文件中添加以下配置:

{
  "mcpServers": {
    "mcp-stock": {
      "command": "node",
      "args": [
        "/Users/zhangyanhua/Documents/augment-projects/mcp-stock/build/index.js" // 打包后的真实路径
      ]
    }
  }
}

该服务器实现了模型上下文协议,可以与任何支持MCP的客户端配合使用,如Claude Desktop。

可用工具

服务器提供以下三个工具:

  1. get-stock-info: 获取股票实时信息

    • 参数: stock_code - 股票代码或名称(例如:600519 或 贵州茅台)

  2. get-stock-history: 获取股票历史数据

    • 参数:

      • stock_code - 股票代码或名称

      • period - 时间周期(1d=日K线, 1w=周K线, 1m=月K线,默认1d)

      • days - 获取天数(1-500天,默认30天)

  3. get-market-index: 获取大盘指数信息

    • 无参数,返回上证指数和深证成指的实时数据

使用示例

1. 获取股票实时信息

股票信息: 600519 (贵州茅台)

当前价格: 1756.00
跌幅: -0.85%
涨跌额: -15.00
开盘价: 1770.00
最高价: 1775.00
最低价: 1750.00
昨收价: 1771.00
成交量: 45678.00手
成交额: 8023456.00万
换手率: 0.36%
市盈率(动态): 35.2
振幅: 1.41%
更新时间: 15:00:00

买卖盘口:
卖5: 1758.00 / 120.00手
卖4: 1757.00 / 89.00手
卖3: 1756.50 / 156.00手
卖2: 1756.20 / 234.00手
卖1: 1756.00 / 67.00手
买1: 1755.80 / 145.00手
买2: 1755.50 / 78.00手
买3: 1755.20 / 203.00手
买4: 1755.00 / 167.00手
买5: 1754.80 / 89.00手

2. 获取股票历史数据

📈 贵州茅台(600519) 历史数据 (最近10个交易日)

日期        开盘    收盘    最高    最低    成交量(手)  涨跌幅
─────────────────────────────────────────────────────────────────
2024-01-15  1770.00 1756.00 1775.00 1750.00  45678.00 📉-0.85%
2024-01-12  1780.00 1771.00 1785.00 1765.00  52341.00 📈+0.57%
...

📊 统计信息:
最高价: 1785.00
最低价: 1720.00
平均价: 1752.50
总成交量: 456789.00手

3. 获取大盘指数信息

📊 大盘指数信息

指数名称      当前点位    涨跌幅     涨跌点    成交量(手)   成交额(万)
──────────────────────────────────────────────────────────────────
上证指数       2956.48 📉-0.42%    -12.56  123456789.00 45678901.00
深证成指      9234.67 📉-0.38%    -35.23   98765432.00 32109876.00

🕐 更新时间: 15:00:00

股票代码格式

支持以下格式的股票查询:

按代码查询

  • 沪市A股: 6位数字代码(如:600519、601318、688981)

  • 深市A股: 6位数字代码(如:000858、002415、300750)

按名称查询

  • 股票全名: 如 贵州茅台、平安银行

  • 股票简称: 如 茅台、平安

代码规则

  • 沪市主板: 600、601、603、605开头

  • 科创板: 688开头

  • 深市主板: 000开头

  • 中小板: 002开头

  • 创业板: 300、301开头

技术说明

  • 📡 使用东方财富API获取实时股票数据

  • 🔌 基于stdio传输协议,与MCP客户端完全兼容

  • 🆓 无需API密钥,免费使用(可能存在频率限制)

  • 🚀 支持智能搜索,可通过股票名称模糊匹配

  • 📊 提供完整的技术指标和盘口数据

开源协议

ISC

Available Tools

3 tools
get-market-indexB

获取大盘指数概览信息,包括上证指数和深证成指等主要指数的实时数据

Inputs: no named parameters.

get-stock-historyB

获取单个股票的历史数据、过去价格、K线数据,支持日K、周K、月K线,用于分析股票过去的表现

Inputs: stock_code (required), period, days.

get-stock-infoB

获取单个股票的实时当前信息,包括当前价格、涨跌幅、成交量等实时数据

Inputs: stock_code (required).

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    B3.3/5.0

    Scored across 3 tools

    Disambiguation5/5

    Each tool has a clearly distinct purpose: get-market-index focuses on market indices, get-stock-history retrieves historical data for individual stocks, and get-stock-info provides real-time information for individual stocks. There is no overlap in functionality, making it easy for an agent to select the appropriate tool.

    Naming Consistency5/5

    All tool names follow a consistent verb_noun pattern with hyphens (e.g., get-market-index, get-stock-history, get-stock-info). The naming is uniform and predictable, using the same verb 'get' followed by a descriptive noun phrase.

    Tool Count3/5

    With only 3 tools, the server feels thin for a stock assistant domain. While the tools cover basic data retrieval (indices, historical data, real-time info), it lacks operations for analysis, trading, or portfolio management, which are common in stock-related tools. The count is borderline but reasonable for a minimal setup.

    Completeness2/5

    The tool surface is significantly incomplete for a stock assistant. It only provides read-only data retrieval (get operations) with no ability to create, update, or delete (e.g., no tools for setting alerts, managing watchlists, or executing trades). This will cause agent failures when trying to perform common stock-related tasks beyond basic queries.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      D
      maintenance
      Enables real-time stock market analysis through AKShare API integration. Supports retrieving live stock prices, historical data, technical indicators (MA, MACD, RSI), market sentiment analysis, stock search, and financial news.
      5
      -
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables querying financial data including stocks, indices, funds, and futures from Chinese, Hong Kong, and US markets. Provides real-time market information, financial indicators, news, and trading suggestions through Eastmoney and Sina data sources.
      12 npm
      3
      ISC
    • F
      license
      B
      quality
      D
      maintenance
      Provides real-time market data for A-shares, Hong Kong, and US stocks using the Tencent Finance API. It enables users to manage stock positions and watchlists through an AI assistant.
      12
      1
      -
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables users to query Chinese A-share stock data, including stock basics, historical prices, financial reports, and macroeconomic indicators.
      1
      MIT