Get Case Citations
get_case_citationsRetrieve citation relationships for a Canadian case: get cases it cites, cases citing it, or legislation it references using case ID and database ID.
Instructions
Get citation information for a case: what it cites, what cites it, or what legislation it references. Note: the CanLII API currently only supports English for this endpoint; French requests will fall back to English.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| caseId | Yes | Case ID (e.g. "1999canlii1527") | |
| citationType | Yes | Type of citation data to retrieve | |
| databaseId | Yes | Database ID (e.g. "onca") | |
| language | No | Response language (currently only 'en' is supported by the API) | en |
Implementation Reference
- src/server.ts:208-235 (registration)Registration of the 'get_case_citations' tool via server.registerTool, defining its metadata and handler.
// 4. Case citator server.registerTool( "get_case_citations", { annotations: { readOnlyHint: true }, description: "Get citation information for a case: what it cites, what cites it, or what legislation it references. Note: the CanLII API currently only supports English for this endpoint; French requests will fall back to English.", inputSchema: { caseId: z.string().describe('Case ID (e.g. "1999canlii1527")'), citationType: z .enum(["citedCases", "citingCases", "citedLegislations"]) .describe("Type of citation data to retrieve"), databaseId: z.string().describe('Database ID (e.g. "onca")'), language: z .enum(["en", "fr"]) .default("en") .describe("Response language (currently only 'en' is supported by the API)"), }, title: "Get Case Citations", }, async ({ databaseId, caseId, citationType }) => { try { return ok(await request(`/caseCitator/en/${databaseId}/${caseId}/${citationType}`)); } catch (e) { return err(String(e)); } }, ); - src/server.ts:211-227 (schema)Input schema for 'get_case_citations' with caseId, citationType, databaseId, and language parameters using Zod validation.
{ annotations: { readOnlyHint: true }, description: "Get citation information for a case: what it cites, what cites it, or what legislation it references. Note: the CanLII API currently only supports English for this endpoint; French requests will fall back to English.", inputSchema: { caseId: z.string().describe('Case ID (e.g. "1999canlii1527")'), citationType: z .enum(["citedCases", "citingCases", "citedLegislations"]) .describe("Type of citation data to retrieve"), databaseId: z.string().describe('Database ID (e.g. "onca")'), language: z .enum(["en", "fr"]) .default("en") .describe("Response language (currently only 'en' is supported by the API)"), }, title: "Get Case Citations", }, - src/server.ts:228-234 (handler)Handler function for 'get_case_citations' that makes a GET request to /caseCitator/en/{databaseId}/{caseId}/{citationType} and returns the JSON result.
async ({ databaseId, caseId, citationType }) => { try { return ok(await request(`/caseCitator/en/${databaseId}/${caseId}/${citationType}`)); } catch (e) { return err(String(e)); } }, - src/server.ts:50-71 (helper)The canliiRequest helper that performs the actual HTTP call 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(); } } - src/server.ts:73-84 (helper)Helper functions ok() and err() that format successful/error responses for tool output.
type ToolResult = { content: Array<{ type: "text"; text: string }>; isError?: boolean; }; function ok(data: unknown): ToolResult { return { content: [{ text: JSON.stringify(data, null, 2), type: "text" }] }; } function err(message: string): ToolResult { return { content: [{ text: message, type: "text" }], isError: true }; }