Skip to main content
Glama

Stock Analysis MCP Server

股票分析MCP工具

基于fastmcp和AKShare API构建的股票分析MCP服务器,支持CherryStudio的SSE标准协议。

功能特性

🚀 核心功能

  • 实时行情: 获取股票实时价格、涨跌幅、成交量等数据
  • 历史数据: 支持日线、周线、月线历史数据查询
  • 技术指标: 计算MA、MACD、RSI等常用技术指标
  • 市场情绪: 分析市场整体情绪和资金流向
  • 股票搜索: 根据股票名称或代码搜索股票信息
  • 新闻资讯: 获取股票相关新闻和市场资讯

🔧 技术特性

  • 基于fastmcp框架,支持MCP协议
  • 集成AKShare API,数据来源可靠
  • 内置缓存机制,提高响应速度
  • 支持CherryStudio的SSE标准协议
  • 异步处理,高性能并发

安装配置

1. 安装依赖

pip install -r requirements.txt

2. 启动服务器

python stock_mcp_server.py

3. 配置CherryStudio

在CherryStudio中添加MCP服务器配置:

{ "name": "股票分析工具", "command": "python", "args": ["stock_mcp_server.py"], "cwd": "/path/to/your/project" }

工具使用说明

1. 获取实时行情

get_stock_realtime_data(symbol="000001")
  • symbol: 股票代码,如 "000001"(平安银行)

2. 获取历史数据

get_stock_history_data( symbol="000001", period="daily", start_date="20240101", end_date="20241231" )
  • symbol: 股票代码
  • period: 数据周期 ("daily", "weekly", "monthly")
  • start_date: 开始日期 (YYYYMMDD格式)
  • end_date: 结束日期 (YYYYMMDD格式)

3. 计算技术指标

calculate_technical_indicators( symbol="000001", indicators=["ma", "macd", "rsi"] )
  • symbol: 股票代码
  • indicators: 指标列表,支持 ["ma", "macd", "rsi", "boll", "kdj"]

4. 获取市场情绪

get_market_sentiment(symbol="000001") # 个股情绪 get_market_sentiment() # 整体市场情绪

5. 搜索股票

search_stock_info(keyword="平安银行")
  • keyword: 搜索关键词(股票名称或代码)

6. 获取新闻资讯

get_stock_news(symbol="000001", limit=10) # 个股新闻 get_stock_news(limit=20) # 市场新闻

数据说明

实时行情数据字段

  • 股票代码、股票名称
  • 最新价、涨跌幅、涨跌额
  • 成交量、成交额、振幅
  • 最高价、最低价、开盘价、昨收价

技术指标说明

  • MA: 移动平均线 (5日、10日、20日、60日)
  • MACD: 指数平滑移动平均线
  • RSI: 相对强弱指标 (14日)

市场情绪指标

  • 上涨/下跌股票数量和比例
  • 主力资金净流入情况
  • 北向资金流向数据

注意事项

  1. 数据来源: 数据来自AKShare API,请遵守相关使用条款
  2. 缓存机制: 内置5分钟缓存,避免频繁请求
  3. 错误处理: 包含完善的错误处理和日志记录
  4. 性能优化: 限制返回数据量,避免内存溢出

开发扩展

添加新的技术指标

calculate_technical_indicators 函数中添加新的指标计算逻辑:

# 计算布林带 if 'boll' in indicators: df['BOLL_MID'] = df['收盘'].rolling(window=20).mean() df['BOLL_STD'] = df['收盘'].rolling(window=20).std() df['BOLL_UPPER'] = df['BOLL_MID'] + 2 * df['BOLL_STD'] df['BOLL_LOWER'] = df['BOLL_MID'] - 2 * df['BOLL_STD']

自定义缓存策略

修改 StockAnalyzer 类中的缓存参数:

self.cache_timeout = 300 # 缓存时间(秒)

许可证

MIT License

贡献

欢迎提交Issue和Pull Request来改进这个项目!

-
security - not tested
F
license - not found
-
quality - not tested

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

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.

  1. 功能特性
    1. 🚀 核心功能
    2. 🔧 技术特性
  2. 安装配置
    1. 1. 安装依赖
    2. 2. 启动服务器
    3. 3. 配置CherryStudio
  3. 工具使用说明
    1. 1. 获取实时行情
    2. 2. 获取历史数据
    3. 3. 计算技术指标
    4. 4. 获取市场情绪
    5. 5. 搜索股票
    6. 6. 获取新闻资讯
  4. 数据说明
    1. 实时行情数据字段
    2. 技术指标说明
    3. 市场情绪指标
  5. 注意事项
    1. 开发扩展
      1. 添加新的技术指标
      2. 自定义缓存策略
    2. 许可证
      1. 贡献

        Related MCP Servers

        • A
          security
          A
          license
          A
          quality
          Deliver real-time investment research with extensive private and public market data.
          Last updated -
          11
          909
          60
          JavaScript
          MIT License
          • Apple
        • -
          security
          F
          license
          -
          quality
          Provides real-time access to global stock market data including current prices, historical charts, and company financial information through a Model Context Protocol (MCP) server for AI assistants.
          Last updated -
          TypeScript
          • Linux
          • Apple
        • -
          security
          F
          license
          -
          quality
          Enables users to create, manage, and analyze investment portfolios with real-time market data, personalized recommendations, and visual representations of asset allocation.
          Last updated -
          3
          Python
        • A
          security
          A
          license
          A
          quality
          Provides integration with Twelve Data API to access financial market data including historical time series, real-time quotes, and instrument metadata for stocks, forex pairs, and cryptocurrencies.
          Last updated -
          35
          21
          Python
          MIT License

        View all related MCP servers

        MCP directory API

        We provide all the information about MCP servers via our MCP API.

        curl -X GET 'https://glama.ai/api/mcp/v1/servers/jwangkun/stock_mcp'

        If you have feedback or need assistance with the MCP directory API, please join our Discord server