ca-eli-mcp 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,61 @@
1
+ name: release
2
+
3
+ # Publishes to PyPI (org secret PYPI_API_TOKEN) + the MCP Registry (GitHub OIDC).
4
+ # Trigger: push a version tag, e.g. `git tag v0.1.0 && git push origin v0.1.0`.
5
+ # Pattern matches gb-eli-mcp (classic token; OIDC trusted-publishing hit a
6
+ # persistent invalid-publisher error across the fleet).
7
+
8
+ on:
9
+ push:
10
+ tags:
11
+ - "v*"
12
+ workflow_dispatch: {} # manual re-run of the MCP Registry publish without bumping the package version
13
+
14
+ permissions:
15
+ contents: read
16
+ id-token: write # required for the MCP Registry OIDC login
17
+
18
+ jobs:
19
+ build-and-publish-pypi:
20
+ if: github.event_name == 'push' # only on a version tag; skipped on manual dispatch
21
+ runs-on: ubuntu-latest
22
+ steps:
23
+ - uses: actions/checkout@v4
24
+
25
+ - name: Set up Python
26
+ uses: actions/setup-python@v5
27
+ with:
28
+ python-version: "3.12"
29
+
30
+ - name: Install build tooling
31
+ run: python -m pip install --upgrade build
32
+
33
+ - name: Build sdist + wheel
34
+ run: python -m build
35
+
36
+ - name: Publish to PyPI (org API token)
37
+ uses: pypa/gh-action-pypi-publish@release/v1
38
+ with:
39
+ password: ${{ secrets.PYPI_API_TOKEN }}
40
+
41
+ publish-mcp-registry:
42
+ needs: build-and-publish-pypi
43
+ # run after a successful PyPI publish, OR standalone on manual dispatch
44
+ if: always() && (github.event_name == 'workflow_dispatch' || needs.build-and-publish-pypi.result == 'success')
45
+ runs-on: ubuntu-latest
46
+ permissions:
47
+ contents: read
48
+ id-token: write # OIDC login to the MCP Registry
49
+ steps:
50
+ - uses: actions/checkout@v4
51
+
52
+ - name: Install mcp-publisher
53
+ run: |
54
+ curl -L "https://github.com/modelcontextprotocol/registry/releases/latest/download/mcp-publisher_$(uname -s | tr '[:upper:]' '[:lower:]')_amd64.tar.gz" | tar xz mcp-publisher
55
+ sudo mv mcp-publisher /usr/local/bin/
56
+
57
+ - name: Login to MCP Registry (GitHub OIDC)
58
+ run: mcp-publisher login github-oidc
59
+
60
+ - name: Publish server.json to MCP Registry
61
+ run: mcp-publisher publish
@@ -0,0 +1,20 @@
1
+ # Python
2
+ .venv/
3
+ __pycache__/
4
+ *.py[cod]
5
+ *.egg-info/
6
+ dist/
7
+ build/
8
+ .pytest_cache/
9
+ .mypy_cache/
10
+ .ruff_cache/
11
+
12
+ # Local runtime (never source)
13
+ .matematic/
14
+ *.log
15
+
16
+ # OS
17
+ .DS_Store
18
+ Thumbs.db
19
+
20
+ # Note: tests/fixtures/* ARE committed - public Finlex data needed for tests.
@@ -0,0 +1,45 @@
1
+ # Discovery notes - Canada
2
+
3
+ Date: 2026-07-06.
4
+
5
+ ## Why Canada, and why now
6
+
7
+ An earlier scouting pass (2026-07-04) only looked at CanLII (case law) for
8
+ Canada and ruled it out on ToS grounds. It did not check the Justice Laws
9
+ Website for legislation. Live probing on 2026-07-06 found it works exactly
10
+ like the cleanest connectors in this fleet: keyless, direct XML per
11
+ document, bilingual, both acts and regulations on the same URL pattern.
12
+ Market size (the Federation of Law Societies of Canada's own "About Us"
13
+ page, flsc.ca/about-us/, states law societies regulate "more than 136,000
14
+ lawyers" - a standing figure, not verified against a specific year during
15
+ this session) combined with this architecture made it the clear pick over
16
+ Mexico in this round - Mexico's federal law
17
+ portals (`diputados.gob.mx/LeyesBiblio`, `ordenjuridico.gob.mx`,
18
+ `dof.gob.mx`) returned connection failures on every endpoint tried and have
19
+ no documented API; still DEFER, as in the earlier sweep.
20
+
21
+ ## What's confirmed live
22
+
23
+ - `https://laws-lois.justice.gc.ca/eng/XML/C-46.xml` - 200, well-formed XML,
24
+ `lims` namespace, consolidation date attributes, no external DTD (unlike
25
+ Ireland's ISB, which needed the DTD workaround).
26
+ - `https://laws-lois.justice.gc.ca/fra/XML/C-46.xml` - French version, 200.
27
+ - `https://laws-lois.justice.gc.ca/eng/XML/SOR-2018-151.xml` - a regulation
28
+ on the same path pattern, 200.
29
+ - `https://laws-lois.justice.gc.ca/eng/acts/C-46/index.html` and
30
+ `https://laws-lois.justice.gc.ca/eng/regulations/SOR-2018-151/index.html`
31
+ - the public HTML pages, both 200 (note: acts and regulations live under
32
+ different path segments, `acts/` vs `regulations/` - this connector
33
+ detects which one to use from the code prefix).
34
+
35
+ ## Not resolved
36
+
37
+ - No confirmed reuse license for Justice Laws Website content beyond "it is
38
+ the official public consolidation, meant for public use" - flagged in
39
+ SOURCES.md, same caution class as other Crown/amtliche-Werke-style
40
+ government legal text. Does not block a keyless-fetch connector (we are
41
+ not redistributing a bulk copy), but should be confirmed before any
42
+ bulk/offline mode.
43
+ - `laws-lois-api.justice.gc.ca`, referenced in some older documentation
44
+ found via web search, returned 404 on every path tried - likely retired
45
+ or never public. Not used.
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,78 @@
1
+ Metadata-Version: 2.4
2
+ Name: ca-eli-mcp
3
+ Version: 0.1.0
4
+ Summary: MCP server for Canadian federal legislation (Justice Laws Website) with verifiable citations.
5
+ Project-URL: Repository, https://github.com/matematicsolutions/ca-eli-mcp
6
+ Project-URL: Issues, https://github.com/matematicsolutions/ca-eli-mcp/issues
7
+ Project-URL: Homepage, https://matematic.co
8
+ Author-email: Matematic Solutions <kontakt@matematic.co>, Wieslaw Mazur <mazur.wieslaw2022@gmail.com>
9
+ License: Apache-2.0
10
+ License-File: LICENSE
11
+ Keywords: canada,justice-laws,law,legaltech,mcp
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Legal Industry
14
+ Classifier: License :: OSI Approved :: Apache Software License
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Topic :: Office/Business
20
+ Requires-Python: >=3.11
21
+ Requires-Dist: anyio>=4.3
22
+ Requires-Dist: diskcache>=5.6
23
+ Requires-Dist: fastmcp>=0.2.0
24
+ Requires-Dist: httpx>=0.27
25
+ Provides-Extra: dev
26
+ Requires-Dist: mypy>=1.10; extra == 'dev'
27
+ Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
28
+ Requires-Dist: pytest>=8.0; extra == 'dev'
29
+ Requires-Dist: ruff>=0.5; extra == 'dev'
30
+ Description-Content-Type: text/markdown
31
+
32
+ # ca-eli-mcp
33
+
34
+ <!-- mcp-name: io.github.matematicsolutions/ca-eli-mcp -->
35
+
36
+ MCP server for Canadian federal legislation via the Justice Laws Website
37
+ (laws-lois.justice.gc.ca), the Department of Justice Canada's official
38
+ source for consolidated Acts and regulations. Bilingual (English/French).
39
+
40
+ ## What this is not
41
+
42
+ - **No free-text search** - the Justice Laws Website has no search API of
43
+ its own. This connector is by-code only (the same limitation as
44
+ `ie-eli-mcp` for Ireland): you need to already know the code (e.g.
45
+ `"C-46"` for the Criminal Code) or a short title to look one up.
46
+ - **Federal only** - provincial and territorial legislation is out of scope.
47
+ - **No case law** - CanLII's terms of service forbid bulk redistribution and
48
+ its content API requires a per-identity key, which breaks the
49
+ zero-cloud pattern this connector otherwise follows. Not attempted here.
50
+
51
+ ## Tools
52
+
53
+ | Tool | Purpose |
54
+ |---|---|
55
+ | `ca_get_document` | Metadata (title, in-force status, last-consolidated date) for one act or regulation |
56
+ | `ca_get_text` | Full consolidated XML text of the same document |
57
+
58
+ Every response carries `lex_uri` (the XML source), `source_url` (the public
59
+ HTML page), and `human_readable_citation` (e.g. `"Criminal Code (C-46)"`).
60
+
61
+ ## Install
62
+
63
+ ```bash
64
+ pip install ca-eli-mcp
65
+ ```
66
+
67
+ ## Configuration
68
+
69
+ | Env var | Default |
70
+ |---|---|
71
+ | `CA_ELI_CACHE_DIR` | `~/.matematic/cache/ca-eli` |
72
+ | `CA_ELI_AUDIT_DIR` | `~/.matematic/audit` |
73
+ | `CA_ELI_BASE_URL` | `https://laws-lois.justice.gc.ca` |
74
+
75
+ ## License
76
+
77
+ Apache-2.0 (code). Justice Laws Website content is Government of Canada
78
+ material (see [SOURCES.md](SOURCES.md)).
@@ -0,0 +1,47 @@
1
+ # ca-eli-mcp
2
+
3
+ <!-- mcp-name: io.github.matematicsolutions/ca-eli-mcp -->
4
+
5
+ MCP server for Canadian federal legislation via the Justice Laws Website
6
+ (laws-lois.justice.gc.ca), the Department of Justice Canada's official
7
+ source for consolidated Acts and regulations. Bilingual (English/French).
8
+
9
+ ## What this is not
10
+
11
+ - **No free-text search** - the Justice Laws Website has no search API of
12
+ its own. This connector is by-code only (the same limitation as
13
+ `ie-eli-mcp` for Ireland): you need to already know the code (e.g.
14
+ `"C-46"` for the Criminal Code) or a short title to look one up.
15
+ - **Federal only** - provincial and territorial legislation is out of scope.
16
+ - **No case law** - CanLII's terms of service forbid bulk redistribution and
17
+ its content API requires a per-identity key, which breaks the
18
+ zero-cloud pattern this connector otherwise follows. Not attempted here.
19
+
20
+ ## Tools
21
+
22
+ | Tool | Purpose |
23
+ |---|---|
24
+ | `ca_get_document` | Metadata (title, in-force status, last-consolidated date) for one act or regulation |
25
+ | `ca_get_text` | Full consolidated XML text of the same document |
26
+
27
+ Every response carries `lex_uri` (the XML source), `source_url` (the public
28
+ HTML page), and `human_readable_citation` (e.g. `"Criminal Code (C-46)"`).
29
+
30
+ ## Install
31
+
32
+ ```bash
33
+ pip install ca-eli-mcp
34
+ ```
35
+
36
+ ## Configuration
37
+
38
+ | Env var | Default |
39
+ |---|---|
40
+ | `CA_ELI_CACHE_DIR` | `~/.matematic/cache/ca-eli` |
41
+ | `CA_ELI_AUDIT_DIR` | `~/.matematic/audit` |
42
+ | `CA_ELI_BASE_URL` | `https://laws-lois.justice.gc.ca` |
43
+
44
+ ## License
45
+
46
+ Apache-2.0 (code). Justice Laws Website content is Government of Canada
47
+ material (see [SOURCES.md](SOURCES.md)).
@@ -0,0 +1,32 @@
1
+ # Sources
2
+
3
+ ## Justice Laws Website (`laws-lois.justice.gc.ca`)
4
+
5
+ - **Origin**: Department of Justice Canada.
6
+ - **License**: Government of Canada material. No explicit reuse license was
7
+ found on the site itself during discovery; treat as informational-use
8
+ government material pending confirmation, same caution class as amtliche
9
+ Werke in Germany (see `mcp-de-legal`'s THIRD_PARTY notes for the pattern).
10
+ This connector fetches from the official live site directly - it does not
11
+ vendor or redistribute the official GitHub mirror
12
+ (`justicecanada/laws-lois-xml`, license field `NOASSERTION` on GitHub),
13
+ which was used only as a confirmation that the XML corpus is officially
14
+ maintained and actively updated (last push 2026-07-02).
15
+ - **Access**: keyless, direct XML at `/{lang}/XML/{code}.xml` (`lang` is
16
+ `eng` or `fra`), confirmed live 2026-07-06 for both acts (e.g. `C-46`,
17
+ the Criminal Code) and regulations (e.g. `SOR-2018-151`).
18
+ - **Coverage**: federal Acts and regulations only. No search endpoint - by
19
+ code only.
20
+
21
+ ## Not covered (out of scope for this connector)
22
+
23
+ - **CanLII** (case law) - terms of service forbid bulk redistribution,
24
+ content API requires a per-identity key. An earlier scouting pass
25
+ (2026-07-04) already ruled this out for the zero-cloud pattern this fleet
26
+ follows; not revisited here.
27
+ - **Provincial/territorial legislation** - each province publishes
28
+ separately; not surveyed in this pass.
29
+ - **GovInfo-style bulk archive** - the official GitHub mirror
30
+ (`justicecanada/laws-lois-xml`) could support a future offline/bulk mode,
31
+ but its license is unclear (GitHub reports `NOASSERTION`) - would need
32
+ confirmation before vendoring.
@@ -0,0 +1,4 @@
1
+ {
2
+ "$schema": "https://glama.ai/mcp/schemas/server.json",
3
+ "maintainers": ["mazurwieslaw2022-cmd"]
4
+ }
@@ -0,0 +1,65 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "ca-eli-mcp"
7
+ version = "0.1.0"
8
+ description = "MCP server for Canadian federal legislation (Justice Laws Website) with verifiable citations."
9
+ readme = "README.md"
10
+ license = { text = "Apache-2.0" }
11
+ requires-python = ">=3.11"
12
+ authors = [
13
+ { name = "Matematic Solutions", email = "kontakt@matematic.co" },
14
+ { name = "Wieslaw Mazur", email = "mazur.wieslaw2022@gmail.com" },
15
+ ]
16
+ keywords = ["mcp", "legaltech", "canada", "justice-laws", "law"]
17
+ classifiers = [
18
+ "Development Status :: 3 - Alpha",
19
+ "Intended Audience :: Legal Industry",
20
+ "License :: OSI Approved :: Apache Software License",
21
+ "Operating System :: OS Independent",
22
+ "Programming Language :: Python :: 3",
23
+ "Programming Language :: Python :: 3.11",
24
+ "Programming Language :: Python :: 3.12",
25
+ "Topic :: Office/Business",
26
+ ]
27
+ dependencies = [
28
+ "fastmcp>=0.2.0",
29
+ "httpx>=0.27",
30
+ "diskcache>=5.6",
31
+ "anyio>=4.3",
32
+ ]
33
+
34
+ [project.optional-dependencies]
35
+ dev = [
36
+ "pytest>=8.0",
37
+ "pytest-asyncio>=0.23",
38
+ "mypy>=1.10",
39
+ "ruff>=0.5",
40
+ ]
41
+
42
+ [project.urls]
43
+ Repository = "https://github.com/matematicsolutions/ca-eli-mcp"
44
+ Issues = "https://github.com/matematicsolutions/ca-eli-mcp/issues"
45
+ Homepage = "https://matematic.co"
46
+
47
+ [project.scripts]
48
+ ca-eli-mcp = "ca_eli_mcp.server:main"
49
+
50
+ [tool.hatch.build.targets.wheel]
51
+ packages = ["src/ca_eli_mcp"]
52
+
53
+ [tool.ruff]
54
+ line-length = 100
55
+ target-version = "py311"
56
+
57
+ [tool.ruff.lint]
58
+ select = ["E", "F", "I", "B", "UP", "N", "SIM", "RUF"]
59
+
60
+ [tool.ruff.lint.per-file-ignores]
61
+ "src/ca_eli_mcp/server.py" = ["E501"]
62
+
63
+ [tool.pytest.ini_options]
64
+ asyncio_mode = "auto"
65
+ testpaths = ["tests"]
@@ -0,0 +1,22 @@
1
+ {
2
+ "$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
3
+ "name": "io.github.matematicsolutions/ca-eli-mcp",
4
+ "description": "MCP server for Canadian federal legislation (Justice Laws Website), verifiable citations.",
5
+ "version": "0.1.0",
6
+ "repository": {
7
+ "url": "https://github.com/matematicsolutions/ca-eli-mcp",
8
+ "source": "github"
9
+ },
10
+ "packages": [
11
+ {
12
+ "registryType": "pypi",
13
+ "registryBaseUrl": "https://pypi.org",
14
+ "identifier": "ca-eli-mcp",
15
+ "version": "0.1.0",
16
+ "runtimeHint": "uvx",
17
+ "transport": {
18
+ "type": "stdio"
19
+ }
20
+ }
21
+ ]
22
+ }
@@ -0,0 +1,3 @@
1
+ """ca-eli-mcp - MCP connector for Canadian federal legislation (Justice Laws Website)."""
2
+
3
+ __version__ = "0.1.0"
@@ -0,0 +1,94 @@
1
+ """JSONL audit logger for AI Act art. 12.
2
+
3
+ Every call to every MCP tool writes one JSON line to:
4
+
5
+ ~/.matematic/audit/ca-eli-mcp.jsonl
6
+
7
+ (or to the directory given by ``CA_ELI_AUDIT_DIR``).
8
+
9
+ If the write fails, the tool returns an error instead of silently continuing
10
+ (Art. 2 CONSTITUTION.md). Inherited verbatim from the other eu-legal-mcp connectors.
11
+ """
12
+
13
+ from __future__ import annotations
14
+
15
+ import hashlib
16
+ import json
17
+ import os
18
+ import time
19
+ from datetime import UTC, datetime
20
+ from pathlib import Path
21
+ from typing import Any, Literal
22
+
23
+ Status = Literal["ok", "error"]
24
+
25
+ _AUDIT_FILENAME = "ca-eli-mcp.jsonl"
26
+
27
+
28
+ def _resolve_audit_dir() -> Path:
29
+ env = os.environ.get("CA_ELI_AUDIT_DIR")
30
+ if env:
31
+ return Path(env).expanduser()
32
+ return Path.home() / ".matematic" / "audit"
33
+
34
+
35
+ def hash_input(payload: Any) -> str:
36
+ """SHA-256 of a stable JSON serialization of the input."""
37
+ canonical = json.dumps(payload, sort_keys=True, separators=(",", ":"), default=str)
38
+ return hashlib.sha256(canonical.encode("utf-8")).hexdigest()
39
+
40
+
41
+ class AuditLogger:
42
+ """Append-only JSONL logger."""
43
+
44
+ def __init__(self, audit_dir: Path | None = None) -> None:
45
+ self._dir = (audit_dir or _resolve_audit_dir()).expanduser()
46
+ self._dir.mkdir(parents=True, exist_ok=True)
47
+ self._path = self._dir / _AUDIT_FILENAME
48
+
49
+ @property
50
+ def path(self) -> Path:
51
+ return self._path
52
+
53
+ def log(
54
+ self,
55
+ *,
56
+ tool: str,
57
+ input_hash: str,
58
+ output_count_or_size: int,
59
+ duration_ms: int,
60
+ status: Status,
61
+ error: str | None = None,
62
+ ) -> None:
63
+ record: dict[str, Any] = {
64
+ "ts": datetime.now(UTC).isoformat(timespec="milliseconds"),
65
+ "tool": tool,
66
+ "input_hash": input_hash,
67
+ "output_count_or_size": output_count_or_size,
68
+ "duration_ms": duration_ms,
69
+ "status": status,
70
+ }
71
+ if error is not None:
72
+ record["error"] = error[:500]
73
+ line = json.dumps(record, ensure_ascii=False, separators=(",", ":")) + "\n"
74
+ with self._path.open("a", encoding="utf-8") as fh:
75
+ fh.write(line)
76
+
77
+
78
+ class _Timer:
79
+ """Context-managed timer in milliseconds."""
80
+
81
+ def __init__(self) -> None:
82
+ self._t0 = 0.0
83
+ self.duration_ms = 0
84
+
85
+ def __enter__(self) -> _Timer:
86
+ self._t0 = time.perf_counter()
87
+ return self
88
+
89
+ def __exit__(self, *_exc: object) -> None:
90
+ self.duration_ms = int((time.perf_counter() - self._t0) * 1000)
91
+
92
+
93
+ def timer() -> _Timer:
94
+ return _Timer()
@@ -0,0 +1,56 @@
1
+ """Thin wrapper over diskcache - key is URL, TTL per category.
2
+
3
+ Inherited verbatim from the other eu-legal-mcp connectors (only env var and dir differ).
4
+ """
5
+
6
+ from __future__ import annotations
7
+
8
+ import os
9
+ from pathlib import Path
10
+ from typing import Any
11
+
12
+ from diskcache import Cache
13
+
14
+ DEFAULT_TTL_ACT = 24 * 60 * 60
15
+ DEFAULT_TTL_LIST = 60 * 60
16
+ DEFAULT_TTL_DICT = 7 * 24 * 60 * 60
17
+ DEFAULT_TTL_CHANGES = 5 * 60
18
+
19
+
20
+ def _resolve_cache_dir() -> Path:
21
+ env = os.environ.get("CA_ELI_CACHE_DIR")
22
+ if env:
23
+ return Path(env).expanduser()
24
+ return Path.home() / ".matematic" / "cache" / "ca-eli"
25
+
26
+
27
+ class HttpCache:
28
+ """Caches HTTP responses (already deserialized to dict / str)."""
29
+
30
+ def __init__(self, cache_dir: Path | None = None) -> None:
31
+ self._dir = (cache_dir or _resolve_cache_dir()).expanduser()
32
+ self._dir.mkdir(parents=True, exist_ok=True)
33
+ self._cache: Cache = Cache(str(self._dir))
34
+
35
+ def get(self, key: str) -> Any:
36
+ return self._cache.get(key, default=None)
37
+
38
+ def set(self, key: str, value: Any, ttl: int) -> None:
39
+ self._cache.set(key, value, expire=ttl)
40
+
41
+ def close(self) -> None:
42
+ self._cache.close()
43
+
44
+ @staticmethod
45
+ def ttl_for(category: str) -> int:
46
+ match category:
47
+ case "act":
48
+ return DEFAULT_TTL_ACT
49
+ case "list" | "search":
50
+ return DEFAULT_TTL_LIST
51
+ case "dict":
52
+ return DEFAULT_TTL_DICT
53
+ case "changes":
54
+ return DEFAULT_TTL_CHANGES
55
+ case _:
56
+ return DEFAULT_TTL_LIST
@@ -0,0 +1,54 @@
1
+ """Citation contract for ca-eli-mcp.
2
+
3
+ The Justice Laws Website has no formal ELI/ECLI identifier, but every act and
4
+ regulation has a stable "code" (e.g. "C-46" for the Criminal Code, "SOR-2018-151"
5
+ for a regulation) that resolves to both a machine-readable XML document and a
6
+ public HTML page at predictable URLs. We use the code directly rather than
7
+ inventing anything. Metadata is extracted by regex from the header block - the
8
+ same tolerant approach as ie-eli-mcp, since the LIMS namespace/attribute style
9
+ is easier to pull out this way than via a full namespace-aware XML parse.
10
+ """
11
+
12
+ from __future__ import annotations
13
+
14
+ import re
15
+
16
+ from .models import Citation, Document
17
+
18
+ _XML_URL = "https://laws-lois.justice.gc.ca/{lang}/XML/{code}.xml"
19
+ _HTML_URL = "https://laws-lois.justice.gc.ca/{lang}/{kind}/{code}/index.html"
20
+
21
+ _REGULATION_PREFIXES = ("SOR-", "SI-", "C.R.C.")
22
+
23
+
24
+ def _kind_for(code: str) -> str:
25
+ return "regulations" if code.upper().startswith(_REGULATION_PREFIXES) else "acts"
26
+
27
+
28
+ def parse_metadata(code: str, lang: str, xml_text: str) -> Document:
29
+ long_title_m = re.search(r"<LongTitle[^>]*>(.*?)</LongTitle>", xml_text, re.S)
30
+ short_title_m = re.search(r"<ShortTitle[^>]*>(.*?)</ShortTitle>", xml_text, re.S)
31
+ current_date_m = re.search(r'lims:current-date="([^"]+)"', xml_text)
32
+ in_force_m = re.search(r'\bin-force="([^"]+)"', xml_text)
33
+
34
+ def _clean(m: re.Match[str] | None) -> str | None:
35
+ if not m:
36
+ return None
37
+ return re.sub(r"<[^>]+>", "", m.group(1)).strip() or None
38
+
39
+ return Document(
40
+ code=code,
41
+ lang=lang,
42
+ long_title=_clean(long_title_m),
43
+ short_title=_clean(short_title_m),
44
+ current_date=current_date_m.group(1) if current_date_m else None,
45
+ in_force=in_force_m.group(1) if in_force_m else None,
46
+ )
47
+
48
+
49
+ def build_citation(d: Document) -> Citation:
50
+ xml_url = _XML_URL.format(lang=d.lang, code=d.code)
51
+ html_url = _HTML_URL.format(lang=d.lang, kind=_kind_for(d.code), code=d.code)
52
+ title = d.short_title or d.long_title or d.code
53
+ human = f"{title} ({d.code})"
54
+ return Citation(lex_uri=xml_url, human_readable_citation=human, source_url=html_url)
@@ -0,0 +1,75 @@
1
+ """Async httpx client for the Justice Laws Website (laws-lois.justice.gc.ca).
2
+
3
+ Keyless. Every act and regulation is addressed by a stable "code" (e.g.
4
+ "C-46" or "SOR-2018-151") and served as XML at a predictable URL - no
5
+ free-text search API exists on the site itself, so this connector is
6
+ by-coordinate only, same as ie-eli-mcp.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ import anyio
12
+ import httpx
13
+
14
+ from .cache import HttpCache
15
+
16
+ DEFAULT_BASE_URL = "https://laws-lois.justice.gc.ca"
17
+ DEFAULT_TIMEOUT = httpx.Timeout(40.0, connect=10.0)
18
+ USER_AGENT = "ca-eli-mcp/0.1.0 (+https://github.com/matematicsolutions/ca-eli-mcp)"
19
+
20
+ _RETRY_STATUS = frozenset({429, 500, 502, 503, 504})
21
+ _MAX_ATTEMPTS = 3
22
+
23
+
24
+ class JusticeLawsClient:
25
+ """Async client. Use as ``async with JusticeLawsClient() as c: ...``."""
26
+
27
+ def __init__(
28
+ self,
29
+ base_url: str = DEFAULT_BASE_URL,
30
+ cache: HttpCache | None = None,
31
+ timeout: httpx.Timeout = DEFAULT_TIMEOUT,
32
+ ) -> None:
33
+ self.base_url = base_url.rstrip("/")
34
+ self._cache = cache or HttpCache()
35
+ self._http = httpx.AsyncClient(
36
+ timeout=timeout,
37
+ headers={"User-Agent": USER_AGENT, "Accept": "*/*"},
38
+ )
39
+
40
+ async def __aenter__(self) -> JusticeLawsClient:
41
+ return self
42
+
43
+ async def __aexit__(self, *_exc: object) -> None:
44
+ await self.aclose()
45
+
46
+ async def aclose(self) -> None:
47
+ await self._http.aclose()
48
+ self._cache.close()
49
+
50
+ async def _get_xml(self, path: str, *, category: str) -> str:
51
+ url = f"{self.base_url}{path}"
52
+ cached = self._cache.get(url)
53
+ if cached is not None and isinstance(cached, str):
54
+ return cached
55
+ last_exc: Exception | None = None
56
+ for attempt in range(_MAX_ATTEMPTS):
57
+ try:
58
+ resp = await self._http.get(url)
59
+ resp.raise_for_status()
60
+ self._cache.set(url, resp.text, ttl=HttpCache.ttl_for(category))
61
+ return resp.text
62
+ except httpx.HTTPStatusError as exc:
63
+ last_exc = exc
64
+ if exc.response.status_code not in _RETRY_STATUS or attempt == _MAX_ATTEMPTS - 1:
65
+ raise
66
+ except (httpx.TransportError, httpx.TimeoutException) as exc:
67
+ last_exc = exc
68
+ if attempt == _MAX_ATTEMPTS - 1:
69
+ raise
70
+ await anyio.sleep(0.5 * (2**attempt))
71
+ assert last_exc is not None
72
+ raise last_exc
73
+
74
+ async def get_xml(self, code: str, lang: str = "eng") -> str:
75
+ return await self._get_xml(f"/{lang}/XML/{code}.xml", category="act")
@@ -0,0 +1,22 @@
1
+ """Plain dataclasses mirroring the Justice Laws Website consolidated XML header."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from dataclasses import dataclass
6
+
7
+
8
+ @dataclass(frozen=True)
9
+ class Document:
10
+ code: str
11
+ lang: str
12
+ long_title: str | None
13
+ short_title: str | None
14
+ current_date: str | None
15
+ in_force: str | None
16
+
17
+
18
+ @dataclass(frozen=True)
19
+ class Citation:
20
+ lex_uri: str
21
+ human_readable_citation: str
22
+ source_url: str
@@ -0,0 +1,206 @@
1
+ """FastMCP entry point - Canadian federal legislation (Justice Laws Website) tools.
2
+
3
+ Run:
4
+
5
+ python -m ca_eli_mcp.server
6
+
7
+ Configuration via env:
8
+
9
+ - ``CA_ELI_CACHE_DIR`` (default ``~/.matematic/cache/ca-eli``)
10
+ - ``CA_ELI_AUDIT_DIR`` (default ``~/.matematic/audit``)
11
+ - ``CA_ELI_BASE_URL`` (default ``https://laws-lois.justice.gc.ca``)
12
+ """
13
+
14
+ from __future__ import annotations
15
+
16
+ import os
17
+
18
+ import httpx
19
+ from fastmcp import FastMCP
20
+ from mcp.types import ToolAnnotations
21
+
22
+ from .audit import AuditLogger, hash_input, timer
23
+ from .citations import build_citation, parse_metadata
24
+ from .client import DEFAULT_BASE_URL, JusticeLawsClient
25
+
26
+ INSTRUCTIONS = """\
27
+ This MCP server exposes the Justice Laws Website (laws-lois.justice.gc.ca), the Department of Justice Canada's official consolidated Acts and regulations. Bilingual (English/French).
28
+
29
+ ## Call order
30
+
31
+ 1. `ca_get_document` - metadata (title, in-force status, last-consolidated date) for one act or regulation by its `code` (e.g. `"C-46"` for the Criminal Code, `"SOR-2018-151"` for a regulation).
32
+ 2. `ca_get_text` - the full consolidated XML of the same document.
33
+
34
+ ## Hard constraints
35
+
36
+ - **No free-text search** - the Justice Laws Website is addressed by code, not keywords (same limitation as ie-eli-mcp for Ireland). Discover a code from an external reference (a citation the user already has, or a known short title) before calling these tools.
37
+ - **Every response has `human_readable_citation` + `source_url`** - cite both to the user.
38
+ - **No full-text search across all Canadian law** - this is federal legislation only; provincial/territorial law is out of scope.
39
+ - **Audit log JSONL** - every tool call appends to `~/.matematic/audit/ca-eli-mcp.jsonl`.
40
+
41
+ ## Error iteration
42
+
43
+ Tools return a structured error with a `[code]` prefix:
44
+ - `invalid_arg` - a parameter is missing or malformed.
45
+ - `not_found` - no act or regulation exists for that code.
46
+ - `upstream_error` - a Justice Laws Website error (HTTP, timeout). Retry once before surfacing.
47
+
48
+ ## Response style
49
+
50
+ - Cite documents as `human_readable_citation`: "Criminal Code (C-46)".
51
+ - NEVER invent a code or title - take each from the tool output.
52
+ """
53
+
54
+
55
+ class ToolError(Exception):
56
+ """Structured error for ca-eli MCP tools - visible to the LLM with a [code] prefix."""
57
+
58
+ VALID_CODES = frozenset({"invalid_arg", "not_found", "upstream_error"})
59
+
60
+ def __init__(self, code: str, message: str):
61
+ if code not in self.VALID_CODES:
62
+ raise ValueError(f"Unknown ToolError code: {code}. Valid: {sorted(self.VALID_CODES)}")
63
+ self.code = code
64
+ super().__init__(f"[{code}] {message}")
65
+
66
+
67
+ READ_ONLY = ToolAnnotations(
68
+ readOnlyHint=True,
69
+ idempotentHint=True,
70
+ destructiveHint=False,
71
+ openWorldHint=True,
72
+ )
73
+
74
+ mcp: FastMCP = FastMCP(name="ca-eli-mcp", instructions=INSTRUCTIONS)
75
+
76
+ _VALID_LANGS = frozenset({"eng", "fra"})
77
+
78
+
79
+ def _base_url() -> str:
80
+ return os.environ.get("CA_ELI_BASE_URL", DEFAULT_BASE_URL).rstrip("/")
81
+
82
+
83
+ def _audit() -> AuditLogger:
84
+ return AuditLogger()
85
+
86
+
87
+ def _check_args(code: str, lang: str) -> None:
88
+ if not code or not code.strip():
89
+ raise ToolError("invalid_arg", "code must be a non-empty string, e.g. 'C-46'.")
90
+ if lang not in _VALID_LANGS:
91
+ raise ToolError("invalid_arg", f"lang={lang!r} must be one of {sorted(_VALID_LANGS)}.")
92
+
93
+
94
+ def _map_upstream(exc: Exception) -> Exception:
95
+ if isinstance(exc, httpx.HTTPStatusError) and exc.response.status_code == 404:
96
+ return ToolError("not_found", "No act or regulation found at that code on the Justice Laws Website.")
97
+ if isinstance(exc, (httpx.HTTPStatusError, httpx.TransportError, httpx.TimeoutException)):
98
+ return ToolError("upstream_error", f"Justice Laws Website error: {type(exc).__name__}: {exc}")
99
+ return exc
100
+
101
+
102
+ # ---------------------------------------------------------------------------
103
+ # ca_get_document
104
+ # ---------------------------------------------------------------------------
105
+
106
+
107
+ @mcp.tool(annotations=READ_ONLY)
108
+ async def ca_get_document(code: str, lang: str = "eng") -> dict:
109
+ """Fetch metadata for a Canadian federal act or regulation.
110
+
111
+ Args:
112
+ code: e.g. ``"C-46"`` (Criminal Code) or ``"SOR-2018-151"`` (a regulation).
113
+ lang: ``"eng"`` or ``"fra"`` (default ``"eng"``).
114
+
115
+ Returns:
116
+ A dict with ``code``, ``lang``, ``long_title``, ``short_title``,
117
+ ``current_date``, ``in_force``, ``lex_uri``, ``human_readable_citation``,
118
+ ``source_url``.
119
+ """
120
+ audit = _audit()
121
+ _check_args(code, lang)
122
+ input_hash = hash_input({"code": code, "lang": lang})
123
+
124
+ with timer() as t:
125
+ try:
126
+ async with JusticeLawsClient(base_url=_base_url()) as client:
127
+ xml_text = await client.get_xml(code, lang)
128
+ except Exception as exc:
129
+ audit.log(tool="ca_get_document", input_hash=input_hash, output_count_or_size=0,
130
+ duration_ms=t.duration_ms if t.duration_ms else 0, status="error",
131
+ error=f"{type(exc).__name__}: {exc}")
132
+ raise _map_upstream(exc) from exc
133
+
134
+ doc = parse_metadata(code, lang, xml_text)
135
+ citation = build_citation(doc)
136
+ result = {
137
+ "code": doc.code,
138
+ "lang": doc.lang,
139
+ "long_title": doc.long_title,
140
+ "short_title": doc.short_title,
141
+ "current_date": doc.current_date,
142
+ "in_force": doc.in_force,
143
+ "lex_uri": citation.lex_uri,
144
+ "human_readable_citation": citation.human_readable_citation,
145
+ "source_url": citation.source_url,
146
+ }
147
+ audit.log(tool="ca_get_document", input_hash=input_hash, output_count_or_size=1,
148
+ duration_ms=t.duration_ms, status="ok")
149
+ return result
150
+
151
+
152
+ # ---------------------------------------------------------------------------
153
+ # ca_get_text
154
+ # ---------------------------------------------------------------------------
155
+
156
+
157
+ @mcp.tool(annotations=READ_ONLY)
158
+ async def ca_get_text(code: str, lang: str = "eng") -> dict:
159
+ """Fetch the full consolidated XML text of a Canadian federal act or regulation.
160
+
161
+ Args:
162
+ code: e.g. ``"C-46"``.
163
+ lang: ``"eng"`` or ``"fra"`` (default ``"eng"``).
164
+
165
+ Returns:
166
+ A dict with ``code``, ``lang``, ``lex_uri``, ``human_readable_citation``,
167
+ ``source_url``, ``content`` (raw XML), ``byte_size``.
168
+ """
169
+ audit = _audit()
170
+ _check_args(code, lang)
171
+ input_hash = hash_input({"code": code, "lang": lang})
172
+
173
+ with timer() as t:
174
+ try:
175
+ async with JusticeLawsClient(base_url=_base_url()) as client:
176
+ xml_text = await client.get_xml(code, lang)
177
+ except Exception as exc:
178
+ audit.log(tool="ca_get_text", input_hash=input_hash, output_count_or_size=0,
179
+ duration_ms=t.duration_ms if t.duration_ms else 0, status="error",
180
+ error=f"{type(exc).__name__}: {exc}")
181
+ raise _map_upstream(exc) from exc
182
+
183
+ doc = parse_metadata(code, lang, xml_text)
184
+ citation = build_citation(doc)
185
+ byte_size = len(xml_text.encode("utf-8"))
186
+ result = {
187
+ "code": code,
188
+ "lang": lang,
189
+ "lex_uri": citation.lex_uri,
190
+ "human_readable_citation": citation.human_readable_citation,
191
+ "source_url": citation.source_url,
192
+ "content": xml_text,
193
+ "byte_size": byte_size,
194
+ }
195
+ audit.log(tool="ca_get_text", input_hash=input_hash, output_count_or_size=byte_size,
196
+ duration_ms=t.duration_ms, status="ok")
197
+ return result
198
+
199
+
200
+ def main() -> None:
201
+ """Run the MCP server over stdio (default for Claude Code)."""
202
+ mcp.run()
203
+
204
+
205
+ if __name__ == "__main__":
206
+ main()
@@ -0,0 +1,31 @@
1
+ """Live smoke test against the real Justice Laws Website. Network required."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import pytest
6
+
7
+ from ca_eli_mcp.citations import build_citation, parse_metadata
8
+ from ca_eli_mcp.client import JusticeLawsClient
9
+
10
+
11
+ @pytest.mark.asyncio
12
+ async def test_get_act() -> None:
13
+ async with JusticeLawsClient() as client:
14
+ xml_text = await client.get_xml("C-46", "eng")
15
+ doc = parse_metadata("C-46", "eng", xml_text)
16
+ citation = build_citation(doc)
17
+
18
+ assert doc.short_title == "Criminal Code"
19
+ assert citation.human_readable_citation == "Criminal Code (C-46)"
20
+ assert citation.lex_uri == "https://laws-lois.justice.gc.ca/eng/XML/C-46.xml"
21
+ assert citation.source_url == "https://laws-lois.justice.gc.ca/eng/acts/C-46/index.html"
22
+
23
+
24
+ @pytest.mark.asyncio
25
+ async def test_get_regulation_uses_regulations_path() -> None:
26
+ async with JusticeLawsClient() as client:
27
+ xml_text = await client.get_xml("SOR-2018-151", "eng")
28
+ doc = parse_metadata("SOR-2018-151", "eng", xml_text)
29
+ citation = build_citation(doc)
30
+
31
+ assert "regulations" in citation.source_url