File size: 1,977 Bytes
eba86fd
c0ff3c7
eba86fd
c0ff3c7
eba86fd
 
 
c0ff3c7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
---
title: CanLex Web
sdk: docker
app_port: 7860
pinned: false
---

# CanLex Web (Path B)

A private web front-end for **CanLex**, so people without an MCP-capable AI
client can still ask Canadian legal-research questions.

## How it works -- thin client

This app holds **no copy of the legal corpus**. For each question it:

1. calls the deployed **CanLex MCP server** (`canlex_search_legislation`) to
   retrieve the cited source passages;
2. sends those passages and the question to **Google Gemini Flash**, which
   composes a grounded, cited answer following CanLex's own answering
   instructions;
3. displays the answer, with the retrieved passages shown for review.

Because retrieval stays on the MCP server, a corpus or retrieval change is
deployed once (to the MCP Space) and both the MCP connector and this website
pick it up. Only UI or prompt changes redeploy this Space.

## Required Space secrets

Set these under **Settings -> Variables and secrets**:

| Name | Kind | Purpose |
|------|------|---------|
| `GEMINI_API_KEY` | secret | Free Gemini key from Google AI Studio (https://aistudio.google.com/apikey). |
| `CANLEX_WEB_AUTH` | secret | Login credentials, one `username:password` per line. |

Optional overrides:

| Name | Default |
|------|---------|
| `CANLEX_MCP_URL` | `https://beemer0-canlex.hf.space/mcp` |
| `CANLEX_GEMINI_MODEL` | `gemini-2.5-flash` |

If `CANLEX_WEB_AUTH` is unset the app falls back to an insecure default login
(`canlex` / `canlex`) and logs a warning -- set the secret before real use.

## Make the Space private

Under **Settings -> Change Space visibility**, set the Space to **Private**.
The app then has two layers of protection: Hugging Face gates who can open the
page at all, and Gradio's username/password gates who can use it.

## Run locally

```
pip install -r requirements.txt
# PowerShell:
$env:GEMINI_API_KEY = "your-key"
$env:CANLEX_WEB_AUTH = "me:secret"
python app.py
```

Then open http://localhost:7860.