Get Legislation
get_legislationRetrieve metadata for a specific piece of Canadian legislation including title, citation, dates, and repeal status using database and legislation IDs.
Instructions
Get metadata for a specific piece of legislation including title, citation, dates, and repeal status.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| databaseId | Yes | Legislation database ID | |
| language | No | Response language | en |
| legislationId | Yes | Legislation ID from list_legislation (e.g. "rso-1990-c-a1") |
Implementation Reference
- src/server.ts:283-305 (registration)Registration of the get_legislation tool with MCP server, including its input schema (databaseId, language, legislationId) and the handler that calls the CanLII API endpoint /legislationBrowse/{language}/{databaseId}/{legislationId}.
server.registerTool( "get_legislation", { annotations: { readOnlyHint: true }, description: "Get metadata for a specific piece of legislation including title, citation, dates, and repeal status.", inputSchema: { databaseId: z.string().describe("Legislation database ID"), language: z.enum(["en", "fr"]).default("en").describe("Response language"), legislationId: z .string() .describe('Legislation ID from list_legislation (e.g. "rso-1990-c-a1")'), }, title: "Get Legislation", }, async ({ language, databaseId, legislationId }) => { try { return ok(await request(`/legislationBrowse/${language}/${databaseId}/${legislationId}/`)); } catch (e) { return err(String(e)); } }, ); - src/server.ts:298-304 (handler)Handler function for get_legislation: makes an async call to the CanLII legislation browse API with language, databaseId, and legislationId parameters.
async ({ language, databaseId, legislationId }) => { try { return ok(await request(`/legislationBrowse/${language}/${databaseId}/${legislationId}/`)); } catch (e) { return err(String(e)); } }, - src/server.ts:289-295 (schema)Input schema for the get_legislation tool defining three parameters: databaseId (string), language (enum en/fr, default en), and legislationId (string).
inputSchema: { databaseId: z.string().describe("Legislation database ID"), language: z.enum(["en", "fr"]).default("en").describe("Response language"), legislationId: z .string() .describe('Legislation ID from list_legislation (e.g. "rso-1990-c-a1")'), }, - src/server.ts:50-71 (helper)Core HTTP helper function that all tool handlers (including get_legislation) delegate to via the `request` wrapper. Sends authenticated requests to the CanLII API with rate limiting.
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(); } } - src/server.ts:96-97 (helper)Shorthand wrapper that binds the API key to canliiRequest, used by the get_legislation handler to make the actual API call.
const request = (path: string, params?: Record<string, string>) => canliiRequest(apiKey, path, params);