Skip to main content
Glama
AKShare MCP Server

AKShare MCP Server

by jadenmong

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

Related MCP server: AkTools MCP Server

โš™๏ธ 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

๐ŸŒŸ 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

Available Tools

5 tools
get_fund_listC

Get fund list from HTTP sources.

Inputs: type, limit.

get_stock_historical_dataC

Get stock historical data from HTTP sources.

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

get_stock_listC

Get stock list from HTTP sources.

Inputs: market, limit.

get_stock_realtime_dataC

Get stock real-time data from HTTP sources.

Inputs: symbol (required).

search_stockC

Search stock information from HTTP sources.

Inputs: keyword (required), market.

Tool Schema Changelog

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

Loading tool schema changelogโ€ฆ

    TDQS

    B3.1/5.0

    Scored across 5 tools

    Disambiguation5/5

    Each tool targets a distinct resource or data type: funds vs. stocks, and within stocks: historical data, real-time data, list, and search. No overlapping purposes.

    Naming Consistency5/5

    All tool names follow a verb_noun pattern in snake_case (get_fund_list, get_stock_historical_data, etc.). The only slight variation is 'search_stock' instead of 'get_search_stock', but it still maintains the verb_noun structure.

    Tool Count5/5

    With 5 tools covering both fund and stock data retrieval, the count is well-scoped for a financial data API. It provides essential operations without being overwhelming.

    Completeness4/5

    The tool set covers core read operations for stocks and funds but lacks fund historical and real-time data, which are minor gaps. The primary domain (stock and fund lookups) is well-covered.

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Provides real-time A-share (Chinese stock market) data through AKShare integration, enabling access to market overviews, company information, real-time quotes, and historical price data for Shanghai and Shenzhen stock exchanges.
      1
      Apache 2.0
    • A
      license
      A
      quality
      D
      maintenance
      Enables querying and analysis of stock and cryptocurrency data, including market overviews, price history, news, and financial indicators, via akshare.
      18
      MIT
    • A
      license
      A
      quality
      D
      maintenance
      Enables AI assistants to query real-time A-share stock data, including quotes, fund flows, sector flows, and K-line history, without needing an API key.
      5
      19
      MIT
    • F
      license
      Not graded
      quality
      D
      maintenance
      Provides AI assistants with access to Tushare financial data API for querying Chinese stock market data, financial statements, and macroeconomic indicators.
      -