Skip to main content
Glama

get_legislation_databases

List all available Canadian legislation databases on CanLII, returning database IDs (e.g., ons, onr, cas) for browsing statutes and regulations by jurisdiction.

Instructions

List all available legislation databases in Canada. Returns database IDs for browsing statutes and regulations. Key databases: ons (Ontario Statutes), onr (Ontario Regulations), cas (Canada Statutes), car (Canada Regulations), bcs (BC Statutes), abs (Alberta Statutes).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
languageNoLanguage: 'en' for English (default), 'fr' for Frenchen
publishedBeforeNoDate first published on CanLII (YYYY-MM-DD)
publishedAfterNoDate first published on CanLII (YYYY-MM-DD)
modifiedBeforeNoDate content last modified on CanLII (YYYY-MM-DD)
modifiedAfterNoDate content last modified on CanLII (YYYY-MM-DD)
changedBeforeNoDate metadata or content last changed on CanLII (YYYY-MM-DD)
changedAfterNoDate metadata or content last changed on CanLII (YYYY-MM-DD)
decisionDateBeforeNoDecision date upper bound (YYYY-MM-DD)
decisionDateAfterNoDecision date lower bound (YYYY-MM-DD)

Implementation Reference

  • The handler for the get_legislation_databases MCP tool. Fetches legislation databases from the CanLII API (v1/legislationBrowse) with optional language and date parameters, returns the parsed LegislationResponseSchema data.
    server.tool(
    	"get_legislation_databases",
    	"List all available legislation databases in Canada. Returns database IDs for browsing statutes and regulations. " +
    	"Key databases: ons (Ontario Statutes), onr (Ontario Regulations), cas (Canada Statutes), car (Canada Regulations), " +
    	"bcs (BC Statutes), abs (Alberta Statutes).",
    	{
    		language: z.enum(["en", "fr"]).default("en")
    			.describe("Language: 'en' for English (default), 'fr' for French"),
    		...dateParametersSchema,
    	},
    	async (params) => {
    		try {
    			const { language, ...dateParams } = params;
    			const urlParams = new URLSearchParams({ api_key: apiKey });
    			buildDateParams(urlParams, dateParams);
    
    			const response = await apiFetch(
    				`https://api.canlii.org/v1/legislationBrowse/${language}/?${urlParams.toString()}`
    			);
    
    			if (!response.ok) {
    				return errorResponse(`Error: Failed to fetch legislation databases (${response.status})`);
    			}
    
    			const data = await response.json();
    			const parsed = LegislationResponseSchema.parse(data);
    			return jsonResponse(parsed);
    		} catch (error) {
    			return errorResponse(
    				`Error: ${error instanceof Error ? error.message : "Unknown error"}`
    			);
    		}
    	}
    );
  • Zod schema for legislation database items and the response shape (legislationDatabases array). Used to validate the API response.
    export const LegislationSchema = z.object({
        databaseId: z.string(),
        type: z.string(),
        jurisdiction: z.string(),
        name: z.string(),
    }).passthrough();
    
    export const LegislationResponseSchema = z.object({
        legislationDatabases: z.array(LegislationSchema),
    }).passthrough();
  • src/index.ts:399-432 (registration)
    Registration of the tool via server.tool() with name 'get_legislation_databases' on the MCP server instance.
    server.tool(
    	"get_legislation_databases",
    	"List all available legislation databases in Canada. Returns database IDs for browsing statutes and regulations. " +
    	"Key databases: ons (Ontario Statutes), onr (Ontario Regulations), cas (Canada Statutes), car (Canada Regulations), " +
    	"bcs (BC Statutes), abs (Alberta Statutes).",
    	{
    		language: z.enum(["en", "fr"]).default("en")
    			.describe("Language: 'en' for English (default), 'fr' for French"),
    		...dateParametersSchema,
    	},
    	async (params) => {
    		try {
    			const { language, ...dateParams } = params;
    			const urlParams = new URLSearchParams({ api_key: apiKey });
    			buildDateParams(urlParams, dateParams);
    
    			const response = await apiFetch(
    				`https://api.canlii.org/v1/legislationBrowse/${language}/?${urlParams.toString()}`
    			);
    
    			if (!response.ok) {
    				return errorResponse(`Error: Failed to fetch legislation databases (${response.status})`);
    			}
    
    			const data = await response.json();
    			const parsed = LegislationResponseSchema.parse(data);
    			return jsonResponse(parsed);
    		} catch (error) {
    			return errorResponse(
    				`Error: ${error instanceof Error ? error.message : "Unknown error"}`
    			);
    		}
    	}
    );
  • Shared date parameters schema, spread into the tool's schema definition.
    const dateParametersSchema = {
    	publishedBefore: dateSchema.describe("Date first published on CanLII (YYYY-MM-DD)"),
    	publishedAfter: dateSchema.describe("Date first published on CanLII (YYYY-MM-DD)"),
    	modifiedBefore: dateSchema.describe("Date content last modified on CanLII (YYYY-MM-DD)"),
    	modifiedAfter: dateSchema.describe("Date content last modified on CanLII (YYYY-MM-DD)"),
    	changedBefore: dateSchema.describe("Date metadata or content last changed on CanLII (YYYY-MM-DD)"),
    	changedAfter: dateSchema.describe("Date metadata or content last changed on CanLII (YYYY-MM-DD)"),
    	decisionDateBefore: dateSchema.describe("Decision date upper bound (YYYY-MM-DD)"),
    	decisionDateAfter: dateSchema.describe("Decision date lower bound (YYYY-MM-DD)"),
    };
  • Utility function used by the handler to append date filter parameters to the API request URL.
    function buildDateParams(params: URLSearchParams, options: {
    	publishedBefore?: string;
    	publishedAfter?: string;
    	modifiedBefore?: string;
    	modifiedAfter?: string;
    	changedBefore?: string;
    	changedAfter?: string;
    	decisionDateBefore?: string;
    	decisionDateAfter?: string;
    }) {
    	if (options.publishedBefore) params.append('publishedBefore', options.publishedBefore);
    	if (options.publishedAfter) params.append('publishedAfter', options.publishedAfter);
    	if (options.modifiedBefore) params.append('modifiedBefore', options.modifiedBefore);
    	if (options.modifiedAfter) params.append('modifiedAfter', options.modifiedAfter);
    	if (options.changedBefore) params.append('changedBefore', options.changedBefore);
    	if (options.changedAfter) params.append('changedAfter', options.changedAfter);
    	if (options.decisionDateBefore) params.append('decisionDateBefore', options.decisionDateBefore);
    	if (options.decisionDateAfter) params.append('decisionDateAfter', options.decisionDateAfter);
    }
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It states the tool returns database IDs and lists key databases, but it does not disclose behavioral traits such as read-only nature, rate limits, or any side effects. For a simple listing tool, this is adequate but not exhaustive.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise: two sentences plus a brief list of key databases. It is front-loaded with the purpose and provides immediate value without unnecessary detail.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The tool has 9 optional filter parameters, but the description does not explain their purpose or how to use them effectively. There is no output schema, and the description only mentions 'returns database IDs' without specifying format or structure. This leaves some gaps, but for a simple listing tool it is minimally adequate.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, so the baseline is 3. The description does not add meaning beyond the schema; it only mentions database IDs in the output context. The parameters are well-documented in the schema, so no further elaboration is needed.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's function: listing all available legislation databases in Canada. It provides specific examples of key databases and what they represent. This distinguishes it from sibling tools like browse_legislation or get_case_citator.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description indicates the tool is for retrieving a list of databases, which is a clear use case. It does not explicitly mention when not to use it or provide alternatives, but the context is sufficient for an AI agent to understand its primary role.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

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