Canlii

io.github.mohammadfarooqi由 GitHub 帳號 mohammadfarooqi 發布v1.1.4更新於 Oct 24, 2026

Search Canadian case law, browse legislation, and check citations via the CanLII API.

概覽

AI 產生的概覽

一個本機 MCP 伺服器,讓助理透過 CanLII API 檢索加拿大判例法、瀏覽法規並查看引證關係。

可以做什麼
依關鍵字或法律概念全文檢索 CanLII 的判例、立法與評論,支援英文與法文,並提供快速引證預覽與完整引證工具。列出法院與法庭資料庫,依日期篩選瀏覽指定法院的最新判決,取得引文、判決日期、案卷號、關鍵字與 CanLII 連結等案件中繼資料。列出立法資料庫,依管轄區瀏覽法規與條例,並取得特定法規或條例的中繼資料。
適用情境
適合加拿大法律研究:尋找相關判例、確認某判決是否仍被援引、依管轄區定位法規或條例。當你需要中繼資料與引證、並打算自行在 CanLII 上閱讀判決全文時最合適。
執行需求
透過 stdio 在本機執行,通常使用 npx,因此需要 Node.js 18 或更新版本。需要在 CANLII_API_KEY 環境變數中提供 CanLII API 金鑰,研究用途可免費申請。需要連線至 CanLII API 的網路存取。
安裝前請注意
伺服器需要你的 CanLII API 金鑰(CANLII_API_KEY),請勿放入共用設定。它只從 CanLII 讀取資料,不會修改任何內容。API 僅回傳中繼資料而非判決全文,引證工具也不說明判決是被遵循還是被推翻,因此引文與處理結果需對照原始來源核實。有嚴格速率限制,且搜尋端點未公開,可能隨時變更。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Canlii,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

CanLII MCP Server

[npm version] [License: MIT]

A Model Context Protocol (MCP) server for searching Canadian legal information via the CanLII API. Search cases, browse legislation, and check citations — all from Claude Desktop or Claude Code.

bash
npx canlii-mcp

Features

  • Full-text search — search across all of CanLII by keyword, case name, or legal concept
  • Case citator — check if a case is still good law by finding what later cases cite it
  • Legislation browsing — browse statutes and regulations by jurisdiction
  • Bilingual — English and French support across all tools including the citator
  • 9 tools — search, browse courts, browse cases, case metadata, full citator, citator preview, legislation databases, browse legislation, legislation metadata
  • Built-in rate limiting — serialized request queue respects CanLII's API limits (2 req/sec, 1 concurrent, 5,000/day)
  • Input validation — all parameters regex-validated and URI-encoded to prevent injection
  • Minimal footprint — 2 runtime dependencies, ~500 lines of code, runs locally as a stdio process
  • Security-first — no file system access, no shell execution, only connects to api.canlii.org

Quick Start

Prerequisites: Node.js 18+ and a CanLII API key (free for research use).

Claude Desktop — add to your config (~/Library/Application Support/Claude/claude_desktop_config.json on macOS):

json
{  "mcpServers": {    "canlii": {      "command": "npx",      "args": ["-y", "canlii-mcp"],      "env": {        "CANLII_API_KEY": "your_api_key_here"      }    }  }}

Restart Claude Desktop after saving.

Claude Code:

bash
claude mcp add canlii -e CANLII_API_KEY=your_key -- npx -y canlii-mcp

From source (for development):

bash
git clone https://github.com/mohammadfarooqi/canlii-mcp.gitcd canlii-mcpnpm install && npm run build

Available Tools (9)

search

Full-text keyword search across all of CanLII — cases, legislation, and commentary. This is the primary entry point for legal research.

search({ query: "material change in circumstances Ontario", resultCount: 10 })

get_courts_and_tribunals

List all available court and tribunal databases. Returns database IDs needed by other tools.

Key Ontario databases: onsc (Superior Court), onca (Court of Appeal), oncj (Court of Justice), csc-scc (Supreme Court of Canada).

get_case_law_decisions

Browse case law decisions from a specific court database, ordered by most recently added. Supports date filters.

get_case_law_decisions({ databaseId: "onsc", resultCount: 20 })

get_case_metadata

Get full details for a specific case — citation, decision date, docket number, keywords, and CanLII URL for reading the full decision.

get_case_metadata({ databaseId: "onsc", caseId: "2021onsc8582" })

get_case_citator

Look up citation relationships for a case. Use citingCases to check if a case is still good law.

get_case_citator({ databaseId: "csc-scc", caseId: "1996canlii190", metadataType: "citingCases" })

get_case_citator_tease

Quick citation preview returning max 5 results. Faster than the full citator for a quick check.

get_case_citator_tease({ databaseId: "csc-scc", caseId: "1996canlii190", metadataType: "citingCases" })

get_legislation_databases

List all legislation databases. Ontario: ons (Statutes), onr (Regulations). Federal: cas (Statutes), car (Regulations).

browse_legislation

List legislation items within a specific database.

browse_legislation({ databaseId: "ons" })

get_legislation_regulation_metadata

Get metadata for a specific statute or regulation, including its CanLII URL.

Typical Research Workflow

  1. Search — search({ query: "gatekeeping parenting time" }) to find relevant cases
  2. Get details — get_case_metadata(...) to get the full citation and CanLII URL
  3. Check citations — get_case_citator(..., metadataType: "citingCases") to verify the case is still good law
  4. Read the decision — Click the CanLII URL to read the full text on canlii.org

API Rate Limits

Per CanLII's API terms:

  • 5,000 queries per day
  • 2 requests per second
  • 1 request at a time
  • Metadata access only — full document text is not available via the API

The server enforces these limits automatically with a built-in rate limiter.

Development

bash
npm run build    # Compile TypeScriptnpm run start    # Run the server (needs CANLII_API_KEY env var)

Project Structure

src/  index.ts     # MCP server — tools, rate limiter, stdio transport  schema.ts    # Zod schemas for CanLII API responses

Contributing

Contributions are welcome! This project aims to make Canadian legal research more accessible through AI tooling.

Ways to contribute:

To submit a PR:

  1. Fork this repository
  2. Create a feature branch (git checkout -b feature/my-improvement)
  3. Make your changes and test locally (npm run build && CANLII_API_KEY=your_key npm run start)
  4. Commit and push to your fork
  5. Open a pull request with a description of what you changed and why

If you find issues with the CanLII API responses, schema mismatches, or have ideas for new tools that would help legal researchers, please open an issue — even if you're not sure how to fix it. We'll investigate together.

Security

This server is designed to be transparent and minimal:

  • Only connects to api.canlii.org — no other network calls, no telemetry, no analytics
  • API key stays local — passed via environment variable, never logged or included in responses
  • All inputs validated — database IDs, case IDs, and dates are regex-validated before use; path segments are URI-encoded
  • All API responses validated — parsed through Zod schemas before being returned
  • No file system access — the server only makes HTTPS calls to CanLII
  • No shell execution — no child_process, exec, or spawn
  • 2 runtime dependencies — @modelcontextprotocol/sdk (official Anthropic MCP SDK) and zod (schema validation)
  • Rate limiter built in — serialized request queue prevents API abuse
  • MIT licensed, fully open source — read every line at src/index.ts (~350 lines) and src/schema.ts (~140 lines)

If you discover a security issue, please see SECURITY.md.

Known Limitations

  • No decision body text — full-text search works (searching across case titles, citations, and content), but the API cannot return the full text of a decision. You must click the CanLII URL to read the decision on canlii.org. Paragraph numbers and direct quotes need to be verified by reading the source.
  • Search is keyword-based, not semantic — queries like "mother gatekeeping sole decision-making" may return mixed results. Refine queries and check case titles before drilling into metadata.
  • Search results don't include case details — search returns only citations and titles. You need to call get_case_metadata separately for each case to get keywords, topics, decision date, and the CanLII URL.
  • No treatment indicators — the citator shows what cases cite a decision, but does not indicate whether it was followed, distinguished, or overturned. You need to read the citing cases to determine treatment.
  • Citator tease caps at 5 results — use get_case_citator (full version) for comprehensive citation analysis.
  • Search has no database/jurisdiction filter — you cannot limit search results to a specific court or province server-side; add jurisdiction keywords to your query instead (e.g., "custody Ontario" instead of just "custody").
  • Search endpoint is undocumented — it works but is not in CanLII's official API docs, so it could change without notice.
  • Rate limits are strict — 5,000 queries/day, 2 req/sec, 1 concurrent request (enforced automatically by the built-in rate limiter).

License

MIT — see LICENSE.

來源:README.md,提交 259d26f

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v1.1.4最新Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分