@cyanheads/congressgov-mcp-server 0.3.31 → 0.4.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 (47) hide show
  1. package/AGENTS.md +26 -5
  2. package/CLAUDE.md +26 -5
  3. package/Dockerfile +13 -0
  4. package/README.md +18 -7
  5. package/dist/config/server-config.d.ts +15 -0
  6. package/dist/config/server-config.d.ts.map +1 -1
  7. package/dist/config/server-config.js +66 -1
  8. package/dist/config/server-config.js.map +1 -1
  9. package/dist/index.js +30 -2
  10. package/dist/index.js.map +1 -1
  11. package/dist/mcp-server/tools/definitions/committee-lookup.tool.d.ts.map +1 -1
  12. package/dist/mcp-server/tools/definitions/committee-lookup.tool.js +40 -10
  13. package/dist/mcp-server/tools/definitions/committee-lookup.tool.js.map +1 -1
  14. package/dist/mcp-server/tools/definitions/search-bills.tool.d.ts +47 -0
  15. package/dist/mcp-server/tools/definitions/search-bills.tool.d.ts.map +1 -0
  16. package/dist/mcp-server/tools/definitions/search-bills.tool.js +99 -0
  17. package/dist/mcp-server/tools/definitions/search-bills.tool.js.map +1 -0
  18. package/dist/mcp-server/tools/format-helpers.d.ts +2 -0
  19. package/dist/mcp-server/tools/format-helpers.d.ts.map +1 -1
  20. package/dist/mcp-server/tools/format-helpers.js +31 -0
  21. package/dist/mcp-server/tools/format-helpers.js.map +1 -1
  22. package/dist/services/congress-mirror/congress-mirror-service.d.ts +45 -0
  23. package/dist/services/congress-mirror/congress-mirror-service.d.ts.map +1 -0
  24. package/dist/services/congress-mirror/congress-mirror-service.js +116 -0
  25. package/dist/services/congress-mirror/congress-mirror-service.js.map +1 -0
  26. package/dist/services/congress-mirror/ingest.d.ts +33 -0
  27. package/dist/services/congress-mirror/ingest.d.ts.map +1 -0
  28. package/dist/services/congress-mirror/ingest.js +179 -0
  29. package/dist/services/congress-mirror/ingest.js.map +1 -0
  30. package/dist/services/congress-mirror/normalize.d.ts +25 -0
  31. package/dist/services/congress-mirror/normalize.d.ts.map +1 -0
  32. package/dist/services/congress-mirror/normalize.js +47 -0
  33. package/dist/services/congress-mirror/normalize.js.map +1 -0
  34. package/dist/services/congress-mirror/schema.d.ts +19 -0
  35. package/dist/services/congress-mirror/schema.d.ts.map +1 -0
  36. package/dist/services/congress-mirror/schema.js +44 -0
  37. package/dist/services/congress-mirror/schema.js.map +1 -0
  38. package/dist/services/congress-mirror/types.d.ts +55 -0
  39. package/dist/services/congress-mirror/types.d.ts.map +1 -0
  40. package/dist/services/congress-mirror/types.js +9 -0
  41. package/dist/services/congress-mirror/types.js.map +1 -0
  42. package/package.json +33 -7
  43. package/scripts/_mirror-context.ts +30 -0
  44. package/scripts/congress-mirror-init.ts +23 -0
  45. package/scripts/congress-mirror-refresh.ts +24 -0
  46. package/scripts/congress-mirror-verify.ts +36 -0
  47. package/server.json +5 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cyanheads/congressgov-mcp-server",
3
- "version": "0.3.31",
3
+ "version": "0.4.0",
4
4
  "description": "Access U.S. congressional data - bills, votes, members, committees - through MCP. STDIO & Streamable HTTP.",
5
5
  "mcpName": "io.github.cyanheads/congressgov-mcp-server",
6
6
  "type": "module",
@@ -9,7 +9,19 @@
9
9
  "bin": {
10
10
  "congressgov-mcp-server": "dist/index.js"
11
11
  },
12
- "files": ["dist/", "README.md", "LICENSE", "CLAUDE.md", "AGENTS.md", "Dockerfile", "server.json"],
12
+ "files": [
13
+ "dist/",
14
+ "scripts/_mirror-context.ts",
15
+ "scripts/congress-mirror-init.ts",
16
+ "scripts/congress-mirror-refresh.ts",
17
+ "scripts/congress-mirror-verify.ts",
18
+ "README.md",
19
+ "LICENSE",
20
+ "CLAUDE.md",
21
+ "AGENTS.md",
22
+ "Dockerfile",
23
+ "server.json"
24
+ ],
13
25
  "scripts": {
14
26
  "build": "bun scripts/build.ts",
15
27
  "rebuild": "bun scripts/clean.ts && bun scripts/build.ts",
@@ -31,7 +43,10 @@
31
43
  "dev:stdio": "MCP_TRANSPORT_TYPE=stdio bun --watch src/index.ts",
32
44
  "dev:http": "MCP_TRANSPORT_TYPE=http bun --watch src/index.ts",
33
45
  "start:stdio": "MCP_TRANSPORT_TYPE=stdio node dist/index.js",
34
- "start:http": "MCP_TRANSPORT_TYPE=http node dist/index.js"
46
+ "start:http": "MCP_TRANSPORT_TYPE=http node dist/index.js",
47
+ "mirror:init": "bun run scripts/congress-mirror-init.ts",
48
+ "mirror:refresh": "bun run scripts/congress-mirror-refresh.ts",
49
+ "mirror:verify": "bun run scripts/congress-mirror-verify.ts"
35
50
  },
36
51
  "keywords": [
37
52
  "mcp",
@@ -77,18 +92,29 @@
77
92
  "access": "public"
78
93
  },
79
94
  "dependencies": {
80
- "@cyanheads/mcp-ts-core": "^0.10.9",
95
+ "@cyanheads/mcp-ts-core": "^0.10.10",
81
96
  "fast-xml-parser": "^5.9.3",
97
+ "node-cron": "^4.4.1",
82
98
  "pino-pretty": "^13.1.3",
83
99
  "zod": "^4.4.3"
84
100
  },
101
+ "peerDependencies": {
102
+ "better-sqlite3": "^12.0.0"
103
+ },
104
+ "peerDependenciesMeta": {
105
+ "better-sqlite3": {
106
+ "optional": true
107
+ }
108
+ },
85
109
  "devDependencies": {
86
- "@biomejs/biome": "^2.5.0",
87
- "@types/node": "^26.0.0",
110
+ "@biomejs/biome": "^2.5.1",
111
+ "@types/node": "^26.0.1",
112
+ "better-sqlite3": "^12.11.1",
88
113
  "depcheck": "^1.4.7",
89
114
  "ignore": "^7.0.5",
90
115
  "tsc-alias": "^1.8.17",
91
116
  "typescript": "^6.0.3",
92
117
  "vitest": "^4.1.9"
93
- }
118
+ },
119
+ "trustedDependencies": ["better-sqlite3"]
94
120
  }
@@ -0,0 +1,30 @@
1
+ /**
2
+ * @fileoverview Shared bootstrap for the mirror lifecycle CLI scripts
3
+ * (congress-mirror-init / congress-mirror-refresh / congress-mirror-verify).
4
+ * Builds the Congress API client and the mirror service from the environment and
5
+ * hands back the underlying mirror — no MCP transport, no tool registration.
6
+ * Imported by the three named scripts, so it must travel with them in the npm
7
+ * tarball and the Docker image.
8
+ * @module scripts/_mirror-context
9
+ */
10
+
11
+ import type { Mirror } from '@cyanheads/mcp-ts-core/mirror';
12
+ import { getServerConfig } from '@/config/server-config.js';
13
+ import { initCongressApi } from '@/services/congress-api/congress-api-service.js';
14
+ import { initCongressMirror } from '@/services/congress-mirror/congress-mirror-service.js';
15
+
16
+ /**
17
+ * Build the mirror from env config and return its instance. The CLI builds the
18
+ * mirror regardless of `CONGRESS_MIRROR_ENABLED` (that flag gates the tool and the
19
+ * in-process scheduler, not out-of-band index construction); the ingester pages
20
+ * the live Congress.gov API via `CongressApiService`, so init it here.
21
+ */
22
+ export function getMirror(): Mirror {
23
+ const config = getServerConfig();
24
+ initCongressApi();
25
+ const service = initCongressMirror({
26
+ mirrorPath: config.mirrorPath,
27
+ congresses: config.congresses,
28
+ });
29
+ return service.mirrorInstance;
30
+ }
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env bun
2
+ /**
3
+ * @fileoverview mirror:init — full out-of-band build of the Congress bill FTS
4
+ * mirror. Pages the bill list and CRS summaries for the configured congress
5
+ * window, merges them into one row per bill, and writes the SQLite index.
6
+ * Idempotent (the framework upserts by primary key) — safe to re-run after an
7
+ * interrupt. Run as a one-shot job or at Docker build, never on server startup.
8
+ * @module scripts/congress-mirror-init
9
+ */
10
+
11
+ import { logger } from '@cyanheads/mcp-ts-core/utils';
12
+ import { getMirror } from './_mirror-context.js';
13
+
14
+ const mirror = getMirror();
15
+ logger.info('Starting Congress bill mirror init (full build)');
16
+
17
+ const result = await mirror.runSync({ mode: 'init', signal: AbortSignal.timeout(3_600_000) });
18
+
19
+ logger.info(
20
+ `Congress bill mirror init complete: ${result.recordsApplied} records applied across ${result.pagesFetched} pages (total ${result.total}).`,
21
+ );
22
+ await mirror.close();
23
+ process.exit(0);
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env bun
2
+ /**
3
+ * @fileoverview mirror:refresh — incremental refresh of the Congress bill FTS
4
+ * mirror. Re-scans bills updated since the durable checkpoint and re-walks the
5
+ * CRS summaries, merging them into the existing index; the index stays
6
+ * transactionally queryable throughout. Run out-of-band for stdio deployments
7
+ * (the HTTP server schedules this on a cron when CONGRESS_MIRROR_REFRESH_CRON is
8
+ * set).
9
+ * @module scripts/congress-mirror-refresh
10
+ */
11
+
12
+ import { logger } from '@cyanheads/mcp-ts-core/utils';
13
+ import { getMirror } from './_mirror-context.js';
14
+
15
+ const mirror = getMirror();
16
+ logger.info('Starting Congress bill mirror refresh');
17
+
18
+ const result = await mirror.runSync({ mode: 'refresh', signal: AbortSignal.timeout(3_600_000) });
19
+
20
+ logger.info(
21
+ `Congress bill mirror refresh complete: ${result.recordsApplied} records applied (total ${result.total}).`,
22
+ );
23
+ await mirror.close();
24
+ process.exit(0);
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env bun
2
+ /**
3
+ * @fileoverview mirror:verify — report the Congress bill mirror health: readiness,
4
+ * sync status, last completion, record count, and a SQLite integrity check. Exits
5
+ * non-zero when the mirror is not ready or integrity fails, so it can gate a
6
+ * deployment or a post-build smoke check.
7
+ * @module scripts/congress-mirror-verify
8
+ */
9
+
10
+ import { logger } from '@cyanheads/mcp-ts-core/utils';
11
+ import { getMirror } from './_mirror-context.js';
12
+
13
+ const mirror = getMirror();
14
+ const status = await mirror.status();
15
+
16
+ logger.info(
17
+ `Congress bill mirror status: ready=${status.ready}, status=${status.status}, total=${status.total ?? 0}, completedAt=${status.completedAt ?? 'never'}`,
18
+ );
19
+ if (status.error) logger.warning(`Last sync error: ${status.error}`);
20
+
21
+ if (!status.ready) {
22
+ logger.error('Mirror is NOT ready — run mirror:init to build the index.');
23
+ await mirror.close();
24
+ process.exit(1);
25
+ }
26
+
27
+ const integrity = await mirror.store.integrityCheck();
28
+ if (!integrity.ok) {
29
+ logger.error(`SQLite integrity check FAILED: ${integrity.results.join('; ')}`);
30
+ await mirror.close();
31
+ process.exit(1);
32
+ }
33
+
34
+ logger.info('Congress bill mirror integrity check passed.');
35
+ await mirror.close();
36
+ process.exit(0);
package/server.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "url": "https://github.com/cyanheads/congressgov-mcp-server",
7
7
  "source": "github"
8
8
  },
9
- "version": "0.3.31",
9
+ "version": "0.4.0",
10
10
  "remotes": [
11
11
  {
12
12
  "type": "streamable-http",
@@ -19,7 +19,7 @@
19
19
  "registryBaseUrl": "https://registry.npmjs.org",
20
20
  "identifier": "@cyanheads/congressgov-mcp-server",
21
21
  "runtimeHint": "bun",
22
- "version": "0.3.31",
22
+ "version": "0.4.0",
23
23
  "packageArguments": [
24
24
  {
25
25
  "type": "positional",
@@ -33,7 +33,7 @@
33
33
  "environmentVariables": [
34
34
  {
35
35
  "name": "CONGRESS_API_KEY",
36
- "description": "API key from api.data.gov \u2014 optional (falls back to DEMO_KEY: 30 req/hr). Own key: 1000 req/hr. Free signup at api.data.gov.",
36
+ "description": "API key from api.data.gov \u2014 optional (falls back to DEMO_KEY: 30 req/hr). Own key: 5000 req/hr. Free signup at api.data.gov.",
37
37
  "format": "string",
38
38
  "isRequired": false
39
39
  },
@@ -54,7 +54,7 @@
54
54
  "registryBaseUrl": "https://registry.npmjs.org",
55
55
  "identifier": "@cyanheads/congressgov-mcp-server",
56
56
  "runtimeHint": "bun",
57
- "version": "0.3.31",
57
+ "version": "0.4.0",
58
58
  "packageArguments": [
59
59
  {
60
60
  "type": "positional",
@@ -68,7 +68,7 @@
68
68
  "environmentVariables": [
69
69
  {
70
70
  "name": "CONGRESS_API_KEY",
71
- "description": "API key from api.data.gov \u2014 optional (falls back to DEMO_KEY: 30 req/hr). Own key: 1000 req/hr. Free signup at api.data.gov.",
71
+ "description": "API key from api.data.gov \u2014 optional (falls back to DEMO_KEY: 30 req/hr). Own key: 5000 req/hr. Free signup at api.data.gov.",
72
72
  "format": "string",
73
73
  "isRequired": false
74
74
  },