a-share-mcp logo

a-share-mcp

Community
firmmaple

本项目是一个基于专注于 A 股市场的 MCP 服务器,它提供股票基本信息、历史 K 线数据、财务指标、宏观经济数据等多种查询功能,理论上来说,可以回答有关 A 股市场的任何问题,无论是针对大盘还是特定股票。

Publisherfirmmaple
Repositorya-share-mcp-server
LanguagePython
Forks
4
Stars
27
Available tools
0
Transport typestdio
Categories
LicenseMIT
Links
  • Connect tools to AI workflows

    a-share-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

    27 stars and 4 forks from the linked repository.

📊 a-share-mcp 📈

License Python Package Manager MCP

本项目是一个基于专注于 A 股市场的 MCP 服务器,它提供股票基本信息、历史 K 线数据、财务指标、宏观经济数据等多种查询功能,理论上来说,可以回答有关 A 股市场的任何问题,无论是针对大盘还是特定股票。

项目结构

a_share_mcp/
│
├── mcp_server.py           # 主服务器入口文件
├── pyproject.toml          # 项目依赖配置
├── README.md               # 项目说明文档
│
├── docs/                   # 项目文档
│   ├── baostock_com.md     # Baostock API文档
│   ├── mcp_server_docs.md  # 服务器文档
│   └── dev_docs/           # 开发文档
│       ├── AppFlow.md
│       ├── ImplementationPlan.md
│       └── PRD.md
│
├── src/                    # 源代码目录
│   ├── __init__.py
│   ├── baostock_data_source.py   # Baostock数据源实现
│   ├── data_source_interface.py  # 数据源接口定义
│   ├── utils.py                  # 通用工具函数
│   │
│   ├── formatting/         # 数据格式化模块
│   │   ├── __init__.py
│   │   └── markdown_formatter.py  # Markdown格式化工具
│   │
│   └── tools/              # MCP工具模块
│       ├── __init__.py
│       ├── base.py                # 基础工具函数
│       ├── stock_market.py        # 股票市场数据工具
│       ├── financial_reports.py   # 财务报表工具
│       ├── indices.py             # 指数相关工具
│       ├── market_overview.py     # 市场概览工具
│       ├── macroeconomic.py       # 宏观经济数据工具
│       ├── technical_indicators.py # 技术指标工具
│       ├── valuation_analysis.py  # 估值分析工具
│       ├── date_utils.py          # 日期工具
│       └── analysis.py            # 分析工具
│
└── resource/               # 资源文件
    └── img/                # 图片资源
        ├── img_1.png       # CherryStudio配置示例
        └── img_2.png       # CherryStudio配置示例

功能特点

系统要求

项目要求说明
Python版本3.10+推荐使用最新稳定版
操作系统Windows/Linux/MacOS全平台支持
数据源Baostock (免费)无需付费API,感谢Baostock
可选依赖pandas-ta用于高级技术指标计算
内存要求推荐2GB+用于大数据量处理

数据更新时间

以下是 Baostock 官方数据更新时间,请注意查询最新数据时的时间点 Baostock 官网

每日数据更新时间:

  • 当前交易日 17:30,完成日 K 线数据入库
  • 当前交易日 18:00,完成复权因子数据入库
  • 第二自然日 11:00,完成分钟 K 线数据入库
  • 第二自然日 1:30,完成前交易日"其它财务报告数据"入库
  • 周六 17:30,完成周线数据入库

每周数据更新时间:

  • 每周一下午,完成上证 50 成份股、沪深 300 成份股、中证 500 成份股信息数据入库

所以说,在交易日的当天,如果是在 17:30 之前询问当天的数据,是无法获取到的。

快速开始

1. 环境要求

  • Python 3.10 或更高版本
  • pip 包管理器

2. 安装依赖

在项目根目录下执行:

bash
# 克隆项目
git clone https://github.com/firmmaple/a-share-mcp-server.git
cd a-share-mcp-server
bash
# 安装基础依赖
pip install -r requirements.txt
bash
# 可选:安装技术指标分析库(用于高级技术指标计算)
pip install pandas-ta

3. 运行服务器

bash
python mcp_server.py

服务器启动后,将在端口3000上运行,并支持MCP协议连接。

4. 配置AI助手

将以下配置添加到您的AI助手(如Claude Desktop、CherryStudio等)的MCP配置中:

json
{
  "mcpServers": {
    "a-share-mcp": {
      "command": "python",
      "args": ["path/to/your/mcp_server.py"],
      "cwd": "path/to/your/project"
    }
  }
}

工具列表

该 MCP 服务器提供以下工具:

MCP工具接口说明

本服务器通过MCP协议向AI助手提供A股数据查询工具。

📚 完整接口文档

详细的工具接口说明请参考:DOCUMENTS.md

该文档包含:

  • 🔧 所有工具函数的详细参数说明
  • 📝 输入输出格式规范
  • 💡 使用示例和最佳实践
  • 🏗️ 各模块功能架构说明

🚀 快速接口预览

python
# 基础数据查询
get_stock_basic_info(code="sh.600519")
get_historical_k_data(code="sz.000001", start_date="2024-01-01", end_date="2024-01-31")

# 财务分析
get_profit_data(code="sz.002594", year="2023", quarter="4")
get_balance_data(code="sz.002594", year="2023", quarter="4")

# 技术指标
get_technical_indicators(code="sz.300750", start_date="2024-01-01", end_date="2024-01-31")
calculate_risk_metrics(code="sh.600519", period="1Y")

# 估值分析
get_valuation_metrics(code="sz.000858")
calculate_dcf_valuation(code="sh.600519", years_back=5)
calculate_ddm_valuation(code="sh.600000", discount_rate=0.10)

# 市场数据
get_all_stock()
get_hs300_stocks()
get_trade_dates(start_date="2024-01-01", end_date="2024-12-31")

# 宏观经济
get_deposit_rate_data()
get_shibor_data(start_date="2024-01-01", end_date="2024-12-31")

功能亮点

  • 🚀 零配置启动:基于免费Baostock数据源,无需付费API
  • 🎯 AI原生设计:专为AI助手优化的查询接口和数据格式
  • 📊 全面数据覆盖:涵盖基本面、技术面、宏观面等9大维度
  • ⚡ 实时更新:支持最新交易日数据查询
  • 🔧 模块化架构:易于扩展和定制化开发

贡献指南

欢迎提交 Issue 或 Pull Request 来帮助改进项目。贡献前请先查看现有 Issue 和文档。

许可证

本项目采用 MIT 许可证 - 详情请查看 LICENSE 文件

Installation

TypingMind
{
  "mcpServers": {
    "a-share-mcp-server": {
      "command": "python",
      "args": [
        "path/to/your/mcp_server.py"
      ]
    }
  }
}

Use a-share-mcp MCP with multiple AI models

TypingMind connects MCP tools at the workspace level, so once a-share-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 a-share-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 a-share-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": {
    "a-share-mcp-server": {
      "command": "npx",
      "args": [
        "-y",
        "<mcp-server-package>"
      ]
    }
  }
}
4

Use it across models

Save the server list, open Plugins, enable the a-share-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 a-share-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 a-share-mcp to help me with this task?
a-share-mcp
Sure. I read it.
Here is what I found using a-share-mcp.

Frequently asked questions

What is the a-share-mcp MCP server used for?

a-share-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 a-share-mcp MCP with multiple AI models in TypingMind?

Yes. TypingMind connects MCP tools at the workspace level, so you can use a-share-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 a-share-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 a-share-mcp connected, you can use its MCP tools across your preferred models while keeping your chat workflow organized in TypingMind.

How do I connect a-share-mcp MCP to TypingMind?

a-share-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 a-share-mcp MCP provide in TypingMind?

a-share-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 a-share-mcp MCP?

No. TypingMind is local-first and lets you keep your model providers, API keys, prompts, and MCP configuration under your control. If a-share-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 👇