home / mcp / akshare mcp server

AkShare MCP Server

Provides historical stock data via MCP SSE interface using AkShare with configurable environment and logging.

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "guangxiangdebizi-akshare-mcp": {
      "url": "https://<not-provided>/mcp",
      "headers": {
        "HOST": "127.0.0.1",
        "PORT": "8005",
        "TRANSPORT": "sse"
      }
    }
  }
}

You run an AkShare MCP Server that exposes financial data via SSE, providing ready-made, formatted outputs for stock, HK, and A-share histories. It integrates AkShare data interfaces, validates inputs, and logs activity for easy monitoring and reliable usage by your MCP clients.

How to use

To use this MCP server, start it on your machine and connect your MCP client to the local SSE endpoint. The server exposes financial data tools for U.S. stocks, Hong Kong stocks, and Chinese A-shares, returning outputs in readable Markdown table format. Start, connect, and request data using the client’s standard MCP workflow. Ensure the client is configured to talk to the server over SSE with the correct host and port. The server handles parameter validation and returns structured results with fields such as date, prices, volume, and related metrics.

How to install

Prerequisites: you need Python installed on your machine. You will also need network access for AkShare to fetch external data.

Step 1: Install dependencies.

pip install -r requirements.txt

Step 2: Start the MCP server using one of the provided runtime commands.

Step 3: Verify the server is running by checking the logs and ensuring the chosen port is listening.

Configuration and notes

Environment variables control where the server runs and how it is exposed. You can set these before starting the server:

Environment variables

HOST The host address to bind the server to. Typical value is 127.0.0.1 or 0.0.0.0.

PORT The port on which the SSE endpoint will be exposed.

TRANSPORT The transport protocol, for example sse.

Client connection setup

In your MCP client, configure a connection to the local server using the following details. The server exposes an SSE endpoint on the configured host/port.

Example data usage patterns

Request U.S. stock historical data for a given symbol, period, date range, and adjust type. Do the same for 港股 and A股 as needed. Interpret the returned Markdown table: it includes date, open, close, high, low, volume, turnover, and metrics like amplitude and changes.

Available tools

stock_us_hist

Fetch US stock historical data with selectable period, date range, and adjustment type. Returns date, open, close, high, low, volume, turnover, amplitude, change rate, and change amount.

stock_hk_hist

Fetch Hong Kong stock historical data with selectable period, date range, and adjustment type. Returns date, open, close, high, low, volume, turnover, amplitude, change rate, and change amount.

stock_zh_a_hist

Fetch A-share historical data for Shanghai and Shenzhen markets with selectable period, date range, and adjustment type. Returns date, stock code, open, close, high, low, volume, turnover, amplitude, change rate, and change amount.