AkShare MCP Server
AkShare MCP 服务器
基于 AkShare 库的金融数据 MCP (Model Context Protocol) 服务器,提供全面的股票、基金、期货等金融数据查询功能。
功能特性
📈 股票市场数据
A股实时行情 - 沪深京A股实时行情数据
历史行情数据 - 支持日线、周线、月线,可复权
个股信息查询 - 基本面信息、财务数据
分时数据 - 分钟级K线数据
板块数据 - 新股、风险警示板等
🌏 多市场支持
A股市场 - 沪深京全市场覆盖
港股市场 - 港股数据支持
美股市场 - 美股实时行情(新浪财经)
📊 数据分析工具
同行比较 - 估值、成长性、财务指标对比
风险警示 - ST股票、退市股票信息
股市日历 - 公司动态、重要事件
技术指标 - 支持各类技术分析指标
Related MCP server: China Stock MCP Server
安装设置
1. 环境要求
Node.js >= 16
Python >= 3.8
akshare 库
2. 安装依赖
# 安装 Node.js 依赖
npm install
# 安装 Python akshare 库
pip install akshare pandas3. 构建项目
npm run build4. 配置 Claude Code
配置内容:
{
"mcpServers": {
"akshare-mcp": {
"command": "node",
"args": ["/path/marketMcp/dist/index.js"],
}
}
}5. 启动服务
npm start6. 验证配置
重启 Claude Code 后,您就可以使用以下金融数据工具:
A股实时行情查询
历史K线数据(支持复权)
个股基本信息查询
港股、美股数据
同行估值比较分析
可用工具
市场行情类
工具名 | 描述 | 参数 |
| 沪A股实时行情 |
|
| 深A股实时行情 |
|
实时报价类(新增)
工具名 | 描述 | 参数 |
| 个股实时行情数据(雪球) |
|
| 实时行情数据 |
|
| 全球股市实时行情数据 |
|
| 港股实时行情数据 |
|
| 美股实时行情数据(新浪) |
|
历史数据类
工具名 | 描述 | 参数 |
| A股历史行情 |
|
| 分时数据 |
|
个股信息类
工具名 | 描述 | 参数 |
| 个股基本信息 |
|
市场分析类
工具名 | 描述 | 参数 |
| 股市日历公司动态 |
|
特殊板块类
工具名 | 描述 | 参数 |
| 新股数据 |
|
| 风险警示板数据 |
|
使用示例
1. 获取A股实时行情
{
"tool": "stock_sh_a_spot_em",
"arguments": {
"limit": 10
}
}2. 查询个股历史行情
{
"tool": "stock_zh_a_hist",
"arguments": {
"symbol": "600246",
"period": "daily",
"start_date": "20241201",
"end_date": "20241205",
"adjust": "qfq"
}
}3. 获取个股基本信息
{
"tool": "stock_individual_basic_info_xq",
"arguments": {
"symbol": "600246"
}
}4. 获取个股实时行情(雪球)
{
"tool": "stock_individual_spot_xq",
"arguments": {
"symbol": "600246"
}
}5. 获取多只股票实时行情
{
"tool": "realtime_quote",
"arguments": {
"symbol": "600246,600000,000002"
}
}7. 获取全球股市实时行情
{
"tool": "stock_global_realtime",
"arguments": {
"region": "中国"
}
}8. 获取港股实时行情
{
"tool": "stock_hk_spot_em",
"arguments": {
"limit": 50
}
}9. 获取美股实时行情(新浪)
{
"tool": "stock_us_spot",
"arguments": {
"symbol": "AAPL,MSFT,GOOGL"
}
}测试
运行测试脚本验证服务功能:
npm test或者直接运行:
node test/mcp-test.js数据源
本服务器基于 AkShare 库,数据来源于:
东方财富网
上海证券交易所
深圳证券交易所
新浪财经
腾讯财经
雪球财经
注意事项
数据延迟:实时行情数据可能有15分钟延迟
访问频率:请合理控制API调用频率,避免被限制
免责声明:本服务仅提供数据展示,不构成投资建议
数据准确性:请以官方数据为准,本数据仅供参考
故障排除
常见问题
akshare库未安装
pip install akshare pandasPython版本不兼容 确保使用 Python 3.8+
权限问题 确保脚本有执行权限
网络连接问题 检查网络连接,某些数据源可能需要特殊网络环境
开发
项目结构
├── src/
│ └── index.ts # MCP服务器主文件
├── test/
│ └── mcp-test.js # 测试脚本
├── dist/ # 编译输出目录
├── akshare_service.py # Python服务脚本
├── package.json # Node.js项目配置
├── tsconfig.json # TypeScript配置
└── README.md # 项目文档添加新工具
在
src/index.ts中的getToolDefinitions方法中添加工具定义Python服务会自动调用对应的akshare函数
在
test/mcp-test.js中添加相应的测试用例
许可证
MIT License
贡献
欢迎提交 Issue 和 Pull Request!
更新日志
v1.0.0
初始版本发布
支持基础的股票数据查询功能
包含完整的测试套件
Available Tools
14 toolsrealtime_quoteC
获取实时行情数据(使用A股实时行情)
Inputs: symbol.
stock_global_realtimeC
获取全球股市实时行情数据
Inputs: region.
stock_gsrl_gsdt_emC
获取股市日历-公司动态数据
Inputs: date (required).
stock_hk_spot_emB
获取港股实时行情数据
Inputs: limit.
stock_individual_basic_info_xqB
查询个股基本信息(雪球数据源)- 可能因网络限制无法获取数据
Inputs: symbol (required).
stock_individual_info_emC
查询个股基本信息(东方财富数据源,更稳定)
Inputs: symbol (required).
stock_individual_spot_xqA
获取个股实时行情数据(雪球)
Inputs: symbol (required).
stock_sh_a_spot_emB
获取沪A股实时行情数据
Inputs: limit.
stock_sz_a_spot_emB
获取深A股实时行情数据
Inputs: limit.
stock_us_spotB
获取美股实时行情数据(新浪)
Inputs: symbol.
stock_zh_a_histB
获取A股历史行情数据
Inputs: symbol (required), adjust, period, end_date, +1 more.
stock_zh_a_minuteC
获取股票分时数据
Inputs: symbol (required), adjust, period.
stock_zh_a_new_emB
获取新股上市数据
Inputs: limit.
stock_zh_a_st_emB
获取风险警示板股票数据
Inputs: limit.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 14 tools
Most tools have distinct purposes (e.g., market-specific quotes, historical data, individual info), but there is some overlap among real-time quote tools (A-share, Shanghai, Shenzhen, global) that could cause confusion. Descriptions help differentiate.
Names mostly start with 'stock_' but vary in structure (e.g., 'realtime_quote' breaks the pattern, and some have cryptic abbreviations like 'gsrl_gsdt_em'). Consistency is moderate but still navigable.
14 tools is well within the ideal range for a stock data server, covering real-time quotes, historical data, basic info, and special stocks without being excessive.
The set covers major stock market data needs (quotes, history, minutes, individual info, new/stocks, risk warnings), but lacks index quotes, fundamental financials, or order book data, leaving minor gaps.
Related MCP Connectors
China A-share & equity research MCP server (回声投研) for market quotes, filings, financials, fund flows, concepts & sentiment.
MCP server for real-time China A-share stock quotes, indices and market data.
Financial data MCP server for global quotes, news, financials, funds, bonds, IPOs and macro data.
2812China A-share market data for research, backtesting and AI agents via MCP.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceA Model Context Protocol server that enables Claude Desktop to access and analyze Chinese and global financial market data through the AKShare library.53MIT
- FlicenseNot gradedqualityDmaintenanceA Multi-Call Protocol server providing comprehensive access to Chinese stock market data through a unified API, leveraging AKShare to fetch real-time and historical data from various Chinese exchanges.24-
- AlicenseCqualityDmaintenanceA Model Context Protocol server providing tools for querying A-share stock market data, including historical prices, financial reports, market indices, and macroeconomic indicators.41648MIT
- AlicenseNot gradedqualityBmaintenanceA Model Context Protocol server that provides intelligent stock data assistance through Tushare's financial data API, enabling users to query comprehensive stock information, financial data, and market indices through natural language.51MIT