canlii-mcp
canlii-mcp
一个用于 CanLII 加拿大法律信息 API 的 MCP (Model Context Protocol) 服务器。它使 AI 助手能够访问所有联邦、省和地区司法管辖区的加拿大判例法和立法元数据。
注意: CanLII API 仅提供元数据——标题、引文、日期、关键词和引用关系。无法通过 API 获取完整的文档文本。
工具
工具 | 描述 |
| 列出 CanLII 集合中的所有法院和法庭 |
| 浏览特定法院/法庭数据库中的判决 |
| 获取特定案件的元数据(标题、引文、日期、关键词) |
| 获取某案件引用的案件、引用该案件的案件,或其引用的立法 |
| 列出所有法规和条例数据库 |
| 浏览特定数据库中的法规或条例 |
| 获取特定立法的元数据 |
Related MCP server: courtlistener-mcp
要求
Node.js 22+
CanLII API 密钥 — 在此申请
使用方法
通过 npx 使用 stdio(最快)
{
"mcpServers": {
"canlii": {
"type": "stdio",
"command": "npx",
"args": ["-y", "@tomilashy/canlii-mcp"],
"env": {
"CANLII_API": "your_api_key"
}
}
}
}stdio(从源码运行)
npm install
npm run build
node dist/index.js添加到您的 MCP 配置中:
{
"mcpServers": {
"canlii": {
"command": "node",
"args": ["/path/to/canlii-mcp/dist/index.js"],
"env": {
"CANLII_API": "your_api_key"
}
}
}
}HTTP 服务器
PORT=3000 CANLII_API=your_api_key node dist/index.js --transport httpMCP 端点位于 http://localhost:3000/mcp。服务器以无状态模式运行——每个请求都是独立的,不需要会话 ID 或初始化握手。客户端可以直接调用工具:
curl -X POST http://localhost:3000/mcp \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"list_case_databases","arguments":{"language":"en"}}}'Docker
docker run -e CANLII_API=your_api_key -e MCP_AUTH_TOKEN=your_secret -p 3000:3000 ghcr.io/tomilashy/canlii-mcp或者使用 Docker Compose:
services:
canlii-mcp:
image: ghcr.io/tomilashy/canlii-mcp
environment:
CANLII_API: your_api_key
MCP_AUTH_TOKEN: your_secret # optional
ports:
- "3000:3000"Cloudflare Workers
该服务器包含一个兼容 Workers 的入口点 (src/worker.ts)。
CLI 部署
npx wrangler secret put CANLII_API
npx wrangler secret put MCP_AUTH_TOKEN # optional
npx wrangler deploy仪表板部署(连接到 Git)
前往 Cloudflare 仪表板 → Workers & Pages → Create → Connect to Git
选择您的
tomilashy/canlii-mcp仓库在 Set up your application 页面:
Project name:
canlii-mcpBuild command:
npm install && npm run buildDeploy command:
npx wrangler deploy(预填)
展开 Advanced settings:
Variable name:
CANLII_APIVariable value: 您的 CanLII API 密钥
勾选 Encrypt 以将其存储为机密
点击 Deploy
MCP 端点将位于 https://canlii-mcp.<your-subdomain>.workers.dev/mcp。
配置
环境变量 | 必需 | 默认 | 描述 |
| 是 | — | 您的 CanLII API 密钥 |
| 否 |
| HTTP 服务器端口(仅限 HTTP 模式) |
| 否 | — | 用于 HTTP 身份验证的 Bearer 令牌。如果设置,所有 HTTP 请求必须包含 |
速率限制
服务器会自动执行 CanLII 的 API 限制:
同时处理 1 个请求
每秒 2 个请求
每天 5,000 个请求
超过每日限制的请求将返回错误,而不是访问 API。
开发
npm install
npm run build # compile TypeScript
npm run watch # watch mode发布
本项目通过 semantic-release 使用 语义化版本控制 (Semantic Versioning)。提交信息遵循 Conventional Commits 规范:
提交前缀 | 发布类型 |
| 补丁 ( |
| 次要版本 ( |
| 主要版本 ( |
推送到 main 分支会触发发布工作流。如果发布成功,Docker 镜像将自动构建并发布到 ghcr.io。
许可证
MIT
Available Tools
7 toolsget_caseGet CaseARead-onlyInspect
Get metadata for a specific case including title, citation, decision date, keywords, and URL.
Inputs: caseId (required), databaseId (required), language.
get_case_citationsGet Case CitationsARead-onlyInspect
Get citation information for a case: what it cites, what cites it, or what legislation it references. Note: the CanLII API currently only supports English for this endpoint; French requests will fall back to English.
Inputs: caseId (required), citationType (required), databaseId (required), language.
get_legislationGet LegislationARead-onlyInspect
Get metadata for a specific piece of legislation including title, citation, dates, and repeal status.
Inputs: databaseId (required), legislationId (required), language.
list_case_databasesList Case DatabasesARead-onlyInspect
List all courts and tribunals in the CanLII collection with their database IDs.
Inputs: language.
list_casesList CasesBRead-onlyInspect
List decisions from a specific caselaw database. Returns case titles, citations, and IDs.
Inputs: databaseId (required), decisionDateAfter, decisionDateBefore, language, +4 more.
list_legislationList LegislationARead-onlyInspect
List statutes or regulations from a specific legislation database.
Inputs: databaseId (required), language.
list_legislation_databasesList Legislation DatabasesARead-onlyInspect
List all legislation and regulation databases in the CanLII collection.
Inputs: language.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 7 tools
Each tool targets a distinct operation: retrieving specific case metadata, case citations, legislation, or listing various databases and documents. No functional overlap exists.
All tool names follow a consistent verb_noun pattern using snake_case, e.g., get_case, list_cases, get_legislation, making the API predictable.
7 tools is well-scoped for a legal database API, covering core retrieval and listing operations. Slightly on the smaller side but still appropriate.
The set covers basic CRUD-like read operations for cases and legislation, but lacks search/full-text query capabilities, which are common in legal research APIs.
Maintenance
Related MCP Connectors
Connect AI to millions of laws and court cases with the Lawstronaut MCP.
One MCP server for the services your AI needs: memory, files, Microsoft 365, kanban and more.
MCP server that lets your AI assistant build and deploy apps, hosting each one at a live URL.
AI governance MCP server for EU AI Act compliance and jurisdiction verification
Related MCP Servers
- AlicenseAqualityDmaintenanceMCP Server providing AI agents access to over 3 million US court decisions via CourtListener and EU legislation via EUR-Lex, with tools for searching cases, citations, judges, and court information.6MIT
- AlicenseNot gradedqualityDmaintenanceAn MCP server providing AI agents access to CourtListener's comprehensive legal database, featuring semantic search, hybrid search, citation verification, and research tools.7MIT
- AlicenseAqualityBmaintenanceMCP server giving AI agents structured access to Canadian federal, provincial, and municipal government data.4562MIT
- AlicenseAqualityDmaintenanceLegalMCP is a comprehensive US legal MCP server that enables AI assistants to search over 4 million US court opinions, manage Clio practice data, and access PACER federal filings through natural language.1869MIT