AKShare MCP Server

hybrid server

The server is able to function both locally and remotely, depending on the configuration or use case.

Integrations

  • Supports containerized deployment of the AKShare MCP server via Docker build and run commands

  • Provides repository access for installation of the AKShare MCP server via cloning from GitHub

  • Provides testing capabilities for the AKShare MCP server development

AKShare MCP 服务器

使用 AKShare 库提供财务数据分析功能的模型上下文协议 (MCP) 服务器。

特征

  • 通过AKShare获取中国及全球金融市场数据
  • 通过 MCP 协议与 Claude Desktop 集成
  • 支持各类财务数据查询及分析

安装

使用 uv(推荐)

# Clone the repository git clone https://github.com/yourusername/akshare_mcp_server.git cd akshare_mcp_server # Create and activate a virtual environment python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate # Install dependencies with uv uv pip install -e .

使用 pip

# Clone the repository git clone https://github.com/yourusername/akshare_mcp_server.git cd akshare_mcp_server # Create and activate a virtual environment python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate # Install dependencies pip install -e .

用法

运行服务器

# Activate the virtual environment source venv/bin/activate # On Windows: venv\Scripts\activate # Run the server python run_server.py

与 Claude Desktop 集成

  1. 将以下配置添加到您的 Claude Desktop 配置中:
"mcpServers": { "akshare-mcp": { "command": "uv", "args": [ "--directory", "/path/to/akshare_mcp_server", "run", "akshare-mcp" ], "env": { "AKSHARE_API_KEY": "<your_api_key_if_needed>" } } }
  1. 重启Claude桌面
  2. 从可用工具中选择 AKShare MCP 服务器

可用工具

AKShare MCP 服务器提供以下工具:

  • 股票数据查询
  • 基金数据查询
  • 债券数据查询
  • 期货数据查询
  • 外汇数据查询
  • 宏观经济数据查询
  • 还有更多...

添加新工具

要向 MCP 服务器添加新工具,请按照以下步骤操作:

  1. src/mcp_server_akshare/api.py中添加一个新的 API 函数
    async def fetch_new_data_function(param1: str, param2: str = "default") -> List[Dict[str, Any]]: """ Fetch new data type. Args: param1: Description of param1 param2: Description of param2 """ try: df = ak.akshare_function_name(param1=param1, param2=param2) return dataframe_to_dict(df) except Exception as e: logger.error(f"Error fetching new data: {e}") raise
  2. 将新工具添加到src/mcp_server_akshare/server.py中的枚举中
    class AKShareTools(str, Enum): # Existing tools... NEW_TOOL_NAME = "new_tool_name"
  3. src/mcp_server_akshare/server.py中导入新函数
    from .api import ( # Existing imports... fetch_new_data_function, )
  4. 将工具定义添加到handle_list_tools()函数
    types.Tool( name=AKShareTools.NEW_TOOL_NAME.value, description="Description of the new tool", inputSchema={ "type": "object", "properties": { "param1": {"type": "string", "description": "Description of param1"}, "param2": {"type": "string", "description": "Description of param2"}, }, "required": ["param1"], # List required parameters }, ),
  5. handle_call_tool()函数中添加工具处理程序
    case AKShareTools.NEW_TOOL_NAME.value: param1 = arguments.get("param1") if not param1: raise ValueError("Missing required argument: param1") param2 = arguments.get("param2", "default") result = await fetch_new_data_function( param1=param1, param2=param2, )
  6. 通过运行服务器并向新工具发出请求来测试新工具。

发展

# Install development dependencies uv pip install -e ".[dev]" # Run tests pytest

Docker

您还可以使用 Docker 运行服务器:

# Build the Docker image docker build -t akshare-mcp-server . # Run the Docker container docker run -p 8000:8000 akshare-mcp-server

执照

麻省理工学院

-
security - not tested
F
license - not found
-
quality - not tested

模型上下文协议服务器使 Claude Desktop 能够通过 AKShare 库访问和分析中国及全球金融市场数据。

  1. Features
    1. Installation
      1. Using uv (recommended)
      2. Using pip
    2. Usage
      1. Running the server
      2. Integrating with Claude Desktop
    3. Available Tools
      1. Adding a New Tool
        1. Development
          1. Docker
            1. License
              ID: ndlloeca6d