AkShare MCP Server

AkShare MCP Server

A financial data server that provides real-time and historical data for A-shares, Hong Kong, and US markets using the AkShare library. It enables users to query market quotes, fundamental information, and technical indicators through the Model Context Protocol.

Category
Visit Server

README

AkShare MCP 服务器

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

功能特性

📈 股票市场数据

  • A股实时行情 - 沪深京A股实时行情数据
  • 历史行情数据 - 支持日线、周线、月线,可复权
  • 个股信息查询 - 基本面信息、财务数据
  • 分时数据 - 分钟级K线数据
  • 板块数据 - 新股、风险警示板等

🌏 多市场支持

  • A股市场 - 沪深京全市场覆盖
  • 港股市场 - 港股数据支持
  • 美股市场 - 美股实时行情(新浪财经)

📊 数据分析工具

  • 同行比较 - 估值、成长性、财务指标对比
  • 风险警示 - ST股票、退市股票信息
  • 股市日历 - 公司动态、重要事件
  • 技术指标 - 支持各类技术分析指标

安装设置

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

  • 初始版本发布
  • 支持基础的股票数据查询功能
  • 包含完整的测试套件

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
E2B

E2B

Using MCP to run code via e2b.

Official
Featured