List Legislation Databases
list_legislation_databasesRetrieve a complete list of legislation and regulation databases indexed in the CanLII legal database. Specify language for English or French output.
Instructions
List all legislation and regulation databases in the CanLII collection.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| language | No | Response language | en |
Implementation Reference
- src/server.ts:237-255 (registration)Registration of the 'list_legislation_databases' tool via server.registerTool(), including its input schema (language parameter) and the handler that calls the CanLII API endpoint /legislationBrowse/{language}/.
// 5. List legislation databases server.registerTool( "list_legislation_databases", { annotations: { readOnlyHint: true }, description: "List all legislation and regulation databases in the CanLII collection.", inputSchema: { language: z.enum(["en", "fr"]).default("en").describe("Response language"), }, title: "List Legislation Databases", }, async ({ language }) => { try { return ok(await request(`/legislationBrowse/${language}/`)); } catch (e) { return err(String(e)); } }, ); - src/server.ts:248-254 (handler)The handler function for 'list_legislation_databases'. It takes a 'language' parameter, calls request(`/legislationBrowse/${language}/`), and returns the result.
async ({ language }) => { try { return ok(await request(`/legislationBrowse/${language}/`)); } catch (e) { return err(String(e)); } }, - src/server.ts:243-245 (schema)Input schema for the tool: a 'language' enum (en/fr) with default 'en', described as 'Response language'.
inputSchema: { language: z.enum(["en", "fr"]).default("en").describe("Response language"), }, - src/server.ts:96-97 (helper)The 'request' helper closure that wraps canliiRequest with the API key, used by the handler to make the HTTP call.
const request = (path: string, params?: Record<string, string>) => canliiRequest(apiKey, path, params); - src/server.ts:50-71 (helper)The core HTTP helper 'canliiRequest' that performs the actual fetch to the CanLII API with rate limiting and error handling.
async function canliiRequest( apiKey: string, path: string, params: Record<string, string> = {}, ): Promise<unknown> { await acquireSlot(); try { const url = new URL(`${BASE_URL}${path}`); url.searchParams.set("api_key", apiKey); for (const [k, v] of Object.entries(params)) { if (v !== undefined && v !== "") url.searchParams.set(k, v); } const res = await fetch(url.toString()); if (!res.ok) { const body = await res.text(); throw new Error(`CanLII API ${res.status}: ${body}`); } return await res.json(); } finally { releaseSlot(); } }