@ansvar/rwandan-law-mcp 1.0.0

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.
Files changed (124) hide show
  1. package/LICENSE +110 -0
  2. package/README.md +83 -0
  3. package/dist/__tests__/contract/golden.test.d.ts +9 -0
  4. package/dist/__tests__/contract/golden.test.d.ts.map +1 -0
  5. package/dist/__tests__/contract/golden.test.js +76 -0
  6. package/dist/__tests__/contract/golden.test.js.map +1 -0
  7. package/dist/api/health.d.ts +3 -0
  8. package/dist/api/health.d.ts.map +1 -0
  9. package/dist/api/health.js +101 -0
  10. package/dist/api/health.js.map +1 -0
  11. package/dist/api/mcp.d.ts +3 -0
  12. package/dist/api/mcp.d.ts.map +1 -0
  13. package/dist/api/mcp.js +119 -0
  14. package/dist/api/mcp.js.map +1 -0
  15. package/dist/scripts/build-db.d.ts +11 -0
  16. package/dist/scripts/build-db.d.ts.map +1 -0
  17. package/dist/scripts/build-db.js +375 -0
  18. package/dist/scripts/build-db.js.map +1 -0
  19. package/dist/scripts/drift-detect.d.ts +9 -0
  20. package/dist/scripts/drift-detect.d.ts.map +1 -0
  21. package/dist/scripts/drift-detect.js +62 -0
  22. package/dist/scripts/drift-detect.js.map +1 -0
  23. package/dist/scripts/ingest.d.ts +10 -0
  24. package/dist/scripts/ingest.d.ts.map +1 -0
  25. package/dist/scripts/ingest.js +333 -0
  26. package/dist/scripts/ingest.js.map +1 -0
  27. package/dist/scripts/lib/fetcher.d.ts +26 -0
  28. package/dist/scripts/lib/fetcher.d.ts.map +1 -0
  29. package/dist/scripts/lib/fetcher.js +102 -0
  30. package/dist/scripts/lib/fetcher.js.map +1 -0
  31. package/dist/scripts/lib/parser.d.ts +60 -0
  32. package/dist/scripts/lib/parser.d.ts.map +1 -0
  33. package/dist/scripts/lib/parser.js +560 -0
  34. package/dist/scripts/lib/parser.js.map +1 -0
  35. package/dist/scripts/lib/pdf.d.ts +7 -0
  36. package/dist/scripts/lib/pdf.d.ts.map +1 -0
  37. package/dist/scripts/lib/pdf.js +124 -0
  38. package/dist/scripts/lib/pdf.js.map +1 -0
  39. package/dist/src/capabilities.d.ts +16 -0
  40. package/dist/src/capabilities.d.ts.map +1 -0
  41. package/dist/src/capabilities.js +43 -0
  42. package/dist/src/capabilities.js.map +1 -0
  43. package/dist/src/constants.d.ts +7 -0
  44. package/dist/src/constants.d.ts.map +1 -0
  45. package/dist/src/constants.js +7 -0
  46. package/dist/src/constants.js.map +1 -0
  47. package/dist/src/index.d.ts +8 -0
  48. package/dist/src/index.d.ts.map +1 -0
  49. package/dist/src/index.js +80 -0
  50. package/dist/src/index.js.map +1 -0
  51. package/dist/src/tools/about.d.ts +45 -0
  52. package/dist/src/tools/about.d.ts.map +1 -0
  53. package/dist/src/tools/about.js +54 -0
  54. package/dist/src/tools/about.js.map +1 -0
  55. package/dist/src/tools/build-legal-stance.d.ts +21 -0
  56. package/dist/src/tools/build-legal-stance.d.ts.map +1 -0
  57. package/dist/src/tools/build-legal-stance.js +46 -0
  58. package/dist/src/tools/build-legal-stance.js.map +1 -0
  59. package/dist/src/tools/check-currency.d.ts +20 -0
  60. package/dist/src/tools/check-currency.d.ts.map +1 -0
  61. package/dist/src/tools/check-currency.js +41 -0
  62. package/dist/src/tools/check-currency.js.map +1 -0
  63. package/dist/src/tools/format-citation.d.ts +14 -0
  64. package/dist/src/tools/format-citation.d.ts.map +1 -0
  65. package/dist/src/tools/format-citation.js +28 -0
  66. package/dist/src/tools/format-citation.js.map +1 -0
  67. package/dist/src/tools/get-eu-basis.d.ts +21 -0
  68. package/dist/src/tools/get-eu-basis.d.ts.map +1 -0
  69. package/dist/src/tools/get-eu-basis.js +52 -0
  70. package/dist/src/tools/get-eu-basis.js.map +1 -0
  71. package/dist/src/tools/get-provision-eu-basis.d.ts +20 -0
  72. package/dist/src/tools/get-provision-eu-basis.d.ts.map +1 -0
  73. package/dist/src/tools/get-provision-eu-basis.js +45 -0
  74. package/dist/src/tools/get-provision-eu-basis.js.map +1 -0
  75. package/dist/src/tools/get-provision.d.ts +24 -0
  76. package/dist/src/tools/get-provision.d.ts.map +1 -0
  77. package/dist/src/tools/get-provision.js +80 -0
  78. package/dist/src/tools/get-provision.js.map +1 -0
  79. package/dist/src/tools/get-rwandan-implementations.d.ts +21 -0
  80. package/dist/src/tools/get-rwandan-implementations.d.ts.map +1 -0
  81. package/dist/src/tools/get-rwandan-implementations.js +42 -0
  82. package/dist/src/tools/get-rwandan-implementations.js.map +1 -0
  83. package/dist/src/tools/list-sources.d.ts +25 -0
  84. package/dist/src/tools/list-sources.d.ts.map +1 -0
  85. package/dist/src/tools/list-sources.js +41 -0
  86. package/dist/src/tools/list-sources.js.map +1 -0
  87. package/dist/src/tools/registry.d.ts +13 -0
  88. package/dist/src/tools/registry.d.ts.map +1 -0
  89. package/dist/src/tools/registry.js +365 -0
  90. package/dist/src/tools/registry.js.map +1 -0
  91. package/dist/src/tools/search-eu-implementations.d.ts +24 -0
  92. package/dist/src/tools/search-eu-implementations.d.ts.map +1 -0
  93. package/dist/src/tools/search-eu-implementations.js +58 -0
  94. package/dist/src/tools/search-eu-implementations.js.map +1 -0
  95. package/dist/src/tools/search-legislation.d.ts +24 -0
  96. package/dist/src/tools/search-legislation.d.ts.map +1 -0
  97. package/dist/src/tools/search-legislation.js +54 -0
  98. package/dist/src/tools/search-legislation.js.map +1 -0
  99. package/dist/src/tools/validate-citation.d.ts +20 -0
  100. package/dist/src/tools/validate-citation.d.ts.map +1 -0
  101. package/dist/src/tools/validate-citation.js +107 -0
  102. package/dist/src/tools/validate-citation.js.map +1 -0
  103. package/dist/src/tools/validate-eu-compliance.d.ts +20 -0
  104. package/dist/src/tools/validate-eu-compliance.d.ts.map +1 -0
  105. package/dist/src/tools/validate-eu-compliance.js +98 -0
  106. package/dist/src/tools/validate-eu-compliance.js.map +1 -0
  107. package/dist/src/utils/as-of-date.d.ts +9 -0
  108. package/dist/src/utils/as-of-date.d.ts.map +1 -0
  109. package/dist/src/utils/as-of-date.js +25 -0
  110. package/dist/src/utils/as-of-date.js.map +1 -0
  111. package/dist/src/utils/fts-query.d.ts +19 -0
  112. package/dist/src/utils/fts-query.d.ts.map +1 -0
  113. package/dist/src/utils/fts-query.js +47 -0
  114. package/dist/src/utils/fts-query.js.map +1 -0
  115. package/dist/src/utils/metadata.d.ts +16 -0
  116. package/dist/src/utils/metadata.d.ts.map +1 -0
  117. package/dist/src/utils/metadata.js +22 -0
  118. package/dist/src/utils/metadata.js.map +1 -0
  119. package/dist/src/utils/statute-id.d.ts +18 -0
  120. package/dist/src/utils/statute-id.d.ts.map +1 -0
  121. package/dist/src/utils/statute-id.js +34 -0
  122. package/dist/src/utils/statute-id.js.map +1 -0
  123. package/package.json +74 -0
  124. package/server.json +30 -0
package/LICENSE ADDED
@@ -0,0 +1,110 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work.
38
+
39
+ "Derivative Works" shall mean any work, whether in Source or Object
40
+ form, that is based on (or derived from) the Work and for which the
41
+ editorial revisions, annotations, elaborations, or other modifications
42
+ represent, as a whole, an original work of authorship.
43
+
44
+ "Contribution" shall mean any work of authorship, including
45
+ the original version of the Work and any modifications or additions
46
+ to that Work or Derivative Works thereof, that is intentionally
47
+ submitted to the Licensor for inclusion in the Work by the copyright owner
48
+ or by an individual or Legal Entity authorized to submit on behalf of
49
+ the copyright owner.
50
+
51
+ "Contributor" shall mean Licensor and any individual or Legal Entity
52
+ on behalf of whom a Contribution has been received by the Licensor and
53
+ subsequently incorporated within the Work.
54
+
55
+ 2. Grant of Copyright License. Subject to the terms and conditions of
56
+ this License, each Contributor hereby grants to You a perpetual,
57
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
58
+ copyright license to reproduce, prepare Derivative Works of,
59
+ publicly display, publicly perform, sublicense, and distribute the
60
+ Work and such Derivative Works in Source or Object form.
61
+
62
+ 3. Grant of Patent License. Subject to the terms and conditions of
63
+ this License, each Contributor hereby grants to You a perpetual,
64
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
65
+ (except as stated in this section) patent license to make, have made,
66
+ use, offer to sell, sell, import, and otherwise transfer the Work.
67
+
68
+ 4. Redistribution. You may reproduce and distribute copies of the
69
+ Work or Derivative Works thereof in any medium, with or without
70
+ modifications, and in Source or Object form, provided that You
71
+ meet the following conditions:
72
+
73
+ (a) You must give any other recipients of the Work or
74
+ Derivative Works a copy of this License; and
75
+
76
+ (b) You must cause any modified files to carry prominent notices
77
+ stating that You changed the files; and
78
+
79
+ (c) You must retain, in the Source form of any Derivative Works
80
+ that You distribute, all copyright, patent, trademark, and
81
+ attribution notices from the Source form of the Work; and
82
+
83
+ (d) If the Work includes a "NOTICE" text file, You must include
84
+ a readable copy of the attribution notices contained
85
+ within such NOTICE file.
86
+
87
+ 5. Submission of Contributions.
88
+
89
+ 6. Trademarks. This License does not grant permission to use the trade
90
+ names, trademarks, service marks, or product names of the Licensor.
91
+
92
+ 7. Disclaimer of Warranty.
93
+
94
+ 8. Limitation of Liability.
95
+
96
+ 9. Accepting Warranty or Additional Liability.
97
+
98
+ Copyright 2024 Ansvar Systems AB
99
+
100
+ Licensed under the Apache License, Version 2.0 (the "License");
101
+ you may not use this file except in compliance with the License.
102
+ You may obtain a copy of the License at
103
+
104
+ http://www.apache.org/licenses/LICENSE-2.0
105
+
106
+ Unless required by applicable law or agreed to in writing, software
107
+ distributed under the License is distributed on an "AS IS" BASIS,
108
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
109
+ See the License for the specific language governing permissions and
110
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,83 @@
1
+ # Rwandan Law MCP
2
+
3
+ Rwandan law database for cybersecurity compliance via Model Context Protocol (MCP).
4
+
5
+ ## Features
6
+
7
+ - **Full-text search** across legislation provisions (FTS5 with BM25 ranking)
8
+ - **Article-level retrieval** for specific legal provisions
9
+ - **Citation validation** to prevent hallucinated references
10
+ - **Currency checks** to verify if laws are still in force
11
+
12
+ ## Quick Start
13
+
14
+ ### Claude Code (Remote)
15
+ ```bash
16
+ claude mcp add rwandan-law --transport http https://rwandan-law-mcp.vercel.app/mcp
17
+ ```
18
+
19
+ ### Local (npm)
20
+ ```bash
21
+ npx @ansvar/rwandan-law-mcp
22
+ ```
23
+
24
+ ## Data Sources
25
+
26
+ Real legislation ingested from RwandaLII law catalog:
27
+ - `data-display-type=akn`: direct article extraction from AKN HTML
28
+ - `data-display-type=pdf`: PDF text extraction (including multilingual gazette PDFs) and article parsing
29
+
30
+ ## License
31
+
32
+ Apache-2.0
33
+
34
+
35
+ ---
36
+
37
+ ## Important Disclaimers
38
+
39
+ ### Not Legal Advice
40
+
41
+ > **THIS TOOL IS NOT LEGAL ADVICE**
42
+ >
43
+ > Statute text is sourced from official government publications. However:
44
+ > - This is a **research tool**, not a substitute for professional legal counsel
45
+ > - **Coverage may be incomplete** — verify critical provisions against primary sources
46
+ > - **Verify all citations** against the official legal portal before relying on them professionally
47
+ > - Laws change — check the `about` tool for database freshness date
48
+
49
+ ### Client Confidentiality
50
+
51
+ When using the remote endpoint, queries are processed by third-party infrastructure
52
+ (Vercel, Claude API). For privileged or confidential legal matters, use the local
53
+ npm package or on-premise deployment.
54
+
55
+ **Before using professionally, read:** [DISCLAIMER.md](DISCLAIMER.md) | [PRIVACY.md](PRIVACY.md)
56
+
57
+ ---
58
+
59
+ ## Open Law
60
+
61
+ This server is part of **Ansvar Open Law** — free, structured access to legislation
62
+ from 70+ jurisdictions worldwide via the Model Context Protocol.
63
+
64
+ **Browse all jurisdictions ->** [ansvar.eu/open-law](https://ansvar.eu/open-law)
65
+
66
+ ## Ansvar MCP Network
67
+
68
+ Ansvar Open Law is part of the broader **Ansvar MCP Network** — 80+ servers covering
69
+ global legislation, EU/US compliance frameworks, and cybersecurity standards.
70
+
71
+ | Category | Coverage |
72
+ |----------|----------|
73
+ | **Legislation** | 70+ jurisdictions worldwide |
74
+ | **EU Compliance** | 49 regulations, 2,693 articles |
75
+ | **US Compliance** | 15 federal & state regulations |
76
+ | **Security Frameworks** | 261 frameworks, 1,451 controls |
77
+ | **Cybersecurity** | 200K+ CVEs, STRIDE patterns, sanctions |
78
+
79
+ **Explore the full network ->** [ansvar.ai/mcp](https://ansvar.ai/mcp)
80
+
81
+ ---
82
+
83
+ Built by [Ansvar Systems](https://ansvar.eu) | [ansvar.eu/open-law](https://ansvar.eu/open-law)
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Golden contract tests for Rwandan Law MCP.
3
+ *
4
+ * These tests require the SQLite database to exist locally.
5
+ * In CI (where *.db is excluded), the describe blocks are
6
+ * automatically skipped via `describe.skipIf(!DB_EXISTS)`.
7
+ */
8
+ export {};
9
+ //# sourceMappingURL=golden.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"golden.test.d.ts","sourceRoot":"","sources":["../../../__tests__/contract/golden.test.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Golden contract tests for Rwandan Law MCP.
3
+ *
4
+ * These tests require the SQLite database to exist locally.
5
+ * In CI (where *.db is excluded), the describe blocks are
6
+ * automatically skipped via `describe.skipIf(!DB_EXISTS)`.
7
+ */
8
+ import { beforeAll, describe, expect, it } from 'vitest';
9
+ import Database from 'better-sqlite3';
10
+ import * as fs from 'fs';
11
+ import * as path from 'path';
12
+ import { fileURLToPath } from 'url';
13
+ const __filename = fileURLToPath(import.meta.url);
14
+ const __dirname = path.dirname(__filename);
15
+ const DB_PATH = path.resolve(__dirname, '../../data/database.db');
16
+ const DB_EXISTS = fs.existsSync(DB_PATH);
17
+ let db;
18
+ describe.skipIf(!DB_EXISTS)('Database integrity', () => {
19
+ beforeAll(() => {
20
+ db = new Database(DB_PATH, { readonly: true });
21
+ db.pragma('journal_mode = DELETE');
22
+ });
23
+ it('has substantial law coverage', () => {
24
+ const row = db.prepare('SELECT COUNT(*) as cnt FROM legal_documents').get();
25
+ expect(row.cnt).toBeGreaterThanOrEqual(50);
26
+ });
27
+ it('has substantial provision coverage', () => {
28
+ const row = db.prepare('SELECT COUNT(*) as cnt FROM legal_provisions').get();
29
+ expect(row.cnt).toBeGreaterThanOrEqual(1000);
30
+ });
31
+ it('has FTS index data', () => {
32
+ const row = db.prepare("SELECT COUNT(*) as cnt FROM provisions_fts WHERE provisions_fts MATCH 'data'").get();
33
+ expect(row.cnt).toBeGreaterThanOrEqual(1);
34
+ });
35
+ });
36
+ describe.skipIf(!DB_EXISTS)('Provision retrieval', () => {
37
+ beforeAll(() => {
38
+ db = new Database(DB_PATH, { readonly: true });
39
+ db.pragma('journal_mode = DELETE');
40
+ });
41
+ it('retrieves core personal-data law article', () => {
42
+ const row = db.prepare("SELECT content FROM legal_provisions WHERE document_id = 'rw-personal-data-protection-2021' AND section = '1'").get();
43
+ expect(row).toBeDefined();
44
+ expect(row.content.length).toBeGreaterThan(50);
45
+ });
46
+ it('retrieves a PDF-derived law article', () => {
47
+ const row = db.prepare("SELECT content FROM legal_provisions WHERE document_id = 'rw-law-2018-68' AND section = '1'").get();
48
+ expect(row).toBeDefined();
49
+ expect(row.content.length).toBeGreaterThan(50);
50
+ });
51
+ });
52
+ describe.skipIf(!DB_EXISTS)('Negative tests', () => {
53
+ beforeAll(() => {
54
+ db = new Database(DB_PATH, { readonly: true });
55
+ db.pragma('journal_mode = DELETE');
56
+ });
57
+ it('returns no rows for fictional law', () => {
58
+ const row = db.prepare("SELECT COUNT(*) as cnt FROM legal_provisions WHERE document_id = 'fictional-law-2099'").get();
59
+ expect(row.cnt).toBe(0);
60
+ });
61
+ it('returns no rows for invalid section', () => {
62
+ const row = db.prepare("SELECT COUNT(*) as cnt FROM legal_provisions WHERE document_id = 'rw-personal-data-protection-2021' AND section = '999ZZZ-INVALID'").get();
63
+ expect(row.cnt).toBe(0);
64
+ });
65
+ });
66
+ describe.skipIf(!DB_EXISTS)('Metadata', () => {
67
+ beforeAll(() => {
68
+ db = new Database(DB_PATH, { readonly: true });
69
+ db.pragma('journal_mode = DELETE');
70
+ });
71
+ it('has db_metadata entries', () => {
72
+ const row = db.prepare('SELECT COUNT(*) as cnt FROM db_metadata').get();
73
+ expect(row.cnt).toBeGreaterThan(0);
74
+ });
75
+ });
76
+ //# sourceMappingURL=golden.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"golden.test.js","sourceRoot":"","sources":["../../../__tests__/contract/golden.test.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AACzD,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AACtC,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,O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VercelResponse): void;
3
+ //# sourceMappingURL=health.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"health.d.ts","sourceRoot":"","sources":["../../api/health.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAuDlE,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,GAAG,EAAE,aAAa,EAAE,GAAG,EAAE,cAAc,QA+DtE"}
@@ -0,0 +1,101 @@
1
+ import Database from '@ansvar/mcp-sqlite';
2
+ import { existsSync, copyFileSync, rmSync, statSync, writeFileSync } from 'fs';
3
+ import { join } from 'path';
4
+ import { REPOSITORY_URL, SERVER_NAME, SERVER_VERSION, DB_ENV_VAR, } from '../src/constants.js';
5
+ const SOURCE_DB = process.env[DB_ENV_VAR] || join(process.cwd(), 'data', 'database.db');
6
+ const TMP_DB = '/tmp/database.db';
7
+ const TMP_DB_META = '/tmp/database.db.meta.json';
8
+ const STALENESS_THRESHOLD_DAYS = 30;
9
+ function getHealthDb() {
10
+ try {
11
+ if (!existsSync(TMP_DB) && existsSync(SOURCE_DB)) {
12
+ rmSync('/tmp/database.db.lock', { recursive: true, force: true });
13
+ copyFileSync(SOURCE_DB, TMP_DB);
14
+ const stats = statSync(SOURCE_DB);
15
+ writeFileSync(TMP_DB_META, JSON.stringify({ source_db: SOURCE_DB, source_signature: `${stats.size}:${Math.trunc(stats.mtimeMs)}` }), 'utf-8');
16
+ }
17
+ if (existsSync(TMP_DB)) {
18
+ return new Database(TMP_DB, { readonly: true });
19
+ }
20
+ }
21
+ catch {
22
+ // DB not available
23
+ }
24
+ return null;
25
+ }
26
+ function readMeta(db, key) {
27
+ try {
28
+ const row = db.prepare('SELECT value FROM db_metadata WHERE key = ?').get(key);
29
+ return row?.value ?? null;
30
+ }
31
+ catch {
32
+ return null;
33
+ }
34
+ }
35
+ function safeCount(db, sql) {
36
+ try {
37
+ const row = db.prepare(sql).get();
38
+ return row ? Number(row.count) : 0;
39
+ }
40
+ catch {
41
+ return 0;
42
+ }
43
+ }
44
+ export default function handler(req, res) {
45
+ const url = new URL(req.url ?? '/', `https://${req.headers.host}`);
46
+ if (url.pathname === '/version' || url.searchParams.has('version')) {
47
+ res.status(200).json({
48
+ name: SERVER_NAME,
49
+ version: SERVER_VERSION,
50
+ node_version: process.version,
51
+ transport: ['stdio', 'streamable-http'],
52
+ capabilities: ['statutes', 'eu_cross_references'],
53
+ tier: 'free',
54
+ source_schema_version: '1.0',
55
+ repo_url: REPOSITORY_URL,
56
+ report_issue_url: `${REPOSITORY_URL}/issues/new?template=data-error.md`,
57
+ });
58
+ return;
59
+ }
60
+ const db = getHealthDb();
61
+ let dataStatus = 'degraded';
62
+ let builtAt = null;
63
+ let daysSinceBuilt = null;
64
+ let tier = 'free';
65
+ let schemaVersion = 'unknown';
66
+ let counts = {};
67
+ if (db) {
68
+ try {
69
+ builtAt = readMeta(db, 'built_at');
70
+ tier = readMeta(db, 'tier') ?? 'free';
71
+ schemaVersion = readMeta(db, 'schema_version') ?? 'unknown';
72
+ if (builtAt) {
73
+ daysSinceBuilt = Math.floor((Date.now() - new Date(builtAt).getTime()) / (1000 * 60 * 60 * 24));
74
+ dataStatus = daysSinceBuilt > STALENESS_THRESHOLD_DAYS ? 'stale' : 'ok';
75
+ }
76
+ counts = {
77
+ documents: safeCount(db, 'SELECT COUNT(*) as count FROM legal_documents'),
78
+ provisions: safeCount(db, 'SELECT COUNT(*) as count FROM legal_provisions'),
79
+ };
80
+ }
81
+ finally {
82
+ db.close();
83
+ }
84
+ }
85
+ res.status(200).json({
86
+ status: dataStatus,
87
+ server: SERVER_NAME,
88
+ version: SERVER_VERSION,
89
+ uptime_seconds: Math.floor(process.uptime()),
90
+ data: {
91
+ built_at: builtAt,
92
+ days_since_built: daysSinceBuilt,
93
+ staleness_threshold_days: STALENESS_THRESHOLD_DAYS,
94
+ schema_version: schemaVersion,
95
+ counts,
96
+ },
97
+ capabilities: ['statutes', 'eu_cross_references'],
98
+ tier,
99
+ });
100
+ }
101
+ //# sourceMappingURL=health.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"health.js","sourceRoot":"","sources":["../../api/health.ts"],"names":[],"mappings":"AACA,OAAO,QAAQ,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAgB,aAAa,EAAE,MAAM,IAAI,CAAC;AAC7F,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EACL,cAAc,EACd,WAAW,EACX,cAAc,EACd,UAAU,GACX,MAAM,qBAAqB,CAAC;AAE7B,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,aAAa,CAAC,CAAC;AACxF,MAAM,MAAM,GAAG,kBAAkB,CAAC;AAClC,MAAM,WAAW,GAAG,4BAA4B,CAAC;AACjD,MAAM,wBAAwB,GAAG,EAAE,CAAC;AAEpC,SAAS,WAAW;IAClB,IAAI,CAAC;QACH,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;YACjD,MAAM,CAAC,uBAAuB,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;YAClE,YAAY,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;YAChC,MAAM,KAAK,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC;YAClC,aAAa,CACX,WAAW,EACX,IAAI,CAAC,SAAS,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,gBAAgB,EAAE,GAAG,KAAK,CAAC,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC,EACxG,OAAO,CACR,CAAC;QACJ,CAAC;QACD,IAAI,UAAU,CAAC,MA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zE,UAAU,EAAE,SAAS,CAAC,EAAE,EAAE,gDAAgD,CAAC;aAC5E,CAAC;QACJ,CAAC;gBAAS,CAAC;YACT,EAAE,CAAC,KAAK,EAAE,CAAC;QACb,CAAC;IACH,CAAC;IAED,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;QACnB,MAAM,EAAE,UAAU;QAClB,MAAM,EAAE,WAAW;QACnB,OAAO,EAAE,cAAc;QACvB,cAAc,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;QAC5C,IAAI,EAAE;YACJ,QAAQ,EAAE,OAAO;YACjB,gBAAgB,EAAE,cAAc;YAChC,wBAAwB,EAAE,wBAAwB;YAClD,cAAc,EAAE,aAAa;YAC7B,MAAM;SACP;QACD,YAAY,EAAE,CAAC,UAAU,EAAE,qBAAqB,CAAC;QACjD,IAAI;KACL,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { VercelRequest, VercelResponse } from '@vercel/node';
2
+ export default function handler(req: VercelRequest, res: VercelResponse): Promise<void>;
3
+ //# sourceMappingURL=mcp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../../api/mcp.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAoGlE,wBAA8B,OAAO,CAAC,GAAG,EAAE,aAAa,EAAE,GAAG,EAAE,cAAc,iBA4C5E"}
@@ -0,0 +1,119 @@
1
+ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
2
+ import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
3
+ import Database from '@ansvar/mcp-sqlite';
4
+ import { join } from 'path';
5
+ import { copyFileSync, existsSync, readFileSync, rmSync, statSync, writeFileSync } from 'fs';
6
+ import { createHash } from 'crypto';
7
+ import { registerTools } from '../src/tools/registry.js';
8
+ import { DB_ENV_VAR, SERVER_NAME, SERVER_VERSION, } from '../src/constants.js';
9
+ const SOURCE_DB = process.env[DB_ENV_VAR]
10
+ || join(process.cwd(), 'data', 'database.db');
11
+ const TMP_DB = '/tmp/database.db';
12
+ const TMP_DB_LOCK = '/tmp/database.db.lock';
13
+ const TMP_DB_SHM = '/tmp/database.db-shm';
14
+ const TMP_DB_WAL = '/tmp/database.db-wal';
15
+ const TMP_DB_META = '/tmp/database.db.meta.json';
16
+ let db = null;
17
+ function computeSourceSignature() {
18
+ const stats = statSync(SOURCE_DB);
19
+ return `${stats.size}:${Math.trunc(stats.mtimeMs)}`;
20
+ }
21
+ function readTmpMeta() {
22
+ if (!existsSync(TMP_DB_META))
23
+ return null;
24
+ try {
25
+ const parsed = JSON.parse(readFileSync(TMP_DB_META, 'utf-8'));
26
+ if (parsed.source_db && parsed.source_signature) {
27
+ return { source_db: parsed.source_db, source_signature: parsed.source_signature };
28
+ }
29
+ }
30
+ catch {
31
+ // Ignore corrupted metadata
32
+ }
33
+ return null;
34
+ }
35
+ function clearTmpDbArtifacts() {
36
+ rmSync(TMP_DB_LOCK, { recursive: true, force: true });
37
+ rmSync(TMP_DB_SHM, { force: true });
38
+ rmSync(TMP_DB_WAL, { force: true });
39
+ rmSync(TMP_DB, { force: true });
40
+ rmSync(TMP_DB_META, { force: true });
41
+ }
42
+ function ensureTempDbIsFresh() {
43
+ const sourceSignature = computeSourceSignature();
44
+ const meta = readTmpMeta();
45
+ const shouldRefresh = !existsSync(TMP_DB) || !meta || meta.source_db !== SOURCE_DB || meta.source_signature !== sourceSignature;
46
+ if (shouldRefresh) {
47
+ clearTmpDbArtifacts();
48
+ copyFileSync(SOURCE_DB, TMP_DB);
49
+ writeFileSync(TMP_DB_META, JSON.stringify({ source_db: SOURCE_DB, source_signature: sourceSignature }), 'utf-8');
50
+ return;
51
+ }
52
+ rmSync(TMP_DB_LOCK, { recursive: true, force: true });
53
+ }
54
+ function computeAboutContext() {
55
+ let fingerprint = 'unknown';
56
+ let dbBuilt = 'unknown';
57
+ try {
58
+ const buf = readFileSync(SOURCE_DB);
59
+ fingerprint = createHash('sha256').update(buf).digest('hex').slice(0, 12);
60
+ }
61
+ catch { /* ignore */ }
62
+ try {
63
+ const database = getDatabase();
64
+ const row = database.prepare("SELECT value FROM db_metadata WHERE key = 'built_at'").get();
65
+ if (row?.value)
66
+ dbBuilt = row.value;
67
+ }
68
+ catch { /* ignore */ }
69
+ return { version: SERVER_VERSION, fingerprint, dbBuilt };
70
+ }
71
+ function getDatabase() {
72
+ if (!db) {
73
+ ensureTempDbIsFresh();
74
+ db = new Database(TMP_DB, { readonly: true });
75
+ db.pragma('foreign_keys = ON');
76
+ }
77
+ return db;
78
+ }
79
+ export default async function handler(req, res) {
80
+ res.setHeader('Access-Control-Allow-Origin', '*');
81
+ res.setHeader('Access-Control-Allow-Methods', 'GET, POST, DELETE, OPTIONS');
82
+ res.setHeader('Access-Control-Allow-Headers', 'Content-Type, mcp-session-id');
83
+ res.setHeader('Access-Control-Expose-Headers', 'mcp-session-id');
84
+ if (req.method === 'OPTIONS') {
85
+ res.status(204).end();
86
+ return;
87
+ }
88
+ if (req.method === 'GET') {
89
+ res.status(200).json({
90
+ name: SERVER_NAME,
91
+ version: SERVER_VERSION,
92
+ protocol: 'mcp-streamable-http',
93
+ });
94
+ return;
95
+ }
96
+ try {
97
+ if (!existsSync(SOURCE_DB)) {
98
+ res.status(500).json({ error: `Database not found at ${SOURCE_DB}` });
99
+ return;
100
+ }
101
+ const database = getDatabase();
102
+ const server = new Server({ name: SERVER_NAME, version: SERVER_VERSION }, { capabilities: { tools: {} } });
103
+ registerTools(server, database, computeAboutContext());
104
+ const transport = new StreamableHTTPServerTransport({
105
+ sessionIdGenerator: undefined,
106
+ enableJsonResponse: true,
107
+ });
108
+ await server.connect(transport);
109
+ await transport.handleRequest(req, res, req.body);
110
+ }
111
+ catch (err) {
112
+ const message = err instanceof Error ? err.message : String(err);
113
+ console.error('MCP handler error:', message);
114
+ if (!res.headersSent) {
115
+ res.status(500).json({ error: message });
116
+ }
117
+ }
118
+ }
119
+ //# sourceMappingURL=mcp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp.js","sourceRoot":"","sources":["../../api/mcp.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,6BAA6B,EAAE,MAAM,oDAAoD,CAAC;AACnG,OAAO,QAAQ,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AAC7F,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEpC,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EACL,UAAU,EACV,WAAW,EACX,cAAc,GACf,MAAM,qBAAqB,CAAC;AAG7B,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC;OACpC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,aAAa,CAAC,CAAC;AAChD,MAAM,MAAM,GAAG,kBAAkB,CAAC;AAClC,MAAM,WAAW,GAAG,uBAAuB,CAAC;AAC5C,MAAM,UAAU,GAAG,sBAAsB,CAAC;AAC1C,MAAM,UAAU,GAAG,sBAAsB,CAAC;AAC1C,MAAM,WAAW,GAAG,4BAA4B,CAAC;AAEjD,IAAI,EAAE,GAAyC,IAAI,CAAC;AAOpD,SAAS,sBAAsB;IAC7B,MAAM,KAAK,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC;IAClC,OAAO,GAAG,KAAK,CAAC,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;AACtD,CAAC;AAED,SAAS,WAAW;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EAAE,CAAC,CAAC;QAEvD,MAAM,SAAS,GAAG,IAAI,6BAA6B,CAAC;YAClD,kBAAkB,EAAE,SAAS;YAC7B,kBAAkB,EAAE,IAAI;SACzB,CAAC,CAAC;QAEH,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAChC,MAAM,SAAS,CAAC,aAAa,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC;IACpD,CAAC;IAAC,OAAO,GAAY,EAAE,CAAC;QACtB,MAAM,OAAO,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACjE,OAAO,CAAC,KAAK,CAAC,oBAAoB,EAAE,OAAO,CAAC,CAAC;QAC7C,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC;YACrB,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;QAC3C,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env tsx
2
+ /**
3
+ * Database builder for Rwandan Law MCP server.
4
+ *
5
+ * Builds the SQLite database from seed JSON files in data/seed/.
6
+ * Follows the Switzerland Law MCP reference pattern.
7
+ *
8
+ * Usage: npm run build:db
9
+ */
10
+ export {};
11
+ //# sourceMappingURL=build-db.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-db.d.ts","sourceRoot":"","sources":["../../scripts/build-db.ts"],"names":[],"mappings":";AACA;;;;;;;GAOG"}