Skip to main content
Glama

browse_legislation

Browse Canadian legislation by database (e.g., Ontario Statutes, Canada Statutes). Retrieve legislation IDs for metadata lookup with filters for publication, modification, and decision dates.

Instructions

List all legislation items in a specific database. Use to find legislation IDs for metadata lookup. Key statutes by database — ons: Children's Law Reform Act, Family Law Act, Employment Standards Act. cas: Divorce Act, Criminal Code, Canada Labour Code, Federal Child Support Guidelines.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
languageNoLanguage: 'en' for English (default), 'fr' for Frenchen
databaseIdYesLegislation database ID (e.g., 'ons' for Ontario Statutes, 'cas' for Canada Statutes, 'onr' for Ontario Regulations)
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 main handler for the browse_legislation tool. It constructs a CanLII API URL for browsing legislation in a given database, calls apiFetch with rate limiting, validates the response with LegislationItemResponseSchema, and returns the result.
    // ============================================================
    // TOOL: browse_legislation
    // ============================================================
    server.tool(
    	"browse_legislation",
    	"List all legislation items in a specific database. Use to find legislation IDs for metadata lookup. " +
    	"Key statutes by database — ons: Children's Law Reform Act, Family Law Act, Employment Standards Act. " +
    	"cas: Divorce Act, Criminal Code, Canada Labour Code, Federal Child Support Guidelines.",
    	{
    		language: z.enum(["en", "fr"]).default("en")
    			.describe("Language: 'en' for English (default), 'fr' for French"),
    		databaseId: pathSegmentSchema
    			.describe("Legislation database ID (e.g., 'ons' for Ontario Statutes, 'cas' for Canada Statutes, 'onr' for Ontario Regulations)"),
    		...dateParametersSchema,
    	},
    	async (params) => {
    		try {
    			const { language, databaseId, ...dateParams } = params;
    			const urlParams = new URLSearchParams({ api_key: apiKey });
    			buildDateParams(urlParams, dateParams);
    
    			const response = await apiFetch(
    				`https://api.canlii.org/v1/legislationBrowse/${language}/${encodeURIComponent(databaseId)}/?${urlParams.toString()}`
    			);
    
    			if (!response.ok) {
    				return errorResponse(`Error: Failed to fetch legislation list (${response.status})`);
    			}
    
    			const data = await response.json();
    			const parsed = LegislationItemResponseSchema.parse(data);
    			return jsonResponse(parsed);
    		} catch (error) {
    			return errorResponse(
    				`Error: ${error instanceof Error ? error.message : "Unknown error"}`
    			);
    		}
    	}
    );
  • src/index.ts:437-448 (registration)
    Registration of the browse_legislation tool on the MCP server with name, description, and input schema (language, databaseId, and date parameters).
    server.tool(
    	"browse_legislation",
    	"List all legislation items in a specific database. Use to find legislation IDs for metadata lookup. " +
    	"Key statutes by database — ons: Children's Law Reform Act, Family Law Act, Employment Standards Act. " +
    	"cas: Divorce Act, Criminal Code, Canada Labour Code, Federal Child Support Guidelines.",
    	{
    		language: z.enum(["en", "fr"]).default("en")
    			.describe("Language: 'en' for English (default), 'fr' for French"),
    		databaseId: pathSegmentSchema
    			.describe("Legislation database ID (e.g., 'ons' for Ontario Statutes, 'cas' for Canada Statutes, 'onr' for Ontario Regulations)"),
    		...dateParametersSchema,
    	},
  • LegislationItemResponseSchema - zod schema used to parse the API response for browse_legislation, containing an array of legislation items.
    export const LegislationItemResponseSchema = z.object({
        legislations: z.array(LegislationItemSchema),
    }).passthrough();
  • LegislationItemSchema - zod schema for each individual legislation item returned by browse_legislation (databaseId, legislationId, title, citation, type).
    export const LegislationItemSchema = z.object({
        databaseId: z.string(),
        legislationId: z.string(),
        title: z.string(),
        citation: z.string(),
        type: z.string(),
    }).passthrough();
  • buildDateParams helper function used by browse_legislation to add 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);
    }
Behavior2/5

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

No annotations are provided, and the description does not disclose behavioral traits such as pagination, rate limits, or output size. For a listing tool, this is a significant gap.

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?

Three focused sentences: purpose, use case, and examples. No redundant information; every sentence is necessary.

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

Completeness3/5

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

Given 10 parameters and no output schema, the description is adequate but lacks details on how filters interact, output format, or pagination. Suitable for a basic list tool but not fully complete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, but the description adds value by listing key statutes per database (e.g., 'ons: Children's Law Reform Act'), helping agents select the correct databaseId. This goes beyond the schema's pattern description.

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 legislation items in a specific database and is used to find legislation IDs for metadata lookup. It distinguishes from sibling tools which focus on case law.

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 specifies using the tool to find legislation IDs, but does not explicitly state when not to use it or compare to the sibling 'search' tool. The context is clear enough for legislation-specific tasks.

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