mcp-chinese-holiday
# 🗓️ mcp-chinese-holiday
<div align="center">
[](https://github.com/kyrenbo/mcp-chinese-holiday/actions/workflows/ci.yml)



**中国法定节假日与调休查询 MCP Server**
Chinese statutory holidays & adjusted workdays query server for the [Model Context Protocol](https://modelcontextprotocol.io).
让 AI 助手准确回答"下周五是工作日吗""春节放几天""请 2 天假能连休几天"这类问题——内置官方调休数据,自动处理周末补班日。
[功能](#-功能) · [快速开始](#-快速开始) · [工具列表](#-工具列表) · [English](#english)
</div>
---
## ✨ 功能
- **6 个查询工具**:单日判定、工作日判断、假期倒计时、下一工作日、全年假期、区间工作日统计
- **官方数据**:收录国务院办公厅年度通知的完整放假调休安排(2024-2026),逐条对照原文录入
- **懂调休**:全国独有痛点——春节后的周六要上班、清明节借的周日要还,统统算对
- **容错输入**:`2026-01-01`、`2026/1/1`、`20260101`、`今天`、`明天` 均可解析
- **数据校验**:40+ 单元测试含「调休总账平衡」校验(周内放假日数 − 补班日数必须等于法定假日总数),录入错误直接测试失败
- **纯本地**:无外部 API 依赖,无网络请求,数据内置
## 🚀 快速开始
### 安装
```bash
# 从源码安装(推荐,发布 PyPI 后可用 uvx / pipx)
git clone https://github.com/kyrenbo/mcp-chinese-holiday.git
cd mcp-chinese-holiday
pip install .
```
### MCP 客户端配置
<details open>
<summary><b>Claude Desktop / Qoder</b></summary>
编辑配置文件(macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`;Windows: `%APPDATA%\Claude\claude_desktop_config.json`):
```json
{
"mcpServers": {
"chinese-holiday": {
"command": "python",
"args": ["-m", "chinese_holiday_mcp.server"]
}
}
}
```
</details>
<details>
<summary><b>Cursor / Cline / 其他通用 JSON 配置</b></summary>
```json
{
"mcpServers": {
"chinese-holiday": {
"command": "python",
"args": ["-m", "chinese_holiday_mcp.server"]
}
}
}
```
</details>
### 命令行直接运行
```bash
chinese-holiday-mcp --version # 或 python -m chinese_holiday_mcp.server
```
## 🛠️ 工具列表
| 工具 | 说明 | 示例提问 |
| --- | --- | --- |
| `check_date` | 单日类型判定(工作日/周末/节假日/调休上班日) | "2026-02-28 是什么日子?" |
| `is_workday` | 是否需要上班 | "下周五要上班吗?" |
| `next_holiday` | 距下一个假期还有几天 | "离春节还有多少天?" |
| `next_workday` | 下一个工作日 | "春节后哪天上班?" |
| `get_holidays` | 全年假期安排 | "2026 年春节放几天?" |
| `count_workdays` | 区间实际工作日统计 | "请 3 天假能连休几天?" |
### 对话示例
> **用户**:2026 年春节后第一个周六要不要上班?
>
> **AI**(调用 `is_workday`):要上班。2026-02-28 是周六,但属于「春节调休上班日」——2026 年春节假期为 2 月 15 日至 23 日共 9 天,需在 2 月 14 日和 2 月 28 日两个周六补班。
## 📊 数据来源与更新
| 年份 | 依据 | 状态 |
| --- | --- | --- |
| 2024 | 国办发明电〔2023〕7 号 | ✅ 已收录 |
| 2025 | 国办发明电〔2024〕7 号 | ✅ 已收录 |
| 2026 | [国办发明电〔2025〕7 号](https://m.12371.gov.cn/content/2025-11/04/content_501868.html) | ✅ 已收录 |
- 国务院办公厅通常于每年 **10-11 月**发布次年安排([中国政府网](https://www.gov.cn))
- 更新数据只需修改 `src/chinese_holiday_mcp/data.py`(结构说明见文件头注释),测试套件中的「调休总账」校验会自动检查录入是否自洽
- 欢迎提交 PR 帮助补充新年份数据
## 🧪 开发与测试
```bash
git clone https://github.com/kyrenbo/mcp-chinese-holiday.git
cd mcp-chinese-holiday
pip install -e .[dev]
pytest # 40+ 测试,含数据完整性与调休平衡校验
ruff check . # 代码检查
```
## 🔄 版本历史
详见 [CHANGELOG.md](CHANGELOG.md)。
## 📄 许可证
[MIT](LICENSE)
---
<a id="english"></a>
## English
**mcp-chinese-holiday** is a [Model Context Protocol](https://modelcontextprotocol.io) server that answers Chinese statutory holiday and adjusted-workday questions, so AI assistants can correctly handle China's unique "swap weekends for longer holidays" (调休) system.
### Tools
`check_date` · `is_workday` · `next_holiday` · `next_workday` · `get_holidays` · `count_workdays`
### Why
China's holiday schedule shifts weekends around holidays (e.g., working on a Saturday after Spring Festival). Generic calendar answers are wrong; this server embeds the official annual schedules published by the State Council (2024-2026) and handles all edge cases.
### Data quality
Unit tests enforce an **annual balance invariant**: (weekdays off inside holiday periods) − (compensating weekend workdays) must equal the statutory paid-holiday total (13 days since 2025, 11 before). Data entry mistakes break the build.
### Install
```bash
git clone https://github.com/kyrenbo/mcp-chinese-holiday.git
cd mcp-chinese-holiday && pip install .
```
Then register in your MCP client config:
```json
{ "mcpServers": { "chinese-holiday": { "command": "python", "args": ["-m", "chinese_holiday_mcp.server"] } } }
```
Licensed under MIT.
TDQS
Scored across 6 tools
Most tools target clearly different questions (next holiday, next workday, yearly holiday list, workday counting), but check_date and is_workday overlap heavily: both answer 'what is this date / do I work'. The descriptions differentiate them (full classification vs boolean), but an agent asking 'is 2026-05-01 a workday?' could reasonably pick either.
All names are snake_case and follow a verb/qualifier + noun pattern (next_holiday, get_holidays, count_workdays, check_date, is_workday). The mix of get_/count_/check_/is_/next_ is a minor deviation but remains readable and predictable.
Six tools is a well-scoped size for a holiday-calendar domain, covering lookup, counting, and navigation. One slot (is_workday) is arguably a thinner restatement of check_date, so the set is slightly padded rather than minimal.
Core workflows are covered: yearly holiday data, date classification, workday counting, and forward navigation to the next holiday/workday. Minor gaps exist, such as listing holidays within an arbitrary date range or looking up a holiday by name, but agents can derive these from get_holidays and count_workdays.