Skip to main content

Akshare MCP Server - Chinese Financial Data API for Claude via Model Context Protocol

Project description

Akshare MCP Server

English | 中文

中文

简介

Akshare MCP Server 是一个基于 Model Context Protocol (MCP) 的服务器,提供中国金融数据接口。通过集成 akshare 库,为 Claude 等 AI 助手提供实时和历史的股票、期货、基金等金融数据。

功能特性

  • 📈 股票数据:支持 A股股票的分钟级(5分钟、15分钟、30分钟、60分钟)和日线数据
  • 🥇 期货数据:支持期货合约的分钟级和日线数据,包括黄金、白银等主力合约
  • 💰 黄金数据:专门的黄金期货和现货数据接口
  • 🔍 股票搜索:根据股票名称或代码搜索股票信息
  • 📊 市场概览:提供 A股市场的整体概况和主要指数
  • 🔄 实时数据:支持最新的交易数据和历史数据查询

安装

使用 uvx(推荐)

uvx akshare-mcp-ikouhaha

使用 pip

pip install akshare-mcp-ikouhaha

从源码安装

git clone https://github.com/your-username/akshare-mcp.git
cd akshare-mcp
pip install -e .

配置

在你的 MCP 客户端配置文件中添加服务器配置:

{
  "mcpServers": {
    "akshare": {
      "command": "akshare-mcp-ikouhaha"
    }
  }
}

使用示例

获取股票数据

# 获取平安银行(000001)的日线数据
get_stock_data({"symbol": "000001", "period": "daily"})

# 获取5分钟数据
get_stock_data({"symbol": "000001", "period": "5min", "adjust": "qfq"})

获取期货数据

# 获取黄金主力合约数据
get_futures_data({"symbol": "AU0", "period": "daily"})

# 获取5分钟期货数据
get_futures_data({"symbol": "AU0", "period": "5min"})

搜索股票

# 搜索包含"平安"的股票
search_stock({"keyword": "平安"})

# 根据股票代码搜索
search_stock({"keyword": "000001"})

API 文档

工具列表

  1. get_stock_data - 获取股票数据

    • symbol (必需): 股票代码,如 "000001"
    • period (可选): 数据周期 ["5min", "15min", "30min", "60min", "daily", "weekly", "monthly"],默认 "daily"
    • adjust (可选): 复权类型 ["qfq", "hfq", ""],默认 "qfq"
  2. get_futures_data - 获取期货数据

    • symbol (必需): 期货代码,如 "AU0"(黄金主力)
    • period (可选): 数据周期 ["5min", "15min", "30min", "60min", "daily"],默认 "daily"
  3. get_gold_data - 获取黄金数据

    • data_type (可选): 数据类型 ["futures", "spot", "futures_5min"],默认 "futures"
    • period (可选): 数据周期,默认 "daily"
  4. get_market_overview - 获取市场概览

    • market (可选): 市场类型 ["a_share", "us", "hk"],默认 "a_share"
  5. search_stock - 搜索股票

    • keyword (必需): 搜索关键词

开发

环境设置

git clone https://github.com/your-username/akshare-mcp.git
cd akshare-mcp
pip install -e ".[dev]"

运行测试

pytest

代码格式化

black src/
isort src/

依赖项

  • Python >= 3.8
  • mcp >= 1.0.0
  • akshare >= 1.12.0
  • pandas >= 1.3.0

许可证

MIT License


English

Introduction

Akshare MCP Server is a Model Context Protocol (MCP) server that provides Chinese financial data interfaces. By integrating the akshare library, it offers real-time and historical data for stocks, futures, funds, and other financial instruments to AI assistants like Claude.

Features

  • 📈 Stock Data: Supports minute-level (5min, 15min, 30min, 60min) and daily data for A-share stocks
  • 🥇 Futures Data: Supports minute-level and daily data for futures contracts, including gold and silver main contracts
  • 💰 Gold Data: Dedicated gold futures and spot data interfaces
  • 🔍 Stock Search: Search stock information by name or symbol
  • 📊 Market Overview: Provides A-share market overview and major indices
  • 🔄 Real-time Data: Supports latest trading data and historical data queries

Installation

Using uvx (Recommended)

uvx akshare-mcp-ikouhaha

Using pip

pip install akshare-mcp-ikouhaha

From Source

git clone https://github.com/your-username/akshare-mcp.git
cd akshare-mcp
pip install -e .

Configuration

Add the server configuration to your MCP client configuration file:

{
  "mcpServers": {
    "akshare": {
      "command": "akshare-mcp-ikouhaha"
    }
  }
}

Usage Examples

Get Stock Data

# Get daily data for Ping An Bank (000001)
get_stock_data({"symbol": "000001", "period": "daily"})

# Get 5-minute data
get_stock_data({"symbol": "000001", "period": "5min", "adjust": "qfq"})

Get Futures Data

# Get gold main contract data
get_futures_data({"symbol": "AU0", "period": "daily"})

# Get 5-minute futures data
get_futures_data({"symbol": "AU0", "period": "5min"})

Search Stocks

# Search stocks containing "平安"
search_stock({"keyword": "平安"})

# Search by stock code
search_stock({"keyword": "000001"})

API Reference

Tools

  1. get_stock_data - Get stock data

    • symbol (required): Stock symbol, e.g., "000001"
    • period (optional): Data period ["5min", "15min", "30min", "60min", "daily", "weekly", "monthly"], default "daily"
    • adjust (optional): Adjustment type ["qfq", "hfq", ""], default "qfq"
  2. get_futures_data - Get futures data

    • symbol (required): Futures symbol, e.g., "AU0" (Gold main)
    • period (optional): Data period ["5min", "15min", "30min", "60min", "daily"], default "daily"
  3. get_gold_data - Get gold data

    • data_type (optional): Data type ["futures", "spot", "futures_5min"], default "futures"
    • period (optional): Data period, default "daily"
  4. get_market_overview - Get market overview

    • market (optional): Market type ["a_share", "us", "hk"], default "a_share"
  5. search_stock - Search stocks

    • keyword (required): Search keyword

Development

Setup

git clone https://github.com/your-username/akshare-mcp.git
cd akshare-mcp
pip install -e ".[dev]"

Run Tests

pytest

Format Code

black src/
isort src/

Dependencies

  • Python >= 3.8
  • mcp >= 1.0.0
  • akshare >= 1.12.0
  • pandas >= 1.3.0

License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

akshare_mcp_ikouhaha-0.2.3.tar.gz (8.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

akshare_mcp_ikouhaha-0.2.3-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file akshare_mcp_ikouhaha-0.2.3.tar.gz.

File metadata

  • Download URL: akshare_mcp_ikouhaha-0.2.3.tar.gz
  • Upload date:
  • Size: 8.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.13

File hashes

Hashes for akshare_mcp_ikouhaha-0.2.3.tar.gz
Algorithm Hash digest
SHA256 7dd585fa53071f09c34a5d58a76f140fbb386c8dd9a9a2d739f8919ec5b90a8e
MD5 85d3303344b48ae406803f1afad83def
BLAKE2b-256 c4fcec3d0aca077467a853acfeafa0ebc34faada68d6dfec5a5e4746794e86e7

See more details on using hashes here.

File details

Details for the file akshare_mcp_ikouhaha-0.2.3-py3-none-any.whl.

File metadata

File hashes

Hashes for akshare_mcp_ikouhaha-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 50d2b248abba940603a1d29a33f60e5fbc3356f131c702ac3f19c604521ca9de
MD5 4328bfc8bcc436ae35de82346f47b6dc
BLAKE2b-256 a1e8af071983f153f7339680c6fe4b1f9a2c9d73d76a70d0bbd6765c2fe5b46b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page