akshare-mcp
This TypeScript-based MCP server (zero Python dependencies) provides AI assistants with comprehensive Chinese A-share stock market data from East Money, Sina, and Xueqiu.
Market Data
get_time_info— Current time, timestamp, and latest trading dayget_hist_data— Historical K-line data (minute/hour/day/week/month/year intervals, forward/backward price adjustment, multiple sources) with 34 built-in technical indicators (SMA, EMA, MACD, RSI, BOLL, ATR, CCI, ADX, MFI, etc.)get_realtime_data— Real-time quotes: price, change %, market cap, PE/PB ratios
Financial Statements
get_balance_sheet— Total assets, fixed assets, cash, inventory, liabilitiesget_income_statement— Operating revenue, costs, net profitget_cash_flow— Operating, investing, and financing cash flowsget_financial_metrics— Key consolidated financial metrics
Shareholder Data
get_top10_shareholders— Top 10 shareholders (name, share count, %, changes)get_top10_free_shareholders— Top 10 tradable shareholders with type classification (fund, QFII, broker, insurance)get_fund_holdings— Complete fund holdings (unlimited records, position size, float %, market value)
News & Insider Activity
get_news_data— Stock-related news from East Moneyget_inner_trade_data— Insider trading records (director/supervisor/executive buy/sell transactions)
AHShare MCP Server
纯 TypeScript 实现的中国 A 股市场数据 MCP 服务器
概述
ahshare-mcp 是一个基于 Model Context Protocol (MCP) 的服务器,为 AI 助手(如 Claude Desktop、VS Code Copilot)提供中国 A 股市场金融数据访问能力。
核心特点:与 Python 版 akshare-one-mcp 功能兼容,但使用 纯 TypeScript 实现,零 Python 依赖。
与 Python 版的区别
维度 | Python 版 | TypeScript 版 |
语言 | Python 3.12+ | TypeScript 5.x |
运行时 | CPython | Node.js 22+ |
数据源 | 通过 | 直接调用 HTTP API |
Python 依赖 | ❌ 必需 | ✅ 零依赖 |
技术指标 | pandas 计算 | 纯 TS 数学实现 |
部署 | Python + pip/uv | 单 Node.js 进程 |
镜像大小 | ~500MB | ~150MB |
MCP 工具数 | 9 | 12(含股东/基金持股) |
Related MCP server: A股实时行情MCP服务器
功能特性
📊 市场数据(3 个工具)
历史 K 线 — 日/周/月/分钟级,支持前/后复权,多数据源
实时行情 — 最新价、涨跌幅、市值、PE/PB
34 种技术指标 — SMA/EMA/MACD/RSI/BOLL/ATR/CCI/ADX/MFI 等
💰 财务报表(4 个工具)
资产负债表 — 总资产、固定资产、货币资金、存货、负债
利润表 — 营业收入、营业成本、营业利润、净利润
现金流量表 — 经营/投资/筹资现金流
财务指标 — 三表合并关键指标
👥 股东数据(3 个工具)
十大股东 — 排名、持股数、持股比例、变动详情
十大流通股东 — 类型分类(基金/QFII/券商/保险)
基金持股 — 全量(不限于前10),1000+ 条记录
📰 其他(2 个工具)
个股新闻 — 东方财富新闻搜索
内部交易 — 董监高增/减持记录
时间信息 — 当前时间 + 最近交易日
安装
前提条件
通过 npm 安装
npm install -g ahshare-mcp从源码安装
git clone https://github.com/terrysun1216/ahshare-mcp-ts.git
cd ahshare-mcp-ts
npm install
npm run build使用
Claude Desktop 集成
在 Claude Desktop 配置文件中添加:
{
"mcpServers": {
"ahshare-mcp": {
"command": "npx",
"args": ["ahshare-mcp"]
}
}
}或在 VS Code Copilot 中:
{
"mcpServers": {
"ahshare-mcp": {
"command": "npx",
"args": ["tsx", "/path/to/ahshare-mcp-ts/src/main.ts"]
}
}
}命令行
# stdio 模式(默认,供 MCP 客户端使用)
ahshare-mcp
# HTTP 模式(供远程/Web 客户端使用)
ahshare-mcp --streamable-http --port 8081示例对话
配置后,在 Claude 中可以这样对话:
"帮我查看贵州茅台 600519 最近 30 天的日线走势和 MACD 指标"
"贵州茅台最新的十大股东是谁?持股市值多少?"
"对比一下 600519 和 000858 的 PE、ROE 等财务指标"
"有哪些基金重仓持有了贵州茅台?"
MCP 工具列表
# | 工具名 | 描述 | 数据源 |
1 |
| 当前时间、时间戳、最近交易日 | 新浪 |
2 |
| 历史 K 线数据 + 34种技术指标 | 东方财富/新浪 |
3 |
| 实时行情(价格/涨跌/市值/PE/PB) | 东方财富 |
4 |
| 个股新闻 | 东方财富 |
5 |
| 资产负债表 | 东方财富 |
6 |
| 利润表 | 东方财富 |
7 |
| 现金流量表 | 东方财富 |
8 |
| 三大报表合并关键指标 | 东方财富 |
9 |
| 董监高内部交易 | 雪球 |
10 |
| 十大股东 + 十大流通股东 | 东方财富 F10 |
11 |
| 十大流通股东明细 | 东方财富 F10 |
12 |
| 基金持股明细(全量) | 新浪财经 |
34 种技术指标
类别 | 指标 |
趋势 | SMA, EMA, MACD, APO, PPO, TRIX, ULTOSC |
动量 | RSI, CCI, ADX, DX, MFI, MOM, CMO, WILLR |
波动率 | BOLL, ATR, SAR |
成交量 | OBV, AD, ADOSC |
方向 | PLUS_DI, PLUS_DM, MINUS_DI, MINUS_DM |
变化率 | ROC, ROCP, ROCR, ROCR100 |
其他 | AROON, AROONOSC, BOP, STOCH, TSF |
架构
┌─────────────────────────┐
│ MCP Client │
│ (Claude Desktop / VS Code) │
└──────┬──────────────────┘
│ JSON-RPC (stdio / HTTP)
┌──────┴──────────────────┐
│ MCP Server Layer │
│ @modelcontextprotocol/ │
│ sdk + Hono + Zod │
├──────────────────────────┤
│ Service Layer │
│ 行情 / 财务 / 股东 / 新闻 │
├──────────────────────────┤
┌──────────┼──────────┬──────────────┤
│ │ │ │
┌────┴───┐ ┌───┴────┐ ┌───┴───┐ ┌───────┴──┐
│东方财富 │ │ 新浪 │ │ 雪球 │ │ 指标引擎 │
│ HTTP │ │ HTTP │ │ HTTP │ │ 34 函数 │
└────────┘ └────────┘ └───────┘ └──────────┘数据流向:MCP Client → JSON-RPC → MCP Server → Service → HTTP Provider → 东方财富/新浪/雪球公开 API
零 Python 依赖:直接从 TypeScript 调用各数据源的公开 HTTP 接口,使用 Node.js 内置 fetch API。
技术栈
包 | 版本 | 用途 |
| ^1.29 | MCP 协议实现 |
| ^4.12 | HTTP 框架 |
| ^4.4 | 参数校验 + 类型推导 |
| ^5.9 | 类型系统 |
| ^4.1 | 测试框架 |
仅 3 个生产依赖,与 Lyna 项目使用完全相同的技术栈。
开发
# 安装依赖
npm install
# 开发运行(stdio 模式)
npm run dev
# 开发运行(HTTP 模式)
npm run dev:http
# 运行测试
npm test
# 编译
npm run build项目结构
src/
├── main.ts # CLI 入口
├── config.ts # 全局配置
├── calendar.ts # 交易日历
├── server/ # MCP Server (stdio + HTTP)
├── tools/ # 12 个 MCP 工具定义
├── services/ # 业务逻辑层
├── providers/ # HTTP API 层(东方财富/新浪/雪球/F10)
├── indicators/ # 34 个技术指标纯函数
└── types/ # Zod Schema + TS 类型测试
全部 13 个 E2E 测试通过,使用真实数据验证:
npm test # 单元测试
npx tsx tests/e2e-all-tools.test.ts # 端到端测试许可证
MIT © Terry
致谢
AKShare — 底层数据源研究和参考
akshare-one-mcp — Python 版 MCP 参考实现
Lyna — TypeScript MCP 架构参考
Available Tools
12 toolsget_balance_sheetC
Get company balance sheet data.
Inputs: symbol (required), recent_n.
get_cash_flowB
Get company cash flow statement data.
Inputs: symbol (required), source, recent_n.
get_financial_metricsC
Get key financial metrics from the three major financial statements.
Inputs: symbol (required), recent_n.
get_fund_holdingsA
获取股票基金持股明细(全量,不限前10)。返回所有持有该股票的基金名称、代码、持仓数量、占流通股比例、持股市值
Inputs: symbol (required).
get_hist_dataC
Get historical stock market data. 'eastmoney_direct' support all A,B,H shares
Inputs: symbol (required), adjust, source, end_date, +5 more.
get_income_statementB
Get company income statement data.
Inputs: symbol (required), recent_n.
get_inner_trade_dataC
Get company insider trading data.
Inputs: symbol (required).
get_news_dataC
Get stock-related news data.
Inputs: symbol (required), recent_n.
get_realtime_dataA
Get real-time stock market data. 'eastmoney_direct' support all A,B,H shares
Inputs: source, symbol.
get_time_infoA
Get current time with ISO format, timestamp, and the last trading day.
Inputs: no named parameters.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 12 tools
Each tool targets a specific type of financial or market data with clear distinctions: financial statements (balance sheet, cash flow, income, metrics), market data (historical vs real-time), ownership (fund holdings, top10 shareholders, top10 free shareholders), insider trades, news, and time info. No two tools have overlapping purposes.
All tool names follow a consistent 'get_<descriptive_noun>' pattern using snake_case. The naming is uniform and predictable, making it easy for agents and users to understand the action and data type each tool provides.
With 12 tools, the server covers core functionalities for stock market data retrieval (financials, prices, ownership, news, utilities) without being overly expansive or too sparse. The count is well-suited for a focused financial data assistant.
The tool surface covers major areas: financial statements, market prices (historical & real-time), holdings, insider trades, and news. However, it lacks tools for company profiles, dividend data, or index data, which are minor gaps for a comprehensive stock analysis toolkit.
Maintenance
Related MCP Connectors
China A-share market data for research, backtesting and AI agents via MCP.
China A-share market data over MCP: 22 tools for quotes, K-line, financials, money flow, top-trader boards, sectors, macro, convertible bonds and factor screening. Five tools need no API key, so you can connect and try it immediately.
MCP server for real-time China A-share stock quotes, indices and market data.
China A-share & equity research MCP server (回声投研) for market quotes, filings, financials, fund flows, concepts & sentiment.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceMCP server that wraps SFC financial data API into 32 tools for comprehensive A-share market data, including real-time quotes, rankings, limit-up statistics, news, themes, financials, charts, research reports, and watchlists.-
- AlicenseNot gradedqualityDmaintenance基于Model Context Protocol (MCP) 的A股实时行情查询服务器,支持查询A股实时价格、历史K线数据、财务信息及市场概况。8MIT
- FlicenseNot gradedqualityDmaintenanceProvides stock market data (search, quotes, real-time, charts) for A-share, Hong Kong, and US stocks via MCP tools.-
- AlicenseNot gradedqualityBmaintenanceEnables MCP clients to directly access A-share market data, including real-time quotes, K-lines, market statistics, sector performance, multi-condition stock screening, and latest financial indicators.MIT