mcp-financial-data
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@mcp-financial-data贵州茅台最新行情"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
金融数据 MCP 服务器 (mcp-financial-data)
基于 MCP (Model Context Protocol) 协议的金融数据服务器,使用 FastMCP 框架构建,为 AI 客户端提供实时的中国 A 股 / 基金 / 宏观经济 / 市场行情数据工具。
功能特性
19 个金融数据工具,覆盖四大领域
使用 akshare 获取真实金融数据
所有工具返回 markdown 格式字符串,适合 AI 客户端直接消费
完整的类型提示和 docstring,MCP 自动生成 JSON Schema
统一的错误处理,网络异常或接口变更时返回友好提示
自动数据截断,防止输出过大
Related MCP server: stock-mcp-server
项目结构
mcp-financial-data/
├── server.py # MCP Server 入口(FastMCP)
├── mcp_financial_data/
│ ├── __init__.py # 包初始化
│ ├── stock_tools.py # 股票数据工具(6个)
│ ├── fund_tools.py # 基金数据工具(4个)
│ ├── econ_tools.py # 宏观经济数据工具(5个)
│ ├── market_tools.py # 市场行情工具(4个)
│ └── utils.py # 公共工具函数
├── README.md
├── SKILL.md
└── requirements.txt工具列表
股票数据工具 (6个)
工具名 | 功能描述 |
| 获取股票实时行情(开高低收量额、PE/PB/市值) |
| 获取历史 K 线(日/周/月,前复权) |
| 获取财务指标(ROE/PE/PB/营收/净利润) |
| 获取股票列表(沪深300/中证500/上证50/全A) |
| 获取涨幅排行榜 |
| 获取跌幅排行榜 |
基金数据工具 (4个)
工具名 | 功能描述 |
| 获取基金列表(股票型/混合型/债券型/指数型/QDII/ETF/LOF) |
| 获取基金净值历史 |
| 获取基金重仓股持仓 |
| 获取基金业绩(近1周/1月/3月/6月/1年/3年收益) |
宏观经济数据工具 (5个)
工具名 | 功能描述 |
| 获取中国 GDP 季度数据 |
| 获取中国 CPI 月度数据 |
| 获取中国 PMI 月度数据 |
| 获取货币供应量(M0/M1/M2) |
| 获取汇率数据(美元/欧元/日元/英镑/港元) |
市场行情工具 (4个)
工具名 | 功能描述 |
| 获取指数行情(上证/深证/创业板/科创50/沪深300) |
| 获取板块涨跌幅排行 |
| 获取市场宽度(涨跌家数/涨停跌停/总成交额) |
| 获取北向资金流向 |
安装
# 克隆项目
git clone <repo-url>
cd mcp-financial-data
# 安装依赖
pip install -r requirements.txt配置 MCP 客户端
Claude Desktop / Claude Code
在 MCP 配置文件中添加:
{
"mcpServers": {
"financial-data": {
"command": "python",
"args": ["server.py"],
"cwd": "/path/to/mcp-financial-data"
}
}
}其他 MCP 客户端
{
"mcpServers": {
"financial-data": {
"command": "python",
"args": ["/path/to/mcp-financial-data/server.py"]
}
}
}使用示例
启动服务器后,AI 客户端会自动发现所有工具。示例对话:
"查询贵州茅台的实时行情" → 调用
get_stock_quote("600519")"查看沪深300成分股" → 调用
get_stock_list("hs300")"今天涨幅前20的股票" → 调用
get_top_gainers(20)"基金161725的净值历史" → 调用
get_fund_nav("161725")"最新的GDP数据" → 调用
get_gdp_data()"上证指数今天怎么样" → 调用
get_index_data("sh000001")"北向资金最近流向" → 调用
get_north_flow()
技术栈
MCP Protocol:
mcp(Model Context Protocol SDK)Server Framework: FastMCP
Data Source: akshare (免费开源金融数据接口库)
Data Processing: pandas
Python: 3.10+
开发
运行服务器
python server.py验证语法
python -m py_compile server.py
python -m py_compile mcp_financial_data/*.py添加新工具
在对应的
*_tools.py文件中实现工具函数在
server.py中用@mcp.tool()装饰器注册确保有完整的类型提示和 docstring
用
py_compile验证语法
测试
运行单元测试:
pip install pytest flake8
pytest tests/ -v --tb=short代码质量检查:
flake8 . --count --max-line-length=120 --statistics
## License
MITThis server cannot be deployed
Maintenance
Related MCP Connectors
Read-only China A-share data for AI agents: market, limit-up, capital flow and disclosures.
Provide access to Chinese stock market data including historical prices, real-time data, news, and…
Access real-time and historical market data for China A-shares and Hong Kong stocks, along with ne…
China A-share market data for research, backtesting and AI agents via MCP.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceProvides real-time quotes, fund flows, and corporate announcements for Chinese A-share stocks. It enables users to search for stocks, analyze financial indicators, and summarize quarterly reports through natural language.-
- AlicenseNot gradedqualityCmaintenanceReal-time A-share stock data for AI assistants. Provides real-time stock prices, K-line data, financial indicators, and sector fund flow analysis for Chinese A-share market. Multi-source data validation ensures accuracy.4MIT
- AlicenseNot gradedqualityDmaintenanceProvides AI assistants with real-time and historical Chinese stock, ETF, index, and futures data via Tushare Pro API, enabling natural language queries for financial analysis and market monitoring.5MIT
- AlicenseNot gradedqualityDmaintenanceEnables users to query Chinese A-share stock data, including stock basics, historical prices, financial reports, and macroeconomic indicators.1MIT