Skip to main content
Glama

get_courts_and_tribunals

List all available Canadian court and tribunal databases from CanLII. Returns database IDs required for browse, citator, and other tools. Use to find valid IDs for courts like ONSC, ONCA, SCC, BCSC, etc.

Instructions

List all available court and tribunal databases in Canada. Returns database IDs needed for other tools. Key databases: onsc (Ontario Superior Court), onca (Ontario Court of Appeal), oncj (Ontario Court of Justice), onscdc (Divisional Court), csc-scc (Supreme Court of Canada), bcsc (BC Supreme Court), abkb (Alberta King's Bench). Use this to discover valid databaseId values for browse and citator tools.

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 function for the get_courts_and_tribunals tool. It accepts language (en/fr) and optional date parameters, makes a GET request to the CanLII caseBrowse API, validates the response with CaseDatabasesResponseSchema, and returns the list of court/tribunal databases.
    server.tool(
    	"get_courts_and_tribunals",
    	"List all available court and tribunal databases in Canada. Returns database IDs needed for other tools. " +
    	"Key databases: onsc (Ontario Superior Court), onca (Ontario Court of Appeal), oncj (Ontario Court of Justice), " +
    	"onscdc (Divisional Court), csc-scc (Supreme Court of Canada), bcsc (BC Supreme Court), abkb (Alberta King's Bench). " +
    	"Use this to discover valid databaseId values for browse and citator tools.",
    	{
    		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/caseBrowse/${language}/?${urlParams.toString()}`
    			);
    
    			if (!response.ok) {
    				return errorResponse(`Error: Failed to fetch databases (${response.status})`);
    			}
    
    			const data = await response.json();
    			const parsed = CaseDatabasesResponseSchema.parse(data);
    			return jsonResponse(parsed);
    		} catch (error) {
    			return errorResponse(
    				`Error: ${error instanceof Error ? error.message : "Unknown error"}`
    			);
    		}
    	}
    );
  • The CaseDatabaseSchema (lines 3-8) and CaseDatabasesResponseSchema (lines 10-12) define the response type for the tool: an object with a 'caseDatabases' array, each containing databaseId, jurisdiction, name, and optional url.
    export const CaseDatabaseSchema = z.object({
        databaseId: z.string(),
        jurisdiction: z.string(),
        name: z.string(),
        url: z.string().optional(),
    }).passthrough();
    
    export const CaseDatabasesResponseSchema = z.object({
        caseDatabases: z.array(CaseDatabaseSchema),
    }).passthrough();
  • src/index.ts:169-203 (registration)
    The tool is registered via server.tool() on line 169 with the name 'get_courts_and_tribunals', a descriptive string, input schema (language enum + date parameters), and the async handler.
    server.tool(
    	"get_courts_and_tribunals",
    	"List all available court and tribunal databases in Canada. Returns database IDs needed for other tools. " +
    	"Key databases: onsc (Ontario Superior Court), onca (Ontario Court of Appeal), oncj (Ontario Court of Justice), " +
    	"onscdc (Divisional Court), csc-scc (Supreme Court of Canada), bcsc (BC Supreme Court), abkb (Alberta King's Bench). " +
    	"Use this to discover valid databaseId values for browse and citator tools.",
    	{
    		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/caseBrowse/${language}/?${urlParams.toString()}`
    			);
    
    			if (!response.ok) {
    				return errorResponse(`Error: Failed to fetch databases (${response.status})`);
    			}
    
    			const data = await response.json();
    			const parsed = CaseDatabasesResponseSchema.parse(data);
    			return jsonResponse(parsed);
    		} catch (error) {
    			return errorResponse(
    				`Error: ${error instanceof Error ? error.message : "Unknown error"}`
    			);
    		}
    	}
    );
  • The buildDateParams helper function is used by the handler to append optional 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);
    }
  • The jsonResponse helper function formats the parsed response data as a JSON text response for the tool output.
    function jsonResponse(data: unknown) {
    	return textResponse(JSON.stringify(data, null, 2));
    }
Behavior4/5

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

Though no annotations are provided, the description implies a read-only operation (listing databases) and explicitly states it returns database IDs. It does not contradict any annotations.

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

Conciseness4/5

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

The description is concise, using three sentences to convey purpose, examples, and usage guidance. Slightly verbose with examples but overall efficient.

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

Completeness4/5

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

Given the tool's simplicity and no output schema, the description covers the core purpose and return values. It does not detail the return structure but is sufficient for a listing tool.

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?

All 9 parameters are fully described in the input schema (100% coverage). The description does not add additional meaning beyond the schema, meriting a baseline score of 3.

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 lists all available court and tribunal databases in Canada and returns database IDs needed for other tools. It distinguishes itself from siblings like get_legislation_databases by specifying it provides database IDs for browse and citator tools.

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 explicitly advises using this tool to discover valid databaseId values for browse and citator tools, providing clear guidance on when to use. However, it does not mention when not to use or alternatives.

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