Cn Financial MCP logo

Cn Financial MCP

Community
ccq1

cn金融数据 MCP 服务器 — 工具包覆盖 A 股行情、财报、估值、板块、市场全景、新闻及宏观指标。

Publisherccq1
Repositorycn-financial-mcp
LanguagePython
Forks
20
Stars
45
Available tools
0
Transport typestdio
LicenseApache-2.0
Links
  • Connect tools to AI workflows

    Cn Financial MCP exposes MCP capabilities that can be used by compatible AI clients and agents.

  • 0 available tools

    Browse the callable actions below, including names and descriptions when provided by the server.

  • Ready-to-copy setup

    Use the installation snippets to configure this server in your preferred MCP client.

  • Open source signals

    45 stars and 20 forks from the linked repository.

cn-financial-mcp


📸 Demo

在 Claude Code 中通过 MCP 工具查询中国西电的盘口走势以及投研分析


简介

cn-financial-mcp 是一个遵循 Model Context Protocol (MCP) 标准的金融数据服务器,专注于cn大陆市场。它让任何支持 MCP 的 AI Agent(如 Claude Code、Cursor、自定义 Agent)都能直接调用 A 股行情、财报、行业、宏观经济等 42 个金融工具,无需 API Key,开箱即用。

底层数据来源于 AKShare,并内置多数据源自动 fallback 机制(东方财富 → 新浪 / 腾讯 / 同花顺),确保在不同网络环境下的可用性。


✨ 功能一览

模块工具数说明
公司信息4股票搜索、公司概况、主营构成、竞争对手
行情数据4实时行情、历史 K 线(日/周/月)、市值、股票列表
财务报表8利润表、资产负债表、现金流量表、财务指标、增长率、分部收入
估值分析4PE/PB/PS 时序、分红历史、机构持仓、分析师评级
行业板块5行业列表、成分股、概念板块、板块资金流、行业估值
市场总览5指数概览、个股资金流、北向资金、涨跌停池、龙虎榜
新闻公告4个股新闻、财报日历、公司公告、关键词搜索
宏观与衍生8GDP/CPI/PMI/M2、汇率、国债收益率、融资融券、高管增减持

合计 42 个工具,覆盖从个股研究到宏观分析的完整链路。


🚀 快速开始

环境要求

  • Python 3.10+
  • pip

安装

bash
git clone https://github.com/<your-username>/cn-financial-mcp.git
cd cn-financial-mcp
pip install -e .

验证安装

bash
PYTHONPATH=src python -m cn_financial_mcp --help
usage: __main__.py [-h] [--http] [--port PORT] [--host HOST]

cn-financial-mcp: China Financial Data MCP Server based on AKShare

options:
  -h, --help   show this help message and exit
  --http       Run in HTTP/SSE mode instead of stdio
  --port PORT  Port for HTTP/SSE mode (default: 8000)
  --host HOST  Host for HTTP/SSE mode (default: 127.0.0.1)

📡 部署方式

方式一:stdio 模式(Claude Code / Cursor)

在你的项目根目录 .mcp.json 中添加:

json
{
  "mcpServers": {
    "cn-financial": {
      "type": "stdio",
      "command": "python",
      "args": ["-m", "cn_financial_mcp"],
      "env": {
        "PYTHONPATH": "/absolute/path/to/cn-financial-mcp/src"
      }
    }
  }
}

将 /absolute/path/to/cn-financial-mcp 替换为你的实际路径。配置好后 Agent 会自动拉起 MCP 进程。

方式二:HTTP/SSE 模式(通用 MCP Client)

bash
cd cn-financial-mcp
PYTHONPATH=src python -m cn_financial_mcp --http --host 0.0.0.0 --port 8000

MCP Client 连接 endpoint:

http://<your-ip>:8000/sse

方式三:Docker

bash
cd cn-financial-mcp
docker compose up -d

服务暴露在 http://localhost:8000。


🛠 工具清单

工具说明
search_stock按名称/代码模糊搜索 A 股
get_company_info获取公司基本信息(行业、市值、股本)
get_company_profile获取主营业务构成及收入占比
get_competitors获取同行业竞争对手列表
工具说明
get_realtime_quote获取实时行情(最新价、涨跌幅、成交量)
get_historical_price获取历史 K 线(日/周/月,支持前复权/后复权)
get_market_capitalization获取总市值与流通市值
get_stock_list获取 A 股完整列表,支持市值筛选
工具说明
get_income_statement利润表
get_balance_sheet资产负债表
get_cash_flow_statement现金流量表
get_financial_line_item自定义查询单项科目
get_financial_indicators综合财务指标(ROE、毛利率等)
get_growth_rates营收/利润增长率
get_per_share_data每股指标(EPS、BPS等)
get_segments_revenue分部收入明细
工具说明
get_valuation_metricsPE/PB/PS 历史时序
get_dividend_data分红派息历史
get_institutional_holdings十大流通股东
get_analyst_rating分析师评级与盈利预测
工具说明
get_industry_list行业板块列表
get_industry_stocks行业成分股
get_concept_list概念板块列表
get_sector_fund_flow板块资金流向排名
get_industry_pe行业历史行情走势
工具说明
get_market_overview主要指数实时快照
get_money_flow个股资金流向
get_north_bound_flow北向资金(沪深港通)净流入
get_limit_up_down当日涨停/跌停池
get_dragon_tiger龙虎榜(机构活跃交易)
工具说明
get_stock_news个股新闻资讯
get_financial_calendar财报披露时间表
get_company_announcements上市公司公告
search_news按关键词搜索新闻
工具说明
get_macro_gdpGDP 数据
get_macro_cpiCPI 数据
get_macro_pmiPMI 数据
get_macro_money_supply货币供应量(M0/M1/M2)
get_fx_rate汇率查询
get_bond_yield_curve国债收益率曲线
get_margin_trading融资融券数据
get_insider_trading高管增减持

🔄 多数据源 Fallback

为应对部分数据源在云服务器环境下不稳定的问题,内置了自动多源切换:

请求 → 东方财富 (优先,字段最全)
         ↓ 失败
       新浪 / 腾讯 / 同花顺 (备选)
         ↓ 失败
       返回错误
功能主源备选源
实时行情东方财富新浪 → 新浪单股
历史 K 线东方财富腾讯
行业板块东方财富同花顺
概念板块东方财富同花顺
公司信息东方财富 emweb新浪

代码始终优先尝试东方财富。只有当主源连接失败时才自动切换,对调用方完全透明。


🧪 测试

bash
# 安装开发依赖
pip install -e ".[dev]"

# 运行单元测试
pytest tests/ -v

# 仅运行网络无关测试
pytest tests/ -v -m "not network"

📁 项目结构

cn-financial-mcp/
├── src/cn_financial_mcp/
│   ├── __init__.py
│   ├── __main__.py          # CLI 入口
│   ├── server.py             # MCP Server 实例
│   ├── tools/
│   │   ├── company_info.py   # 公司信息 (4 tools)
│   │   ├── price_data.py     # 行情数据 (4 tools)
│   │   ├── financial_stmt.py # 财务报表 (8 tools)
│   │   ├── valuation.py      # 估值分析 (4 tools)
│   │   ├── industry.py       # 行业板块 (5 tools)
│   │   ├── market.py         # 市场总览 (5 tools)
│   │   ├── news_events.py    # 新闻公告 (4 tools)
│   │   └── macro_fx.py       # 宏观衍生 (8 tools)
│   └── utils/
│       ├── cache.py          # TTL 缓存
│       ├── fallback.py       # 多源 fallback
│       ├── formatter.py      # DataFrame → JSON
│       └── symbol.py         # 股票代码工具
├── tests/
├── docs/images/
├── pyproject.toml
├── Dockerfile
├── docker-compose.yml
└── .mcp.json

📄 License

Apache-2.0


🙏 致谢

  • AKShare — 开源金融数据接口库

Use Cn Financial MCP MCP with multiple AI models

TypingMind connects MCP tools at the workspace level, so once Cn Financial MCP is connected, you can use it with different AI models in TypingMind instead of setting it up separately for each model. This MCP runs locally through the TypingMind MCP connector on your device.

Setup guide to use the local connector

Use this when the MCP server needs access to local files, apps, or private resources on your computer.

1

Open the MCP settings

In TypingMind, go to Settings, Advanced Settings, then Model Context Protocol and choose Setup Connector.

  1. Open TypingMind in your browser.
  2. Click the Settings icon.
  3. Go to Advanced Settings.
  4. Open the Model Context Protocol section.
  5. Click Setup Connector and choose This Device.
TypingMind MCP connector setup screen with This Device selected
2

Run the connector command

Choose This Device, copy the command from TypingMind, and run it in Terminal. Keep the process running while you use MCP.

  1. Copy the setup command shown by TypingMind.
  2. Open Terminal on macOS or Windows Terminal on Windows.
  3. Paste and run the command.
  4. Approve the package install if Terminal asks you to proceed.
  5. Keep the Terminal window running while using MCP tools.
3

Add Cn Financial MCP as a server

When the connector status is Ready, click Edit Servers and paste the MCP server configuration.

  1. Wait until the connector status shows Ready.
  2. Click Edit Servers.
  3. Paste the Cn Financial MCP MCP server configuration.
  4. Save the server list.
  5. Refresh if you want to confirm the connector is still ready.
TypingMind MCP settings showing active server and Edit Servers button
{
  "mcpServers": {
    "cn-financial-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "<mcp-server-package>"
      ]
    }
  }
}
4

Use it across models

Save the server list, open Plugins, enable the Cn Financial MCP MCP tools, then select any supported AI model in TypingMind and use the tools in chat or assign them to an AI agent.

  1. Open the Plugins page in TypingMind.
  2. Enable the Cn Financial MCP MCP tools.
  3. Start a chat and choose the AI model you want to use.
  4. Use the MCP tools in chat or assign them to an AI agent.
  5. Switch to another AI model whenever needed without reconnecting MCP.
TypingMind chat using enabled MCP tools with a selected AI model
Can you use Cn Financial MCP to help me with this task?
Cn Financial MCP
Sure. I read it.
Here is what I found using Cn Financial MCP.

Frequently asked questions

What is the Cn Financial MCP MCP server used for?

Cn Financial MCP is an MCP server that lets compatible AI clients connect to external tools and context. In TypingMind, you can add this MCP server once and make its tools available in your AI workspace.

Can I use Cn Financial MCP MCP with multiple AI models in TypingMind?

Yes. TypingMind connects MCP tools at the workspace level, so you can use Cn Financial MCP with different AI models such as Claude, ChatGPT, Gemini, or other models you have configured in TypingMind without setting up the MCP server separately for each model.

Why use Cn Financial MCP MCP with TypingMind?

TypingMind is one of the best frontends for LLM chat because it brings multiple AI models, prompts, plugins, AI agents, API keys, and MCP tools into one workspace. With Cn Financial MCP connected, you can use its MCP tools across your preferred models while keeping your chat workflow organized in TypingMind.

How do I connect Cn Financial MCP MCP to TypingMind?

Cn Financial MCP runs through the TypingMind local MCP connector. This is best when the MCP server needs access to local files, desktop apps, command-line tools, or private resources on your computer.

What tools does Cn Financial MCP MCP provide in TypingMind?

Cn Financial MCP exposes MCP capabilities that can be enabled from the TypingMind Plugins page and used in chat or assigned to AI agents.

Do I need to share my API keys with TypingMind to use Cn Financial MCP MCP?

No. TypingMind is local-first and lets you keep your model providers, API keys, prompts, and MCP configuration under your control. If Cn Financial MCP requires authentication, add the required headers, OAuth settings, or local configuration for that MCP server when you create the connection.

Related MCP Servers

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇