Get the FREE Ultimate OpenClaw Setup Guide →

canlii

canlii mcp for people in law in canada

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio alhwyn-canlii-mcp npm run dev \
  --env CANLII_API="your_canlii_api_key_here"

How to use

This MCP server provides programmatic access to CanLII data through a suite of tools. It exposes endpoints that let you discover available courts/tribunals, list and browse legislation databases, fetch metadata for specific acts or cases, and retrieve citations information. Once running locally, you can connect clients like Claude Desktop or the Cloudflare AI Playground to the server's M CPC interface to perform searches and retrieve structured results. The tools resemble a small API catalog: get_courts_and_tribunals, get_legislation_databases, browse_legislation, get_legislation_regulation_metadata, get_case_law_decisions, get_case_metadata, and get_case_citator. Each tool accepts language (en/fr) and relevant identifiers (databaseId, caseId, legislationId) plus optional date filters. You can combine these tools to perform common legal research workflows such as locating statutes, drilling into case metadata, and tracing case citators.

How to install

Prerequisites:

  • Node.js and npm
  • A CanLII API key
  • Optional: Cloudflare Workers account for deployment
  1. Clone the repository and install dependencies
git clone <repository-url>
cd canlii-mcp
npm install
  1. Create and configure environment variables
  • Create a .env file or configure your environment with the CanLII API key:
CANLII_API=your_canlii_api_key_here
  • If deploying to Cloudflare Workers, you can set the variable via Wrangler:
wrangler secret put CANLII_API
  1. Running locally for development
npm run dev

This will start the MCP server locally at http://localhost:8787

  1. Deploy to Cloudflare Workers
npm run deploy

5) Optional verification
- Ensure CANLII_API is set in the environment before starting.
- Visit http://localhost:8787/sse to verify the MCP server stream endpoint (for tools integration).

Additional notes

Tips and notes:

  • The server relies on the CANLII_API key, so ensure it is securely stored and not committed to version control.
  • When deploying to Cloudflare Workers, configure the CANLII_API environment variable in your worker settings.
  • Be mindful of CanLII API rate limits and terms of use; implement appropriate client-side rate limiting if integrating into automation.
  • The npm scripts provided include dev (local server), deploy (Cloudflare deployment), format, lint, and type-check to help maintain code quality.
  • If you need to adjust connection settings, update the environment variable or modify the deployment config accordingly.

Related MCP Servers

Sponsor this space

Reach thousands of developers