cn-mcp-kit
# cn-mcp-kit 中文工具箱 MCP
> 让 AI 助手(Claude / WorkBuddy / 任何支持 MCP 的客户端)直接调用中文场景实用工具的 MCP 服务器。
> 自带真实时钟,让 AI 不再把"刚刚"说成"昨天"。


## 🧰 提供的工具(11 个)
### 时间
| 工具 | 功能 |
| --- | --- |
| `current_time` | 当前真实时间、时区,以及今天 / 昨天 / 明天的日期 |
| `time_diff` | 某个时间点是"39 分钟前,属于今天"还是"昨天 / 前天 / n 天前" |
大模型没有时钟,容易在时间上出错。这两个工具给它一个真的钟,并在描述里要求 AI 先查再说。
### 数字与文本
| 工具 | 功能 |
| --- | --- |
| `amount_to_chinese` | 数字金额 → 人民币大写,支持负数(1234.56 → 壹仟贰佰叁拾肆元伍角陆分) |
| `number_to_chinese` | 阿拉伯数字 → 中文读法(35000 → 三万五千,可输出大写) |
| `cn_number_parse` | 中文数字 → 阿拉伯数字,支持大写、繁体、年份读法(二〇二六 → 2026) |
| `text_statistics` | 字数 / 字符数 / 汉字 / 字母 / 数字 / 标点 / 行数 / 段落数,字数口径与 Word 一致 |
| `fullwidth_convert` | 全角 ↔ 半角转换(Hello123 → Hello123) |
### 日历与中文
| 工具 | 功能 |
| --- | --- |
| `lunar_date` | 公历 → 农历、生肖、干支、节气、节日、星座;不传日期默认今天 |
| `hanzi_pinyin` | 汉字转拼音,支持多音字 |
| `s2t_convert` | 简体 ↔ 繁体转换 |
| `idcard_validate` | 身份证号校验(校验位 + 出生日期真实性),返回年龄、性别、地区码 |
## 🚀 快速开始
需要 Node.js 18 或更高版本。
```bash
npm install
npm test # 117 个测试
```
在 MCP 客户端(如 WorkBuddy、Claude Desktop)的配置文件中加入:
```json
{
"mcpServers": {
"cn-mcp-kit": {
"command": "node",
"args": ["<项目路径>/src/index.js"]
}
}
}
```
## 💡 设计原则
1. **给 AI 真实的数据源,而不是让它猜。** 时间、农历这类会变的事实,由工具现场计算。
2. **看不懂就说看不懂。** 所有工具遇到无法识别的输入都明确返回"无法解析 / 不存在",绝不返回一个看起来对、实际错的值。
3. **一个工具一个文件。** `src/tools/` 下每个文件只导出一个 `register(server)`,互不依赖,哪个工具出问题就看哪个文件。
4. **先测再交。** 每个纯算法工具都有测试,`npm test` 一键回归。
## 📁 目录结构
```
cn-mcp-kit/
├── src/
│ ├── index.js # 服务器入口:注册所有工具
│ └── tools/ # 每个工具一个文件
├── tests/ # 自动化测试(node:test)
├── docs/ # 项目规划、添加新工具教程
├── CONTRIBUTING.md # 贡献指南
├── LICENSE # MIT
└── README.md
```
## 🤝 添加新工具
在 `src/tools/` 下新建一个 js 文件,导出 `register(server)` 函数,
再到 `src/index.js` 注册、到 `tests/` 补测试。详见 [docs/02-如何添加新工具.md](docs/02-如何添加新工具.md)。
欢迎提 PR,规范见 [CONTRIBUTING.md](CONTRIBUTING.md)。
## 📄 License
MIT
TDQS
Scored across 11 tools
Most tools target clearly distinct tasks (pinyin, ID card, lunar date, fullwidth, text stats), so selection is generally easy. The only real overlap is among the three number tools: amount_to_chinese vs number_to_chinese both convert numbers to Chinese characters (currency uppercase vs. plain reading with optional uppercase), which could cause misselection for values like 1234.56; descriptions help but do not fully separate them.
All names are snake_case and readable, but the convention is mixed: verb_noun (validate-style) appears as noun_verb in idcard_validate, hanzi_pinyin, text_statistics, fullwidth_convert, and as bare noun phrases in lunar_date, current_time, time_diff, plus an odd prefixed form cn_number_parse.
11 tools for a Chinese-locale utility kit is well within the sweet spot, and each tool maps to a distinct, useful operation without filler. The three number-conversion tools are individually justified by different output formats (currency uppercase, reading, parsing).
Coverage is broad for a locale toolkit (numbers, dates, conversion, validation, stats), but some operations are one-way: lunar_date only converts Gregorian to lunar with no reverse, and there is no parser for RMB uppercase amounts back to numbers. These gaps are minor and agents can work around them with the existing parse/convert tools.