Skip to main content
Glama
AkShare MCP Server

AkShare MCP Server

by qiupo

AkShare MCP 服务器

基于 AkShare 库的金融数据 MCP (Model Context Protocol) 服务器,提供全面的股票、基金、期货等金融数据查询功能。

功能特性

📈 股票市场数据

  • A股实时行情 - 沪深京A股实时行情数据

  • 历史行情数据 - 支持日线、周线、月线,可复权

  • 个股信息查询 - 基本面信息、财务数据

  • 分时数据 - 分钟级K线数据

  • 板块数据 - 新股、风险警示板等

🌏 多市场支持

  • A股市场 - 沪深京全市场覆盖

  • 港股市场 - 港股数据支持

  • 美股市场 - 美股实时行情(新浪财经)

📊 数据分析工具

  • 同行比较 - 估值、成长性、财务指标对比

  • 风险警示 - ST股票、退市股票信息

  • 股市日历 - 公司动态、重要事件

  • 技术指标 - 支持各类技术分析指标

Related MCP server: China Stock MCP Server

安装设置

1. 环境要求

  • Node.js >= 16

  • Python >= 3.8

  • akshare 库

2. 安装依赖

# 安装 Node.js 依赖
npm install

# 安装 Python akshare 库
pip install akshare pandas

3. 构建项目

npm run build

4. 配置 Claude Code

配置内容:

{
  "mcpServers": {
    "akshare-mcp": {
      "command": "node",
      "args": ["/path/marketMcp/dist/index.js"],
    }
  }
}

5. 启动服务

npm start

6. 验证配置

重启 Claude Code 后,您就可以使用以下金融数据工具:

  • A股实时行情查询

  • 历史K线数据(支持复权)

  • 个股基本信息查询

  • 港股、美股数据

  • 同行估值比较分析

可用工具

市场行情类

工具名

描述

参数

stock_sh_a_spot_em

沪A股实时行情

limit (可选)

stock_sz_a_spot_em

深A股实时行情

limit (可选)

实时报价类(新增)

工具名

描述

参数

stock_individual_spot_xq

个股实时行情数据(雪球)

symbol (必需) - 股票代码

realtime_quote

实时行情数据

symbol (必需) - 支持多只股票,逗号分隔

stock_global_realtime

全球股市实时行情数据

region (可选) - 地区:中国/香港/美国/欧洲/亚洲/全球

stock_hk_spot_em

港股实时行情数据

limit (可选) - 数据条数限制

stock_us_spot

美股实时行情数据(新浪)

symbol (可选) - 支持多只股票,逗号分隔

历史数据类

工具名

描述

参数

stock_zh_a_hist

A股历史行情

symbol (必需), period, start_date, end_date, adjust

stock_zh_a_minute

分时数据

symbol (必需), period, adjust

个股信息类

工具名

描述

参数

stock_individual_basic_info_xq

个股基本信息

symbol (必需)

市场分析类

工具名

描述

参数

stock_gsrl_gsdt_em

股市日历公司动态

date (必需)

特殊板块类

工具名

描述

参数

stock_zh_a_new_em

新股数据

limit (可选)

stock_zh_a_st_em

风险警示板数据

limit (可选)

使用示例

1. 获取A股实时行情

{
  "tool": "stock_sh_a_spot_em",
  "arguments": {
    "limit": 10
  }
}

2. 查询个股历史行情

{
  "tool": "stock_zh_a_hist",
  "arguments": {
    "symbol": "600246",
    "period": "daily",
    "start_date": "20241201",
    "end_date": "20241205",
    "adjust": "qfq"
  }
}

3. 获取个股基本信息

{
  "tool": "stock_individual_basic_info_xq",
  "arguments": {
    "symbol": "600246"
  }
}

4. 获取个股实时行情(雪球)

{
  "tool": "stock_individual_spot_xq",
  "arguments": {
    "symbol": "600246"
  }
}

5. 获取多只股票实时行情

{
  "tool": "realtime_quote",
  "arguments": {
    "symbol": "600246,600000,000002"
  }
}

7. 获取全球股市实时行情

{
  "tool": "stock_global_realtime",
  "arguments": {
    "region": "中国"
  }
}

8. 获取港股实时行情

{
  "tool": "stock_hk_spot_em",
  "arguments": {
    "limit": 50
  }
}

9. 获取美股实时行情(新浪)

{
  "tool": "stock_us_spot",
  "arguments": {
    "symbol": "AAPL,MSFT,GOOGL"
  }
}

测试

运行测试脚本验证服务功能:

npm test

或者直接运行:

node test/mcp-test.js

数据源

本服务器基于 AkShare 库,数据来源于:

  • 东方财富网

  • 上海证券交易所

  • 深圳证券交易所

  • 新浪财经

  • 腾讯财经

  • 雪球财经

注意事项

  1. 数据延迟:实时行情数据可能有15分钟延迟

  2. 访问频率:请合理控制API调用频率,避免被限制

  3. 免责声明:本服务仅提供数据展示,不构成投资建议

  4. 数据准确性:请以官方数据为准,本数据仅供参考

故障排除

常见问题

  1. akshare库未安装

pip install akshare pandas
  1. Python版本不兼容 确保使用 Python 3.8+

  2. 权限问题 确保脚本有执行权限

  3. 网络连接问题 检查网络连接,某些数据源可能需要特殊网络环境

开发

项目结构

├── src/
│   └── index.ts          # MCP服务器主文件
├── test/
│   └── mcp-test.js       # 测试脚本
├── dist/                 # 编译输出目录
├── akshare_service.py    # Python服务脚本
├── package.json          # Node.js项目配置
├── tsconfig.json         # TypeScript配置
└── README.md            # 项目文档

添加新工具

  1. 在 src/index.ts 中的 getToolDefinitions 方法中添加工具定义

  2. Python服务会自动调用对应的akshare函数

  3. 在 test/mcp-test.js 中添加相应的测试用例

许可证

MIT License

贡献

欢迎提交 Issue 和 Pull Request!

更新日志

v1.0.0

  • 初始版本发布

  • 支持基础的股票数据查询功能

  • 包含完整的测试套件

Available Tools

14 tools
realtime_quoteC

获取实时行情数据(使用A股实时行情)

Inputs: symbol.

stock_global_realtimeC

获取全球股市实时行情数据

Inputs: region.

stock_gsrl_gsdt_emC

获取股市日历-公司动态数据

Inputs: date (required).

stock_hk_spot_emB

获取港股实时行情数据

Inputs: limit.

stock_individual_basic_info_xqB

查询个股基本信息(雪球数据源)- 可能因网络限制无法获取数据

Inputs: symbol (required).

stock_individual_info_emC

查询个股基本信息(东方财富数据源,更稳定)

Inputs: symbol (required).

stock_individual_spot_xqA

获取个股实时行情数据(雪球)

Inputs: symbol (required).

stock_sh_a_spot_emB

获取沪A股实时行情数据

Inputs: limit.

stock_sz_a_spot_emB

获取深A股实时行情数据

Inputs: limit.

stock_us_spotB

获取美股实时行情数据(新浪)

Inputs: symbol.

stock_zh_a_histB

获取A股历史行情数据

Inputs: symbol (required), adjust, period, end_date, +1 more.

stock_zh_a_minuteC

获取股票分时数据

Inputs: symbol (required), adjust, period.

stock_zh_a_new_emB

获取新股上市数据

Inputs: limit.

stock_zh_a_st_emB

获取风险警示板股票数据

Inputs: limit.

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    B3.2/5.0

    Scored across 14 tools

    Disambiguation4/5

    Most tools have distinct purposes (e.g., market-specific quotes, historical data, individual info), but there is some overlap among real-time quote tools (A-share, Shanghai, Shenzhen, global) that could cause confusion. Descriptions help differentiate.

    Naming Consistency3/5

    Names mostly start with 'stock_' but vary in structure (e.g., 'realtime_quote' breaks the pattern, and some have cryptic abbreviations like 'gsrl_gsdt_em'). Consistency is moderate but still navigable.

    Tool Count5/5

    14 tools is well within the ideal range for a stock data server, covering real-time quotes, historical data, basic info, and special stocks without being excessive.

    Completeness4/5

    The set covers major stock market data needs (quotes, history, minutes, individual info, new/stocks, risk warnings), but lacks index quotes, fundamental financials, or order book data, leaving minor gaps.

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      A Model Context Protocol server that enables Claude Desktop to access and analyze Chinese and global financial market data through the AKShare library.
      53
      MIT
    • F
      license
      Not graded
      quality
      D
      maintenance
      A Multi-Call Protocol server providing comprehensive access to Chinese stock market data through a unified API, leveraging AKShare to fetch real-time and historical data from various Chinese exchanges.
      24
      -
    • A
      license
      C
      quality
      D
      maintenance
      A Model Context Protocol server providing tools for querying A-share stock market data, including historical prices, financial reports, market indices, and macroeconomic indicators.
      41
      648
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      A Model Context Protocol server that provides intelligent stock data assistance through Tushare's financial data API, enabling users to query comprehensive stock information, financial data, and market indices through natural language.
      51
      MIT