Skip to main content
Glama

canlii-mcp

一个用于 CanLII 加拿大法律信息 API 的 MCP (Model Context Protocol) 服务器。它使 AI 助手能够访问所有联邦、省和地区司法管辖区的加拿大判例法和立法元数据。

注意: CanLII API 仅提供元数据——标题、引文、日期、关键词和引用关系。无法通过 API 获取完整的文档文本。

工具

工具

描述

list_case_databases

列出 CanLII 集合中的所有法院和法庭

list_cases

浏览特定法院/法庭数据库中的判决

get_case

获取特定案件的元数据(标题、引文、日期、关键词)

get_case_citations

获取某案件引用的案件、引用该案件的案件,或其引用的立法

list_legislation_databases

列出所有法规和条例数据库

list_legislation

浏览特定数据库中的法规或条例

get_legislation

获取特定立法的元数据

Related MCP server: courtlistener-mcp

要求

使用方法

通过 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 http

MCP 端点位于 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)

  1. 前往 Cloudflare 仪表板 → Workers & Pages → Create → Connect to Git

  2. 选择您的 tomilashy/canlii-mcp 仓库

  3. 在 Set up your application 页面:

    • Project name: canlii-mcp

    • Build command: npm install && npm run build

    • Deploy command: npx wrangler deploy (预填)

  4. 展开 Advanced settings:

    • Variable name: CANLII_API

    • Variable value: 您的 CanLII API 密钥

    • 勾选 Encrypt 以将其存储为机密

  5. 点击 Deploy

MCP 端点将位于 https://canlii-mcp.<your-subdomain>.workers.dev/mcp。

配置

环境变量

必需

默认

描述

CANLII_API

是

—

您的 CanLII API 密钥

PORT

否

3000

HTTP 服务器端口(仅限 HTTP 模式)

MCP_AUTH_TOKEN

否

—

用于 HTTP 身份验证的 Bearer 令牌。如果设置,所有 HTTP 请求必须包含 Authorization: Bearer <token>。如果未设置,服务器将在无身份验证的情况下运行。

速率限制

服务器会自动执行 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 规范:

提交前缀

发布类型

fix:

补丁 (1.0.0 → 1.0.1)

feat:

次要版本 (1.0.0 → 1.1.0)

feat!: 或 BREAKING CHANGE

主要版本 (1.0.0 → 2.0.0)

推送到 main 分支会触发发布工作流。如果发布成功,Docker 镜像将自动构建并发布到 ghcr.io。

许可证

MIT

Available Tools

7 tools
get_caseGet CaseA
Read-only
Inspect

Get metadata for a specific case including title, citation, decision date, keywords, and URL.

Inputs: caseId (required), databaseId (required), language.

get_case_citationsGet Case CitationsA
Read-only
Inspect

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 LegislationA
Read-only
Inspect

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 DatabasesA
Read-only
Inspect

List all courts and tribunals in the CanLII collection with their database IDs.

Inputs: language.

list_casesList CasesB
Read-only
Inspect

List decisions from a specific caselaw database. Returns case titles, citations, and IDs.

Inputs: databaseId (required), decisionDateAfter, decisionDateBefore, language, +4 more.

list_legislationList LegislationA
Read-only
Inspect

List statutes or regulations from a specific legislation database.

Inputs: databaseId (required), language.

list_legislation_databasesList Legislation DatabasesA
Read-only
Inspect

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

    A3.8/5.0

    Scored across 7 tools

    Disambiguation5/5

    Each tool targets a distinct operation: retrieving specific case metadata, case citations, legislation, or listing various databases and documents. No functional overlap exists.

    Naming Consistency5/5

    All tool names follow a consistent verb_noun pattern using snake_case, e.g., get_case, list_cases, get_legislation, making the API predictable.

    Tool Count4/5

    7 tools is well-scoped for a legal database API, covering core retrieval and listing operations. Slightly on the smaller side but still appropriate.

    Completeness3/5

    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

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      B
      maintenance
      MCP server giving AI agents structured access to Canadian federal, provincial, and municipal government data.
      4
      5
      62
      MIT
    • A
      license
      A
      quality
      D
      maintenance
      LegalMCP 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.
      18
      69
      MIT