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 集成
将以下配置添加到您的 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>"
}
}
}
重启Claude桌面
从可用工具中选择 AKShare MCP 服务器
可用工具
AKShare MCP 服务器提供以下工具:
股票数据查询
基金数据查询
债券数据查询
期货数据查询
外汇数据查询
宏观经济数据查询
还有更多...
添加新工具
要向 MCP 服务器添加新工具,请按照以下步骤操作:
在:
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将新工具添加到:
class AKShareTools(str, Enum): # Existing tools... NEW_TOOL_NAME = "new_tool_name"在:
from .api import ( # Existing imports... fetch_new_data_function, )将工具定义添加到:
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 }, ),在:
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, )通过运行服务器并向新工具发出请求来测试新工具。
发展
# 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
执照
麻省理工学院
This server cannot be installed
hybrid server
The server is able to function both locally and remotely, depending on the configuration or use case.
模型上下文协议服务器使 Claude Desktop 能够通过 AKShare 库访问和分析中国及全球金融市场数据。
Related Resources
Related MCP Servers
- Asecurity-licenseAqualityA collection of Model Context Protocol servers that enable Claude Desktop to provide development assistance capabilities with filesystem, Git, shell command, and web search functionality without incurring API usage costs.Last updated -219MIT License
- Asecurity-licenseAqualityA Model Context Protocol server focused on China's A-share stock market that provides data on stocks, financials, market indices, and macroeconomic indicators.Last updated -27431MIT License
- Asecurity-licenseAqualityA Model Context Protocol server that enables interaction with Polymarket prediction markets through Claude Desktop.Last updated -3MIT License