canlii-mcp
CanLII MCP 服务器
一个用于通过 CanLII API 搜索加拿大法律信息的 模型上下文协议 (MCP) 服务器。在 Claude Desktop 或 Claude Code 中搜索案例、浏览法规并检查引文。
npx canlii-mcp功能
全文搜索 — 通过关键词、案例名称或法律概念搜索整个 CanLII 数据库
案例引文分析 — 通过查找后续引用案例来检查案例是否仍然有效
法规浏览 — 按司法管辖区浏览成文法和法规
双语支持 — 所有工具(包括引文分析器)均支持英语和法语
9 个工具 — 搜索、浏览法院、浏览案例、案例元数据、完整引文分析、引文预览、法规数据库、浏览法规、法规元数据
内置速率限制 — 序列化请求队列遵循 CanLII 的 API 限制(2 次请求/秒,1 个并发,5,000 次/天)
输入验证 — 所有参数均经过正则表达式验证和 URI 编码,以防止注入
极简占用 — 仅 2 个运行时依赖,约 500 行代码,作为 stdio 进程在本地运行
安全优先 — 无文件系统访问权限,无 shell 执行权限,仅连接至
api.canlii.org
Related MCP server: canlii-mcp
快速入门
先决条件: Node.js 18+ 和一个 CanLII API 密钥(研究用途免费)。
Claude Desktop — 添加到您的配置中(macOS 上位于 ~/Library/Application Support/Claude/claude_desktop_config.json):
{
"mcpServers": {
"canlii": {
"command": "npx",
"args": ["-y", "canlii-mcp"],
"env": {
"CANLII_API_KEY": "your_api_key_here"
}
}
}
}保存后重启 Claude Desktop。
Claude Code:
claude mcp add canlii -e CANLII_API_KEY=your_key -- npx -y canlii-mcp从源码安装(用于开发):
git clone https://github.com/mohammadfarooqi/canlii-mcp.git
cd canlii-mcp
npm install && npm run build可用工具 (9)
search
在整个 CanLII(案例、法规和评论)中进行全文关键词搜索。这是法律研究的主要入口。
search({ query: "material change in circumstances Ontario", resultCount: 10 })get_courts_and_tribunals
列出所有可用的法院和法庭数据库。返回其他工具所需的数据库 ID。
安大略省主要数据库:onsc(高等法院)、onca(上诉法院)、oncj(司法法院)、csc-scc(加拿大最高法院)。
get_case_law_decisions
浏览特定法院数据库中的判例法,按最新添加顺序排列。支持日期筛选。
get_case_law_decisions({ databaseId: "onsc", resultCount: 20 })get_case_metadata
获取特定案例的详细信息——引文、判决日期、案卷号、关键词以及用于阅读完整判决的 CanLII URL。
get_case_metadata({ databaseId: "onsc", caseId: "2021onsc8582" })get_case_citator
查找案例的引文关系。使用 citingCases 检查案例是否仍然有效。
get_case_citator({ databaseId: "csc-scc", caseId: "1996canlii190", metadataType: "citingCases" })get_case_citator_tease
快速引文预览,最多返回 5 个结果。比完整引文分析器更快,适合快速检查。
get_case_citator_tease({ databaseId: "csc-scc", caseId: "1996canlii190", metadataType: "citingCases" })get_legislation_databases
列出所有法规数据库。安大略省:ons(成文法)、onr(法规)。联邦:cas(成文法)、car(法规)。
browse_legislation
列出特定数据库中的法规条目。
browse_legislation({ databaseId: "ons" })get_legislation_regulation_metadata
获取特定成文法或法规的元数据,包括其 CanLII URL。
典型研究工作流程
搜索 —
search({ query: "gatekeeping parenting time" })以查找相关案例获取详情 —
get_case_metadata(...)以获取完整引文和 CanLII URL检查引文 —
get_case_citator(..., metadataType: "citingCases")以验证案例是否仍然有效阅读判决 — 点击 CanLII URL 在 canlii.org 上阅读全文
API 速率限制
根据 CanLII 的 API 条款:
每天 5,000 次查询
每秒 2 次请求
一次 1 个请求
仅限访问元数据 — API 不提供完整文档文本
服务器通过内置的速率限制器自动强制执行这些限制。
开发
npm run build # Compile TypeScript
npm run start # Run the server (needs CANLII_API_KEY env var)项目结构
src/
index.ts # MCP server — tools, rate limiter, stdio transport
schema.ts # Zod schemas for CanLII API responses贡献
欢迎贡献!本项目旨在通过 AI 工具使加拿大法律研究更加便捷。
贡献方式:
提交 PR:
Fork 本仓库
创建功能分支 (
git checkout -b feature/my-improvement)进行更改并在本地测试 (
npm run build && CANLII_API_KEY=your_key npm run start)提交并推送到您的 fork
提交拉取请求,并描述更改内容及原因
如果您发现 CanLII API 响应、模式不匹配的问题,或者有任何有助于法律研究人员的新工具想法,请提交 issue — 即使您不确定如何修复它。我们将共同调查。
安全性
本服务器设计为透明且极简:
仅连接至
api.canlii.org— 无其他网络调用,无遥测,无分析API 密钥保留在本地 — 通过环境变量传递,从不记录或包含在响应中
所有输入均经过验证 — 数据库 ID、案例 ID 和日期在使用前均经过正则表达式验证;路径段经过 URI 编码
所有 API 响应均经过验证 — 在返回前通过 Zod 模式解析
无文件系统访问权限 — 服务器仅向 CanLII 发起 HTTPS 调用
无 shell 执行权限 — 无
child_process、exec或spawn2 个运行时依赖 —
@modelcontextprotocol/sdk(官方 Anthropic MCP SDK)和zod(模式验证)内置速率限制器 — 序列化请求队列防止 API 滥用
MIT 许可,完全开源 — 在 src/index.ts(约 350 行)和 src/schema.ts(约 140 行)阅读每一行代码
如果您发现安全问题,请参阅 SECURITY.md。
已知限制
无判决正文 — 全文搜索有效(搜索案例标题、引文和内容),但 API 无法返回判决的全文。您必须点击 CanLII URL 才能在 canlii.org 上阅读判决。段落编号和直接引用需要通过阅读源文件进行验证。
搜索基于关键词,而非语义 — 诸如 "mother gatekeeping sole decision-making" 之类的查询可能会返回混合结果。请优化查询并在深入研究元数据之前检查案例标题。
搜索结果不包含案例详情 — 搜索仅返回引文和标题。您需要为每个案例单独调用
get_case_metadata以获取关键词、主题、判决日期和 CanLII URL。无处理指示器 — 引文分析器显示哪些案例引用了某项判决,但并未指出该判决是被遵循、区分还是推翻。您需要阅读引用案例以确定其处理方式。
引文预览限制为 5 个结果 — 使用
get_case_citator(完整版)进行全面的引文分析。搜索无数据库/司法管辖区过滤器 — 您无法在服务器端将搜索结果限制为特定法院或省份;请在查询中添加司法管辖区关键词(例如,使用 "custody Ontario" 而不是仅使用 "custody")。
搜索端点未记录 — 它可以使用,但不在 CanLII 的官方 API 文档中,因此可能会在不另行通知的情况下更改。
速率限制严格 — 每天 5,000 次查询,每秒 2 次请求,1 个并发请求(由内置速率限制器自动强制执行)。
许可
MIT — 参见 LICENSE。
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- FlicenseNot gradedqualityNot gradedmaintenanceProvides access to Canadian federal parliamentary data (debates, bills, MPs, votes, Hansard transcripts) and legal information (case law and legislation through CanLII) for research and analysis.3
- AlicenseNot gradedqualityCmaintenanceProvides access to the CanLII API for searching and retrieving Canadian legal information, including court decisions, legislation, and citations.22MIT

caselegis-mcpofficial
AlicenseNot gradedqualityDmaintenanceEnables searching, retrieving, and checking citation status of California legal opinions via the Caselegis API.MIT- FlicenseAqualityDmaintenanceEnables Claude Desktop to search the CanLII Canadian legal database and retrieve the full text of matching legal documents.1
Related MCP Connectors
MCP for CanLII: Canadian case law and legislation metadata (federal, provincial, territorial).
Resolve, search and verify legal citations against the official sources, with provenance.
Search Swiss federal legislation: laws, articles, amendments via the Fedlex SPARQL endpoint.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/mohammadfarooqi/canlii-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server