Skip to main content
Glama

get_case_metadata

Get detailed metadata for a specific Canadian case: CanLII URL, citation, decision date, docket number, keywords, and topics. Use after finding a case to gather complete details before citing.

Instructions

Get detailed metadata for a specific case including its CanLII URL, citation, decision date, docket number, keywords, and topics. The URL field links directly to the full decision text on canlii.org — always provide this to the user for verification. Use after finding a case via search or browse to get complete details before citing it.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
languageNoLanguage: 'en' for English (default), 'fr' for Frenchen
databaseIdYesCourt database ID (e.g., 'onsc', 'onca', 'csc-scc')
caseIdYesCase unique identifier from search/browse results (e.g., '2021onsc8582')
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_case_metadata' tool. It takes language, databaseId, caseId, and optional date parameters, calls the CanLII API endpoint /v1/caseBrowse/{lang}/{dbId}/{caseId}, and parses the response with CaseMetadataSchema.
    	async (params) => {
    		try {
    			const { language, databaseId, caseId, ...dateParams } = params;
    			const urlParams = new URLSearchParams({ api_key: apiKey });
    			buildDateParams(urlParams, dateParams);
    
    			const response = await apiFetch(
    				`https://api.canlii.org/v1/caseBrowse/${language}/${encodeURIComponent(databaseId)}/${encodeURIComponent(caseId)}/?${urlParams.toString()}`
    			);
    
    			if (!response.ok) {
    				return errorResponse(`Error: Failed to fetch case metadata (${response.status})`);
    			}
    
    			const data = await response.json();
    			const parsed = CaseMetadataSchema.parse(data);
    			return jsonResponse(parsed);
    		} catch (error) {
    			return errorResponse(
    				`Error: ${error instanceof Error ? error.message : "Unknown error"}`
    			);
    		}
    	}
    );
  • src/index.ts:257-294 (registration)
    The full tool registration using server.tool() with name 'get_case_metadata', description, input schema (language, databaseId, caseId, date parameters), and the async handler function.
    server.tool(
    	"get_case_metadata",
    	"Get detailed metadata for a specific case including its CanLII URL, citation, decision date, docket number, keywords, and topics. " +
    	"The URL field links directly to the full decision text on canlii.org — always provide this to the user for verification. " +
    	"Use after finding a case via search or browse to get complete details before citing it.",
    	{
    		language: z.enum(["en", "fr"]).default("en")
    			.describe("Language: 'en' for English (default), 'fr' for French"),
    		databaseId: pathSegmentSchema
    			.describe("Court database ID (e.g., 'onsc', 'onca', 'csc-scc')"),
    		caseId: pathSegmentSchema
    			.describe("Case unique identifier from search/browse results (e.g., '2021onsc8582')"),
    		...dateParametersSchema,
    	},
    	async (params) => {
    		try {
    			const { language, databaseId, caseId, ...dateParams } = params;
    			const urlParams = new URLSearchParams({ api_key: apiKey });
    			buildDateParams(urlParams, dateParams);
    
    			const response = await apiFetch(
    				`https://api.canlii.org/v1/caseBrowse/${language}/${encodeURIComponent(databaseId)}/${encodeURIComponent(caseId)}/?${urlParams.toString()}`
    			);
    
    			if (!response.ok) {
    				return errorResponse(`Error: Failed to fetch case metadata (${response.status})`);
    			}
    
    			const data = await response.json();
    			const parsed = CaseMetadataSchema.parse(data);
    			return jsonResponse(parsed);
    		} catch (error) {
    			return errorResponse(
    				`Error: ${error instanceof Error ? error.message : "Unknown error"}`
    			);
    		}
    	}
    );
  • The CaseMetadataSchema Zod schema used to validate the API response for get_case_metadata. Fields include databaseId, caseId, url, title, citation, language, docketNumber, decisionDate, keywords, topics, concatenatedId, and aiContentId.
    export const CaseMetadataSchema = z.object({
        databaseId: z.string(),
        caseId: z.string(),
        url: z.string(),
        title: z.string(),
        citation: z.string(),
        language: z.string().optional(),
        docketNumber: z.string().optional(),
        decisionDate: z.string().optional(),
        keywords: z.string().optional(),
        topics: z.string().optional(),
        concatenatedId: z.string().optional(),
        aiContentId: z.string().optional(),
    }).passthrough();
  • The apiFetch helper function that the handler uses to make rate-limited API calls to CanLII.
    async function apiFetch(url: string): Promise<Response> {
    	return new Promise((resolve, reject) => {
    		requestQueue = requestQueue.then(async () => {
    			const today = new Date().toDateString();
    			if (today !== dailyResetDate) {
    				dailyCount = 0;
    				dailyResetDate = today;
    			}
    			if (dailyCount >= 5000) {
    				throw new Error("Daily API limit reached (5,000 queries). Try again tomorrow.");
    			}
    			const now = Date.now();
    			const elapsed = now - lastRequestTime;
    			if (elapsed < MIN_INTERVAL_MS) {
    				await new Promise(r => setTimeout(r, MIN_INTERVAL_MS - elapsed));
    			}
    			lastRequestTime = Date.now();
    			dailyCount++;
    			return fetch(url);
    		}).then(resolve, reject);
    	});
    }
  • The buildDateParams helper function used to append optional date filter parameters to the API 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 burden. It discloses the tool is a read-like retrieval (getting metadata) and includes an instruction to always provide the URL to the user. However, it does not explicitly state it is read-only or mention any permissions or side effects, which weakens transparency.

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 two concise sentences. The first states the purpose and output; the second gives usage guidance. Every word adds value, and the structure is front-loaded with the most critical information.

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?

The description lists key output fields, providing enough context for an agent to understand return structure despite no output schema. It does not explain all parameters or potential errors, but for a simple retrieval tool, it is complete enough.

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?

Schema description coverage is 100%, so each parameter already has a description. The tool description adds no additional meaning beyond schema, except implying that databaseId and caseId are central. This meets the baseline 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 uses the specific verb 'Get' and targets 'detailed metadata for a specific case'. It lists key outputs (CanLII URL, citation, etc.) and differentiates the tool from search and browsing by stating it provides complete details before citing.

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 guides the agent to use this tool 'after finding a case via search or browse to get complete details before citing it'. This provides clear context for when to invoke it, though it does not explicitly mention when not to use it or name specific 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