CanLex / README.md
Beemer
Deploy: the IRCC operational bulletins (7325a34, code approved at b479315) -- the 17 OBs in force, English and French, labelled 'IRCC operational bulletin' (OB 699 with its own end date, OB 205-A with its citizenship note), and the weekly OB watch on IRCC's year pages and each bulletin's pages; curated baseline c32bd27 unchanged
890c58d
|
Raw History Blame Contribute Delete
9.89 kB
---
title: CanLex MCP
sdk: docker
app_port: 7860
pinned: false
---
# CanLex MCP
A remote [Model Context Protocol](https://modelcontextprotocol.io) server for
Canadian legal research, built for front-line border-services work. The
legislation corpus is **bilingual**: every Justice Laws Act and regulation (84)
also carries its parallel French text (the Constitution Acts and the STCA texts
are English only), and a French-language query searches both languages
automatically. Fourteen read-only tools over streamable HTTP (or local stdio):
- **canlex_search_legislation** β€” hybrid (BM25 + semantic) search with a
cross-encoder reranker over the whole corpus: federal border, customs,
criminal, firearms, drug, food/health, labour and privacy legislation with
their Schedules (84 Justice Laws instruments, from IRPA and the Customs Act to the
sanctions Acts, the Criminal Records Act, the Income Tax Act, the aviation-security
instruments and the public-service labour statutes); the ENF operational manuals,
the other active IRCC manuals (CP 14, IN 1-2, IP 3/4/7, OP 8/9/14/22; IP 10 and OP 21
are held back by the eval gate), the 17 IRCC operational bulletins still in force (of 336
IRCC lists) and IRCC program delivery instructions; CBSA D-Memoranda and the AMPS Master Penalty Document; the
Charter; the Safe Third Country Agreement; Treasury Board collective
agreements; NJC directives; the CBSA Code of Conduct and the Treasury
Board people-management instruments; CBSA detention policy and the IRB
Chairperson's Guidelines and the IRB Legal Services papers on criminal
equivalency and criminal refusals; IRCC's rehabilitation application guide;
~265 leading decisions; delegation instruments; benefit-plan booklets; and
CanLex's curated commentary.
- **canlex_get_section** β€” fetch one provision verbatim by Act and section
(accepts 's. 34', '34(1)(c)', 'Schedule I').
- **canlex_us_disposition** β€” step 1 of the IRPA s. 36 screening chain: is a
foreign disposition a "conviction"? Curated for US records, with a
51-jurisdiction state-by-state dataset; a non-US record (the optional
`country`, or a state value that is not a US state or territory) gets the
framework and the entry-level verdict, labelled "non-US record: curated
coverage is thin". The tool names keep their `us_` prefix so saved client
configs keep working. The answer ends with a READ NEXT block: the official
guidance and statute on the point, from the corpus (chunk id, status and a
verbatim quote; unofficial ATIP copies of withdrawn chapters flagged and
listed after the official sources).
- **canlex_us_equivalency** β€” step 2: the Canadian equivalent of a foreign
offence (US-curated pairings), its verified maximum penalty, and the
inadmissibility branch, with the pairing's READ NEXT block.
- **canlex_rehabilitation** β€” step 3: deemed rehabilitation / eligibility to
apply, under IRPA s. 36(3)(c) and IRPR ss. 17–18.1 β€” from dates, with the
earliest eligibility dates computed.
- **canlex_screen_record** β€” the three steps in one call for a foreign record
(US state rows where they exist; optional `country`), from the record's
own words and dates: a screening memo with the draft allegation paragraph
(both paragraphs when the disposition or a tie is unsettled), the next
steps at the port of entry (s. 44 report, the removal path by paragraph,
TRP, rehabilitation application with the IRPR fees, family members by
application type), what the chain assumed, an "s. 37 also to consider"
block where the offence or the optional `organization` fact raises
organized criminality, a "Read next" line per step, and one structured
result line. Where the record's words reach curated content still held for
review that the deployment lacks, the memo says so ("HELD FOR REVIEW -- not
in this deployment") and lists it among what the chain assumed. A conviction in
Canada (country 'Canada' or a province) is screened on s. 36(1)(a)/(2)(a)
instead: discharges, conditional sentences, s. 18.1, the record suspension
as the cure, the removal path and a permanent resident's appeal line. An
optional `date_of_birth` (or `age_at_offence`) prints the youth block,
statute and IRCC policy kept apart. At the top, **THE ANSWER CHANGES WITH
THESE FACTS** lists each missing fact that changes the branch, the allegation
paragraph or the rehabilitation status (the chain re-run with every plausible
value; CANLEX_RESULT `decisive_missing`). An optional `conviction_date`
bounds the maximum at commission; `sentence_imposed` with `sentence_date`
adds a completion date **IF SERVED EXACTLY AS IMPOSED** (Guide 5312's rules;
never a verdict, and a fine blocks it); `detail: "card"` returns a result
card of about ten lines instead of the memo. The full memo ends with a
**DRAFT s. 44(1) narrative skeleton** in the ENF 5 s. 13.1 form, in English,
French or both (`language`): the proposed IRPA paragraph with its words, the
offence as recorded, the Canadian provision (the pairing's curated report
provision, chosen by the matched limb and the maximum at commission) and the
maximum in the statute's own words. Every bracket is to be verified; what
CanLex does not hold (name, place, the conviction date unless given, the
status evidence) stays `[CONFIRM: ...]`, and a result that is not settled
gets one allegation per reading, never a settled one.
- **canlex_screen_history** β€” a whole record at once: every entry through the
chain (foreign or Canadian), then the record-level count for IRPR s. 18(2)
(equal or missing offence dates on a two-offence count give both readings),
deemed rehabilitation tested limb by limb (IRPR s. 18(2)(a)-(c) and s. 18.1:
a table with the entry that decides each limb and the date it starts or stops
holding; both readings where an unsettled reading decides it; an optional
`conviction_date` per entry, which also bounds the maximum at commission)
and the s. 17 clock from the most recent conviction, Canadian ones
included. The decisive facts, `detail: "card"` and the narrative skeleton
(one allegation per entry that grounds one; the two-offence limb over the
summary-only convictions) as for canlex_screen_record; an entry's `relief`
(a pardon, expungement, sealing or record suspension, or 'none') is read as
the disposition's later history.
- **canlex_screen** β€” the same record pipeline, with the entries as typed
objects (one per conviction, disposition or charge, in the record's own
words; an unknown key is refused, so a misspelt key never silently changes
an answer). There is no free-text rap-sheet parsing. A record-level
`relief` applies to every entry without its own; 'none' confirms there is
none. Returns the result card by default (`detail: "full"` for everything,
the narrative skeleton included). Every screening tool's CANLEX_RESULT carries
`confidence`: what each step rests on (the entry's and pairing's authority
status, whether the state row was verified, how many cited decisions are in
the corpus, where the maximum came from, the s. 18(2) limbs left unknown).
- **canlex_transborder** β€” an offence committed on entering Canada (an
undeclared firearm, cannabis or drugs): transborder criminality under IRPA
s. 36(2.1) and IRPR s. 19 β€” whether the offence is prescribed, whether the
Minister's delegate or the Immigration Division makes the deportation
order (IRPR ss. 228(1)(a.01), 229(1)(d.1)), no rehabilitation, the
contraventions check, TRP and a draft allegation. Foreign nationals only.
- **canlex_list_acts** β€” the corpus inventory and its currency.
- **canlex_whats_new** β€” provisions amended or newly in force since a date.
- **canlex_citing** β€” reverse cross-references: what cites a given section.
- **canlex_toc** β€” an Act's table of contents (Parts and marginal notes).
- **canlex_case** β€” live CanLII case citator (citation graph by neutral
citation or URL).
The server also publishes an MCP prompt (`us_record_screening`, the guided
three-step screening flow) and resources (the answering instructions, the
corpus inventory and its per-type views, and the conviction, equivalency and
rehabilitation methodology texts) that any MCP client can use.
The labour side now carries the full union stack alongside the FB collective
agreement: the CIU National By-Laws (EN/FR), CIU Regulations, Branch Rules
and local modifications, the Branch Elections Kit, the PSAC Constitution,
the union's member guides, and every published site VSSA β€” all bannered as
bargaining-agent documents, distinct from employer policy.
Retrieval runs fully locally inside the container and needs no API key. The
optional case citator reads a CanLII key from the `CANLII_API_KEY` environment
variable. A weekly staleness check (`canlex.refresh --check`, run every
Monday by a Claude Code scheduled task on the maintainer's machine --
RUNBOOK.md, "The staleness watch") watches upstream sources for drift; see
RUNBOOK.md for the maintainer's refresh choreography.
Add this Space's `/mcp` URL (`https://beemer0-canlex.hf.space/mcp`) as a
custom connector in any Claude client, or point any other MCP-capable agent
at it. CanLex is an MCP server only: it has no chat page of its own, and it
calls no hosted model API.
**Call log (2026-09-16):** tool calls to this server, including their
arguments, are logged by the operator, privately, to improve CanLex
(RUNBOOK.md, "Call log"). The server says the same to every MCP client when it
connects (its MCP instructions) and at its root URL,
`https://beemer0-canlex.hf.space/`.
**2026-09-16:** the companion Gradio chat page (the separate `Canlex-web`
Space) and its Google Gemini API integration were retired. The `webapp/`
directory, its tests and the predeploy parity step were removed; the git
history keeps them.