npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@wenbochang888/mcp-identity-service

v1.0.0

Published

MCP 服务:中国身份证号生成、验证和解析

Readme

mcp-identity-service

一个基于 Model Context Protocol (MCP) 的中国身份证号生成、验证和解析服务。

功能特性

  • 生成身份证号: 根据姓名生成符合 GB 11643-1999 标准的18位身份证号
  • 验证身份证号: 验证身份证号格式和校验码是否正确
  • 解析身份证号: 提取行政区划、出生日期、年龄、性别等信息
  • 生成三要素: 随机生成姓名 + 身份证号 + 手机号
  • 生成四要素: 在三要素基础上增加银行卡号

安装使用

方式 1: 通过 npm 使用(推荐)

~/.cursor/mcp.json 中配置:

{
  "mcpServers": {
    "identity-service": {
      "command": "npx",
      "args": ["-y", "@wenbochang888/mcp-identity-service"]
    }
  }
}

重启 Cursor,然后在 AI 对话中使用:

请帮我生成一个姓名为"张三"的身份证号
验证这个身份证号是否合法: 110105194912310020
解析这个身份证号的信息: 11010519491231002X

方式 2: 本地开发使用

# 克隆项目
git clone https://github.com/wenbochang888/mcp-identity-service.git
cd mcp-identity-service

# 安装依赖
npm install

# 构建项目
npm run build

# 运行测试
npm test

# 在 Cursor 配置中使用本地路径
{
  "mcpServers": {
    "identity-service": {
      "command": "node",
      "args": ["/path/to/mcp-identity-service/build/index.js"]
    }
  }
}

方式 3: SSE 远程部署

适用于在服务器上运行并通过 HTTP + SSE 方式连接:

# 启动 SSE 服务
PORT=6868 HOST=0.0.0.0 SSE=true node build/index.js

~/.cursor/mcp.json 中配置:

{
  "mcpServers": {
    "identity-service-sse": {
      "type": "sse",
      "url": "http://<your-host>:6868/sse"
    }
  }
}

环境变量:

  • PORT: 监听端口(默认 6868)
  • HOST: 监听地址(默认 0.0.0.0)
  • SSE: 启用 SSE 模式(设置为 true)
  • SSE_PATH: SSE 订阅路径(默认 /sse)
  • SSE_POST_PATH: 客户端 POST 路径(默认 /messages)

健康检查:

curl http://<your-host>:6868/health

MCP 工具列表

1. generate_id_card

生成符合规范的中国18位身份证号码。

参数:

  • name (string, 必填): 姓名
  • startYear (number, 可选): 出生年份起始范围,默认1970
  • endYear (number, 可选): 出生年份结束范围,默认2010
  • areaCode (string, 可选): 指定6位行政区划代码

示例返回:

{
  "success": true,
  "name": "张三",
  "idCard": "11000019950615321X",
  "info": {
    "areaCode": "110000",
    "birthDate": "1995-06-15",
    "age": 29,
    "gender": "女"
  }
}

2. validate_id_card

验证中国身份证号是否合法。

参数:

  • idCard (string, 必填): 18位身份证号

示例返回:

{
  "success": true,
  "idCard": "11010519491231002X",
  "valid": true,
  "message": "身份证号格式正确,校验码验证通过"
}

3. parse_id_card

解析身份证号,提取详细信息。

参数:

  • idCard (string, 必填): 18位身份证号

示例返回:

{
  "success": true,
  "idCard": "11010519491231002X",
  "info": {
    "areaCode": "110105",
    "areaProvince": "北京市",
    "areaCity": "北京市",
    "areaDistrict": "朝阳区",
    "birthDate": "1949-12-31",
    "age": 75,
    "gender": "女",
    "checkCode": "X"
  }
}

4. getThreeElements

生成随机姓名 + 身份证号 + 手机号。

参数: 无

示例返回:

{
  "success": true,
  "name": "韩榕乐",
  "idCard": "210102198905199442",
  "phone": "13823815272"
}

5. getFourElements

在三要素基础上增加银行卡号(16~19位)。

参数: 无

示例返回:

{
  "success": true,
  "name": "韩榕乐",
  "idCard": "210102198905199442",
  "phone": "13823815272",
  "bankCard": "6222021234567890123"
}

身份证号格式说明

18位身份证号格式: AAAAAAYYYYMMDDXXXC

  • AAAAAA (前6位): 行政区划代码
  • YYYYMMDD (中间8位): 出生日期
  • XXX (接下来3位): 顺序码(奇数为男性,偶数为女性)
  • C (最后1位): 校验码(根据ISO 7064:1983.MOD 11-2算法计算)

技术细节

  • 完全符合 GB 11643-1999 公民身份号码标准
  • 支持中国所有省级行政区划代码(31个省/直辖市/自治区)
  • 自动处理闰年和各月天数
  • 使用 ISO 7064:1983.MOD 11-2 校验算法

开发

# 安装依赖
npm install

# 构建项目
npm run build

# 开发模式(监听文件变化)
npm run watch

# 运行测试
npm test

注意事项

⚠️ 免责声明:

  • 本工具生成的身份证号仅供开发、测试使用
  • 生成的身份证号是随机的,不对应真实个人信息
  • 请勿将生成的身份证号用于任何非法用途
  • 使用本工具产生的任何后果由使用者自行承担

许可证

MIT License - 详见 LICENSE 文件

参考标准

  • GB 11643-1999: 公民身份号码
  • ISO 7064:1983.MOD 11-2: 校验字符系统