mcp-financial-data

mcp-financial-data

提供19个中国A股、基金、宏观经济及市场行情数据工具,支持AI客户端实时查询。

Category
Visit Server

README

金融数据 MCP 服务器 (mcp-financial-data)

基于 MCP (Model Context Protocol) 协议的金融数据服务器,使用 FastMCP 框架构建,为 AI 客户端提供实时的中国 A 股 / 基金 / 宏观经济 / 市场行情数据工具。

功能特性

  • 19 个金融数据工具,覆盖四大领域
  • 使用 akshare 获取真实金融数据
  • 所有工具返回 markdown 格式字符串,适合 AI 客户端直接消费
  • 完整的类型提示和 docstring,MCP 自动生成 JSON Schema
  • 统一的错误处理,网络异常或接口变更时返回友好提示
  • 自动数据截断,防止输出过大

项目结构

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个)

工具名 功能描述
get_stock_quote 获取股票实时行情(开高低收量额、PE/PB/市值)
get_stock_history 获取历史 K 线(日/周/月,前复权)
get_stock_financial 获取财务指标(ROE/PE/PB/营收/净利润)
get_stock_list 获取股票列表(沪深300/中证500/上证50/全A)
get_top_gainers 获取涨幅排行榜
get_top_losers 获取跌幅排行榜

基金数据工具 (4个)

工具名 功能描述
get_fund_list 获取基金列表(股票型/混合型/债券型/指数型/QDII/ETF/LOF)
get_fund_nav 获取基金净值历史
get_fund_holdings 获取基金重仓股持仓
get_fund_performance 获取基金业绩(近1周/1月/3月/6月/1年/3年收益)

宏观经济数据工具 (5个)

工具名 功能描述
get_gdp_data 获取中国 GDP 季度数据
get_cpi_data 获取中国 CPI 月度数据
get_pmi_data 获取中国 PMI 月度数据
get_money_supply 获取货币供应量(M0/M1/M2)
get_fx_rate 获取汇率数据(美元/欧元/日元/英镑/港元)

市场行情工具 (4个)

工具名 功能描述
get_index_data 获取指数行情(上证/深证/创业板/科创50/沪深300)
get_sector_performance 获取板块涨跌幅排行
get_market_breadth 获取市场宽度(涨跌家数/涨停跌停/总成交额)
get_north_flow 获取北向资金流向

安装

# 克隆项目
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

添加新工具

  1. 在对应的 *_tools.py 文件中实现工具函数
  2. 在 server.py 中用 @mcp.tool() 装饰器注册
  3. 确保有完整的类型提示和 docstring
  4. 用 py_compile 验证语法

License

MIT

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured