cn-law-mcp
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
cn-law-mcp
让 Claude、Cursor、Cherry Studio 通过 MCP 检索中国法条。零 API key 可用,每条结果都带国家法律法规数据库的官方检索链接。

15 秒开始
先自检:
uvx --from git+https://github.com/2598389291-beep/cn-law-mcp cn-law-mcp --selftest
# 108 条法条索引加载成功把下面配置加入 MCP 客户端:
{
"mcpServers": {
"cn-law-mcp": {
"command": "uvx",
"args": [
"--from",
"git+https://github.com/2598389291-beep/cn-law-mcp",
"cn-law-mcp"
]
}
}
}然后直接问:
网购七天无理由退货是第几条?
预期返回《消费者权益保护法》第 25 条、条文原文、关键词和 flk.npc.gov.cn 官方检索链接。
Related MCP server: chinese-law-mcp
提供的三个工具
工具 | 适用时机 | 返回 |
| 已知问题,但不知道对应哪条法律 |
|
| 已知准确法律名和条号 | 一条法条;不存在时返回明确提示 |
| 模型准备引用法条,或需要验证一段文字 | 逐条返回 |
工具参数和输出字段都带中文 schema 描述,模型可以根据“查法条、精确取条、核验引用”三种意图自行选择。
所有可预期错误统一为:
{
"error": "未找到《消费者权益保护法》第999条",
"hint": "请先用 search_law 确认法律名和条款号;本地索引只覆盖 108 条法条"
}安装
用 uvx 运行,不污染全局环境:
uvx --from git+https://github.com/2598389291-beep/cn-law-mcp cn-law-mcp或安装后作为命令行 MCP server 运行:
pip install "git+https://github.com/2598389291-beep/cn-law-mcp.git"
cn-law-mcp
cn-law-mcp --selftest索引会在第一次启动时自动构建并写入系统缓存。缓存以法条数据的 SHA-256 为键,数据更新后不会误用旧索引。
为什么不是把法条直接塞进 prompt
法条不应该由模型背。 直接塞入 prompt 只能约束当前上下文,换个会话或换一个模型仍可能生成看似合理但不存在的条号。
按需取条更省 token。 用户问退款时,没必要把 108 条法条全部发送给模型;检索层只返回最相关的几条。
结果可以核对。 每条结果都带官方检索链接,用户能离开聊天窗口自行确认,而不是只能相信模型。
更新边界清楚。 数据文件、索引和引用核验都来自同一份固定语料,法律文本更新时可以重新同步并留下 diff。
默认检索使用字符 2/3-gram + BM25,中文不依赖分词器,离线也可运行。
可选 embedding
只有同时配置 endpoint 和 model 才会启用向量召回;未配置时不会发起任何网络请求。API key 可选,适合本地 OpenAI 兼容服务。
export CN_LAW_MCP_EMBEDDING_URL="http://127.0.0.1:8000/v1/embeddings"
export CN_LAW_MCP_EMBEDDING_MODEL="your-embedding-model"
# 需要鉴权时再设置:
export CN_LAW_MCP_EMBEDDING_API_KEY="..."向量请求失败或向量维度不一致时会自动退回 BM25,不会让服务启动失败。
自定义缓存目录:
export CN_LAW_MCP_CACHE_DIR="/path/to/cache"数据来源与边界
法条语料只有 108 条 / 20 部法律,原样复制自
yanquan/backend/services/law_seed.py。法条原文来源标注为国家法律法规数据库
flk.npc.gov.cn;本工具生成的是按法律名查询的官方检索页链接,不是每部法律的固定详情页。本仓库没有使用模型生成、补写、润色或改写任何法条原文。数据文件的 SHA-256 由测试锁定。
cite_check只核验本地 108 条白名单。not_found表示白名单中没有该条,unverifiable表示该法律不在本地语料中;两者都不是对现行法效力的司法结论。这是一个检索与引用核验工具,不构成法律意见。
开发与验收
uv sync --all-extras
uv run ruff check .
uv run pytest -q
uv run python scripts/smoke.py
uvx --from . cn-law-mcp --selftestscripts/smoke.py 会真正启动 stdio MCP 子进程,完成初始化、列出工具并检索《消费者权益保护法》第 25 条。GitHub Actions 在每次 push 和 pull request 时执行 lint、单测和这条 smoke test。
关键设计决定和验证方式记录在 DECISIONS.md。
许可证
代码使用 MIT License。MCP 服务结构参考 mazulo/leis-mcp (MIT),完整声明见 NOTICE。
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
MCP server for Chinese law lookup: statutes, regulations and articles by keyword or law name.
Taiwan legal research MCP by Dr.Legal (法律偵探): 22.7M court judgments, current statutes, administrative rulings and Constitutional Court decisions. Retrieval-only, per-item citations, appeal-chain history, bundle-level citation audit. Free, no API key; OAuth 2.0 dynamic registration completes automatically. 台灣法律 MCP:2,272 萬筆裁判書、法規、函釋、憲法法庭裁判,逐筆附出處並提供引用查核。免費、免金鑰。Docs: https://dr-legal.com.tw/mcp
Search your AI chat history (ChatGPT, Claude, Codex) from any MCP client. Remote, private, read-only
中文法律 MCP 服务:47,606 条法规与 11,369 条案例,提供法规检索、法条详情、法律问答、法律咨询与多轮追问。
Related MCP Servers
- AlicenseAqualityCmaintenanceEnables real-time retrieval of authoritative Chinese government policies and verification of law article citations (《法名》第X条) via public sources, with no API key required.6MIT
- AlicenseNot gradedqualityBmaintenanceMCP server for Chinese statutes: search 500+ Chinese statutes, judicial interpretations and administrative regulations in force and fetch any article verbatim, with citable source links.33MIT
- AlicenseAqualityBmaintenanceEnables LLMs to search Chinese statutes and verify legal citations locally, including detecting fabricated references in generated text. It supports natural-language queries, article lookup, and citation validation without registration, API keys, or network access.59MIT
- AlicenseAqualityCmaintenanceEnables MCP clients such as Claude to look up Korean statutes, individual articles, annexes, amendment history, precedents, and interpretive rulings from the Ministry of Government Legislation's national law information open API, and to run guided research scenarios, citation audits, contract risk scans, and citation tracing — all read-only. Supports both a hosted HTTP endpoint with per-user tokens and a local stdio installation using your own API key.121MIT