AKShare MCP Server

AKShare MCP Server

Enables AI assistants to access comprehensive Chinese financial market data including stocks, funds, futures, and economic indicators via AKShare.

Category
访问服务器

README

AKShare MCP Server

English | 中文版

A financial data MCP (Model Context Protocol) server based on AKShare, providing Claude and other AI assistants with comprehensive Chinese financial market data retrieval capabilities. Supports stocks, funds, futures, economic indicators, and more.

🚀 Quick Start

Prerequisites

  • Node.js: 18.0.0 or higher
  • Python: 3.8 or higher (only required for Python version)

Installation

# 1. Clone the project
git clone https://github.com/jadenmong/akshare-mcp-server.git
cd akshare-mcp-server

# 2. Install Node.js dependencies
npm install

# 3. Start the server (HTTP version, recommended - no Python dependencies)
npm start

# Or start Python version (requires Python and akshare installation)
npm run start:python

Version Information

The project provides two MCP server implementations:

HTTP Version (Recommended):

  • ✅ Zero Python dependencies, ready to use
  • ✅ Based on AKShare HTTP API, stable and reliable
  • ✅ Built-in fallback data ensures service availability
  • ✅ Simple deployment, fast startup

Python Version:

  • ✅ Direct AKShare library calls, richer data
  • ✅ Supports more data types (futures, economic indicators)
  • ❌ Requires local Python 3.8+ environment
  • ❌ Requires akshare library installation

⚙️ Configuration

Claude Desktop Configuration

Add the following configuration to your Claude Desktop configuration file:

Windows: %APPDATA%\Claude\claude_desktop_config.json macOS: ~/Library/Application Support/Claude/claude_desktop_config.json Linux: ~/.config/claude/claude_desktop_config.json

HTTP Version Configuration (Recommended):

{
  "mcpServers": {
    "akshare": {
      "command": "node",
      "args": ["<your-project-path>/src/http-server.js"],
      "description": "AKShare Financial Data MCP Server (HTTP)"
    }
  }
}

Python Version Configuration:

{
  "mcpServers": {
    "akshare": {
      "command": "node",
      "args": ["<your-project-path>/src/server.js"],
      "description": "AKShare Financial Data MCP Server (Python)"
    }
  }
}

Note:

  • Replace <your-project-path> with your actual absolute path
  • Windows: use double backslashes \\, e.g., D:\\projects\\akshare-mcp-server\\src\\http-server.js
  • macOS/Linux: use forward slashes /, e.g., /home/user/akshare-mcp-server/src/http-server.js

📋 Available Tools

📈 Stock Data (HTTP + Python Versions)

  • Historical Data: get_stock_historical_data - Get stock historical data
  • Real-time Quotes: get_stock_realtime_data - Get stock real-time quotes
  • Stock List: get_stock_list - Get stock list

🔍 Search Tools (HTTP Version New)

  • Stock Search: search_stock - Search stock information

💰 Fund Data (HTTP + Python Versions)

  • Fund List: get_fund_list - Get fund list

📊 Futures Data (Python Version Only)

  • Futures Information: get_futures_info - Get futures market data

🏭 Economic Data (Python Version Only)

  • Economic Indicators: get_economic_data - Get macroeconomic data

Version Comparison

Feature HTTP Version Python Version
Stock Historical Data
Stock Real-time Data
Stock List
Stock Search
Fund Data
Futures Data
Economic Data

🏗️ Project Structure

akshare-mcp-server/
├── src/
│   ├── http-server.js         # HTTP version MCP server (recommended)
│   ├── server.js              # Python version MCP server
│   ├── tools/                 # Financial data tool modules
│   │   ├── stock_tools.js     # Stock data tools
│   │   ├── fund_tools.js      # Fund data tools
│   │   ├── futures_tools.js   # Futures data tools
│   │   └── economic_tools.js  # Economic data tools
│   └── utils/
│       └── toolHelpers.js     # Tool helper functions
├── test/
│   └── test.js                # Automated test suite
├── python_bridge.py           # Python bridge script
├── requirements.txt           # Python dependencies
├── package.json               # Node.js configuration
├── README.md                  # English documentation
├── README_CN.md               # Chinese documentation
└── LICENSE                    # MIT License

📝 Usage Examples

Stock Data Examples

Get Stock Historical Data

{
  "name": "get_stock_historical_data",
  "arguments": {
    "symbol": "000001",
    "period": "daily",
    "start_date": "20240101",
    "end_date": "20240131",
    "adjust": "qfq"
  }
}

Get Stock Real-time Quotes

{
  "name": "get_stock_realtime_data",
  "arguments": {
    "symbol": "000001"
  }
}

Get Stock List

{
  "name": "get_stock_list",
  "arguments": {
    "market": "all"
  }
}

Fund Data Examples

Get Fund Information

{
  "name": "get_fund_info",
  "arguments": {
    "symbol": "510050"
  }
}

Get Fund List

{
  "name": "get_fund_list",
  "arguments": {
    "type": "etf"
  }
}

Futures Data Examples

Get Futures Information

{
  "name": "get_futures_info",
  "arguments": {
    "symbol": "ag",
    "exchange": "SHFE"
  }
}

Economic Data Examples

Get Economic Indicators

{
  "name": "get_economic_data",
  "arguments": {
    "indicator": "GDP",
    "start_date": "20240101",
    "end_date": "20241231"
  }
}

🔧 Development and Testing

Run Tests

The project includes a comprehensive automated test suite for both versions:

npm test

Test coverage includes:

  • Tool list retrieval
  • Stock historical data queries
  • Stock real-time quotes
  • Stock list retrieval
  • Fund data queries
  • Futures data queries (Python version)
  • Economic data queries (Python version)

Development Mode (with auto-restart)

# HTTP version development mode
npm run dev

# Python version development mode
npm run dev:python

🔍 Troubleshooting

Common Issues

  1. Node.js Version Too Low

    Error: Node.js version 18.0.0 or higher required
    Solution: Upgrade Node.js to the latest LTS version
    
  2. Python Dependencies Installation Failed

    # Try using a domestic mirror
    pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple/
    
  3. Claude Desktop Connection Failed

    • Check if the configuration file path is correct (note Windows uses double backslashes)
    • Confirm that http-server.js or server.js file path exists
    • Restart the Claude Desktop application
    • Check Claude Desktop log output
  4. Data Retrieval Failed

    • Check network connection
    • HTTP version: Confirm access to AKShare HTTP API
    • Python version: Confirm akshare library is installed (pip list | grep akshare)
    • Check server log output for errors

Debug Mode

Start the server with detailed logging:

DEBUG=akshare:* npm start

🔧 Technical Features

  • High Performance: Node.js async processing with concurrent request support
  • 🛡️ Type Safety: Strict parameter validation and type checking using Zod
  • 🌉 Python Bridge: Secure AKShare Python library calls via subprocess
  • 🔧 Modular Design: Tools organized by financial product category for easy maintenance
  • 📊 Data Standardization: Unified JSON data format and error handling
  • 🚀 Easy to Extend: Simple tool definition and addition mechanism for rapid integration
  • 🔄 Dual Implementation: HTTP and Python versions for different use cases
  • Comprehensive Testing: Automated test suite ensures code quality

📄 License

This project is open source under the MIT License.

🙏 Acknowledgments

🤝 Contributing

Welcome to submit Issues and Pull Requests to improve this project!

📞 Support

If you encounter issues during use, please:

  1. Check the Troubleshooting section of this documentation
  2. Submit an issue on GitHub Issues
  3. Consult the AKShare Official Documentation

📚 Related Documentation

🌟 Roadmap

  • [ ] Support more financial data types (bonds, forex, cryptocurrency)
  • [ ] Add data caching mechanism for better performance
  • [ ] Support custom data source configuration
  • [ ] Provide Docker image for simplified deployment
  • [ ] Add data visualization tool integration

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选