@pipeworx/mcp-govinfo 0.1.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.
- package/LICENSE +21 -0
- package/README.md +56 -0
- package/package.json +20 -0
- package/server.json +18 -0
- package/src/index.ts +285 -0
- package/tsconfig.json +14 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Pipeworx
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# mcp-govinfo
|
|
2
|
+
|
|
3
|
+
GovInfo.gov MCP — full text of US government publications
|
|
4
|
+
|
|
5
|
+
Part of [Pipeworx](https://pipeworx.io) — an MCP gateway connecting AI agents to 250+ live data sources.
|
|
6
|
+
|
|
7
|
+
## Tools
|
|
8
|
+
|
|
9
|
+
| Tool | Description |
|
|
10
|
+
|------|-------------|
|
|
11
|
+
| `get_granule` | Granule metadata for a sub-unit within a package. |
|
|
12
|
+
|
|
13
|
+
## Quick Start
|
|
14
|
+
|
|
15
|
+
Add to your MCP client (Claude Desktop, Cursor, Windsurf, etc.):
|
|
16
|
+
|
|
17
|
+
```json
|
|
18
|
+
{
|
|
19
|
+
"mcpServers": {
|
|
20
|
+
"govinfo": {
|
|
21
|
+
"url": "https://gateway.pipeworx.io/govinfo/mcp"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Or connect to the full Pipeworx gateway for access to all 250+ data sources:
|
|
28
|
+
|
|
29
|
+
```json
|
|
30
|
+
{
|
|
31
|
+
"mcpServers": {
|
|
32
|
+
"pipeworx": {
|
|
33
|
+
"url": "https://gateway.pipeworx.io/mcp"
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Using with ask_pipeworx
|
|
40
|
+
|
|
41
|
+
Instead of calling tools directly, you can ask questions in plain English:
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
ask_pipeworx({ question: "your question about Govinfo data" })
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
The gateway picks the right tool and fills the arguments automatically.
|
|
48
|
+
|
|
49
|
+
## More
|
|
50
|
+
|
|
51
|
+
- [All tools and guides](https://github.com/pipeworx-io/examples)
|
|
52
|
+
- [pipeworx.io](https://pipeworx.io)
|
|
53
|
+
|
|
54
|
+
## License
|
|
55
|
+
|
|
56
|
+
MIT
|
package/package.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pipeworx/mcp-govinfo",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "GovInfo.gov MCP — full text of US government publications",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "src/index.ts",
|
|
7
|
+
"types": "src/index.ts",
|
|
8
|
+
"keywords": ["mcp", "mcp-server", "model-context-protocol", "pipeworx", "govinfo"],
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/pipeworx-io/mcp-govinfo"
|
|
13
|
+
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"typecheck": "tsc --noEmit"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"typescript": "^5.7.0"
|
|
19
|
+
}
|
|
20
|
+
}
|
package/server.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
|
|
3
|
+
"name": "io.github.pipeworx-io/govinfo",
|
|
4
|
+
"title": "Govinfo",
|
|
5
|
+
"description": "GovInfo.gov MCP — full text of US government publications",
|
|
6
|
+
"version": "0.1.0",
|
|
7
|
+
"websiteUrl": "https://pipeworx.io/packs/govinfo",
|
|
8
|
+
"repository": {
|
|
9
|
+
"url": "https://github.com/pipeworx-io/mcp-govinfo",
|
|
10
|
+
"source": "github"
|
|
11
|
+
},
|
|
12
|
+
"remotes": [
|
|
13
|
+
{
|
|
14
|
+
"type": "streamable-http",
|
|
15
|
+
"url": "https://gateway.pipeworx.io/govinfo/mcp"
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
interface McpToolDefinition {
|
|
2
|
+
name: string;
|
|
3
|
+
description: string;
|
|
4
|
+
inputSchema: {
|
|
5
|
+
type: 'object';
|
|
6
|
+
properties: Record<string, unknown>;
|
|
7
|
+
required?: string[];
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
interface McpToolExport {
|
|
12
|
+
tools: McpToolDefinition[];
|
|
13
|
+
callTool: (name: string, args: Record<string, unknown>) => Promise<unknown>;
|
|
14
|
+
meter?: { credits: number };
|
|
15
|
+
cost?: Record<string, unknown>;
|
|
16
|
+
provider?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* GovInfo.gov MCP — full text of US government publications
|
|
21
|
+
*
|
|
22
|
+
* GovInfo carries the authoritative full text of US laws, regulations, and
|
|
23
|
+
* congressional materials: BILLS, USCODE, CFR, eCFR, Federal Register,
|
|
24
|
+
* Congressional Record, hearings, House/Senate documents, public laws,
|
|
25
|
+
* Statutes at Large, US Reports, Code of Federal Regulations.
|
|
26
|
+
*
|
|
27
|
+
* Complement to `federal-register` (FR metadata only) and `congress`.
|
|
28
|
+
*
|
|
29
|
+
* API: https://api.govinfo.gov/docs
|
|
30
|
+
* Auth: `?api_key=` query (reuses data.gov key).
|
|
31
|
+
*
|
|
32
|
+
* Tools:
|
|
33
|
+
* - list_collections: available collections (BILLS, CFR, etc.)
|
|
34
|
+
* - search_packages: search across or within a collection
|
|
35
|
+
* - get_package: metadata for a package (e.g., one issue, one bill)
|
|
36
|
+
* - list_granules: sub-units inside a package (sections of a CFR title)
|
|
37
|
+
* - get_granule: single granule metadata
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
const BASE_URL = 'https://api.govinfo.gov';
|
|
42
|
+
|
|
43
|
+
const tools: McpToolExport['tools'] = [
|
|
44
|
+
{
|
|
45
|
+
name: 'list_collections',
|
|
46
|
+
description:
|
|
47
|
+
'List GovInfo collections (BILLS, CFR, USCODE, FR, CHRG, CRPT, HMAN, PLAW, SERIALSET, USCOURTS, etc.) with package counts. Use the collection code with search_packages to filter.',
|
|
48
|
+
inputSchema: { type: 'object', properties: {}, required: [] },
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
name: 'search_packages',
|
|
52
|
+
description:
|
|
53
|
+
'Full-text + faceted search across GovInfo. Filter by collection codes (comma-separated), date range, congress, court (for USCOURTS), and free-text query. Returns package IDs and titles.',
|
|
54
|
+
inputSchema: {
|
|
55
|
+
type: 'object',
|
|
56
|
+
properties: {
|
|
57
|
+
query: { type: 'string', description: 'Free-text search' },
|
|
58
|
+
collections: {
|
|
59
|
+
type: 'string',
|
|
60
|
+
description: 'Comma-separated collection codes (e.g., "BILLS,FR")',
|
|
61
|
+
},
|
|
62
|
+
congress: { type: 'number', description: 'Congress number (e.g., 118) — for BILLS/CHRG/CRPT' },
|
|
63
|
+
date_from: { type: 'string', description: 'YYYY-MM-DD' },
|
|
64
|
+
date_to: { type: 'string', description: 'YYYY-MM-DD' },
|
|
65
|
+
page_size: { type: 'number', description: '1-100 (default 25)' },
|
|
66
|
+
offset_mark: { type: 'string', description: 'Pagination cursor from previous response' },
|
|
67
|
+
},
|
|
68
|
+
required: ['query'],
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
name: 'get_package',
|
|
73
|
+
description:
|
|
74
|
+
'Metadata for a single package by packageId (e.g., "BILLS-118hr1234ih", "FR-2024-05-12"). Returns title, dates, citations, granule count, download links (PDF/XML/MODS).',
|
|
75
|
+
inputSchema: {
|
|
76
|
+
type: 'object',
|
|
77
|
+
properties: {
|
|
78
|
+
package_id: { type: 'string', description: 'GovInfo packageId' },
|
|
79
|
+
},
|
|
80
|
+
required: ['package_id'],
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
name: 'list_granules',
|
|
85
|
+
description:
|
|
86
|
+
'List granules within a package — e.g., sections of a CFR title, individual entries in a Federal Register issue. Returns granule IDs + titles.',
|
|
87
|
+
inputSchema: {
|
|
88
|
+
type: 'object',
|
|
89
|
+
properties: {
|
|
90
|
+
package_id: { type: 'string', description: 'GovInfo packageId' },
|
|
91
|
+
page_size: { type: 'number', description: '1-100 (default 100)' },
|
|
92
|
+
offset_mark: { type: 'string', description: 'Pagination cursor' },
|
|
93
|
+
},
|
|
94
|
+
required: ['package_id'],
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
name: 'get_granule',
|
|
99
|
+
description: 'Granule metadata for a sub-unit within a package.',
|
|
100
|
+
inputSchema: {
|
|
101
|
+
type: 'object',
|
|
102
|
+
properties: {
|
|
103
|
+
package_id: { type: 'string', description: 'GovInfo packageId' },
|
|
104
|
+
granule_id: { type: 'string', description: 'Granule ID' },
|
|
105
|
+
},
|
|
106
|
+
required: ['package_id', 'granule_id'],
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
];
|
|
110
|
+
|
|
111
|
+
async function callTool(name: string, args: Record<string, unknown>): Promise<unknown> {
|
|
112
|
+
const apiKey = (args._apiKey as string | undefined)?.trim();
|
|
113
|
+
if (!apiKey) {
|
|
114
|
+
throw new Error(
|
|
115
|
+
'GovInfo requires a data.gov API key. Contact the operator about platform credentials (PLATFORM_DATAGOV_KEY), or BYO via ?_apiKey=<key> after registering at https://api.data.gov/signup.',
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
switch (name) {
|
|
119
|
+
case 'list_collections':
|
|
120
|
+
return listCollections(apiKey);
|
|
121
|
+
case 'search_packages':
|
|
122
|
+
return searchPackages(apiKey, args);
|
|
123
|
+
case 'get_package':
|
|
124
|
+
return getPackage(apiKey, reqStr(args, 'package_id', '"BILLS-118hr1234ih"'));
|
|
125
|
+
case 'list_granules':
|
|
126
|
+
return listGranules(apiKey, args);
|
|
127
|
+
case 'get_granule':
|
|
128
|
+
return getGranule(
|
|
129
|
+
apiKey,
|
|
130
|
+
reqStr(args, 'package_id', '"PLAW-117publ328"'),
|
|
131
|
+
reqStr(args, 'granule_id', '"<granule_id>"'),
|
|
132
|
+
);
|
|
133
|
+
default:
|
|
134
|
+
throw new Error(`Unknown tool: ${name}`);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function reqStr(args: Record<string, unknown>, key: string, example: string): string {
|
|
139
|
+
const v = args[key];
|
|
140
|
+
if (typeof v !== 'string' || !v.trim()) {
|
|
141
|
+
throw new Error(`Required argument "${key}" is missing or empty. Pass a string like ${example}.`);
|
|
142
|
+
}
|
|
143
|
+
return v;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
async function giFetch<T>(apiKey: string, path: string, params: URLSearchParams): Promise<T> {
|
|
147
|
+
params.set('api_key', apiKey);
|
|
148
|
+
const url = `${BASE_URL}${path}?${params}`;
|
|
149
|
+
const res = await fetch(url, { headers: { Accept: 'application/json' } });
|
|
150
|
+
if (res.status === 401 || res.status === 403) throw new Error('GovInfo: unauthorized — check the data.gov key');
|
|
151
|
+
if (res.status === 404) throw new Error('GovInfo: not found (HTTP 404)');
|
|
152
|
+
if (res.status === 429) throw new Error('GovInfo: rate-limit (HTTP 429)');
|
|
153
|
+
if (!res.ok) {
|
|
154
|
+
const body = await res.text();
|
|
155
|
+
throw new Error(`GovInfo error: ${res.status} ${body.slice(0, 200)}`);
|
|
156
|
+
}
|
|
157
|
+
return res.json() as Promise<T>;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
async function giPost<T>(apiKey: string, path: string, body: unknown): Promise<T> {
|
|
161
|
+
const url = `${BASE_URL}${path}?api_key=${encodeURIComponent(apiKey)}`;
|
|
162
|
+
const res = await fetch(url, {
|
|
163
|
+
method: 'POST',
|
|
164
|
+
headers: { 'Content-Type': 'application/json', Accept: 'application/json' },
|
|
165
|
+
body: JSON.stringify(body),
|
|
166
|
+
});
|
|
167
|
+
if (res.status === 401 || res.status === 403) throw new Error('GovInfo: unauthorized — check the data.gov key');
|
|
168
|
+
if (res.status === 429) throw new Error('GovInfo: rate-limit (HTTP 429)');
|
|
169
|
+
if (!res.ok) {
|
|
170
|
+
const text = await res.text();
|
|
171
|
+
throw new Error(`GovInfo error: ${res.status} ${text.slice(0, 200)}`);
|
|
172
|
+
}
|
|
173
|
+
return res.json() as Promise<T>;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
async function listCollections(apiKey: string) {
|
|
177
|
+
const data = await giFetch<{
|
|
178
|
+
collections?: { collectionCode?: string; collectionName?: string; packageCount?: number; granuleCount?: number }[];
|
|
179
|
+
}>(apiKey, '/collections', new URLSearchParams());
|
|
180
|
+
return {
|
|
181
|
+
count: data.collections?.length ?? 0,
|
|
182
|
+
collections: (data.collections ?? []).map((c) => ({
|
|
183
|
+
code: c.collectionCode ?? null,
|
|
184
|
+
name: c.collectionName ?? null,
|
|
185
|
+
package_count: c.packageCount ?? null,
|
|
186
|
+
granule_count: c.granuleCount ?? null,
|
|
187
|
+
})),
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
async function searchPackages(apiKey: string, args: Record<string, unknown>) {
|
|
192
|
+
// GovInfo search uses POST /search with a JSON body.
|
|
193
|
+
const filters: string[] = [`query:"${String(args.query).replace(/"/g, '\\"')}"`];
|
|
194
|
+
if (args.collections) filters.push(`collection:(${String(args.collections)})`);
|
|
195
|
+
if (args.congress) filters.push(`congress:${args.congress}`);
|
|
196
|
+
if (args.date_from && args.date_to) {
|
|
197
|
+
filters.push(`publishdate:range(${args.date_from},${args.date_to})`);
|
|
198
|
+
} else if (args.date_from) {
|
|
199
|
+
filters.push(`publishdate:range(${args.date_from},)`);
|
|
200
|
+
} else if (args.date_to) {
|
|
201
|
+
filters.push(`publishdate:range(,${args.date_to})`);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
const body = {
|
|
205
|
+
query: filters.join(' AND '),
|
|
206
|
+
pageSize: Math.min(100, Math.max(1, (args.page_size as number) ?? 25)),
|
|
207
|
+
offsetMark: (args.offset_mark as string) ?? '*',
|
|
208
|
+
sorts: [{ field: 'relevancy', sortOrder: 'DESC' }],
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
const data = await giPost<{
|
|
212
|
+
count?: number;
|
|
213
|
+
offsetMark?: string;
|
|
214
|
+
results?: {
|
|
215
|
+
packageId?: string;
|
|
216
|
+
title?: string;
|
|
217
|
+
collectionCode?: string;
|
|
218
|
+
collectionName?: string;
|
|
219
|
+
dateIssued?: string;
|
|
220
|
+
lastModified?: string;
|
|
221
|
+
packageLink?: string;
|
|
222
|
+
detailsLink?: string;
|
|
223
|
+
}[];
|
|
224
|
+
}>(apiKey, '/search', body);
|
|
225
|
+
|
|
226
|
+
return {
|
|
227
|
+
total: data.count ?? 0,
|
|
228
|
+
next_offset_mark: data.offsetMark ?? null,
|
|
229
|
+
returned: data.results?.length ?? 0,
|
|
230
|
+
results: (data.results ?? []).map((r) => ({
|
|
231
|
+
package_id: r.packageId ?? null,
|
|
232
|
+
title: r.title ?? null,
|
|
233
|
+
collection: r.collectionCode ?? null,
|
|
234
|
+
collection_name: r.collectionName ?? null,
|
|
235
|
+
date_issued: r.dateIssued ?? null,
|
|
236
|
+
last_modified: r.lastModified ?? null,
|
|
237
|
+
package_link: r.packageLink ?? null,
|
|
238
|
+
details_link: r.detailsLink ?? null,
|
|
239
|
+
})),
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
async function getPackage(apiKey: string, packageId: string) {
|
|
244
|
+
const data = await giFetch<Record<string, unknown>>(apiKey, `/packages/${encodeURIComponent(packageId)}/summary`, new URLSearchParams());
|
|
245
|
+
return data;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
async function listGranules(apiKey: string, args: Record<string, unknown>) {
|
|
249
|
+
const packageId = reqStr(args, 'package_id', '"FR-2024-05-12"');
|
|
250
|
+
const params = new URLSearchParams({
|
|
251
|
+
pageSize: String(Math.min(100, Math.max(1, (args.page_size as number) ?? 100))),
|
|
252
|
+
});
|
|
253
|
+
if (args.offset_mark) params.set('offsetMark', String(args.offset_mark));
|
|
254
|
+
else params.set('offsetMark', '*');
|
|
255
|
+
|
|
256
|
+
const data = await giFetch<{
|
|
257
|
+
count?: number;
|
|
258
|
+
offsetMark?: string;
|
|
259
|
+
granules?: { granuleId?: string; title?: string; granuleClass?: string; granuleLink?: string }[];
|
|
260
|
+
}>(apiKey, `/packages/${encodeURIComponent(packageId)}/granules`, params);
|
|
261
|
+
|
|
262
|
+
return {
|
|
263
|
+
package_id: packageId,
|
|
264
|
+
total: data.count ?? 0,
|
|
265
|
+
next_offset_mark: data.offsetMark ?? null,
|
|
266
|
+
returned: data.granules?.length ?? 0,
|
|
267
|
+
granules: (data.granules ?? []).map((g) => ({
|
|
268
|
+
id: g.granuleId ?? null,
|
|
269
|
+
title: g.title ?? null,
|
|
270
|
+
class: g.granuleClass ?? null,
|
|
271
|
+
link: g.granuleLink ?? null,
|
|
272
|
+
})),
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
async function getGranule(apiKey: string, packageId: string, granuleId: string) {
|
|
277
|
+
const data = await giFetch<Record<string, unknown>>(
|
|
278
|
+
apiKey,
|
|
279
|
+
`/packages/${encodeURIComponent(packageId)}/granules/${encodeURIComponent(granuleId)}/summary`,
|
|
280
|
+
new URLSearchParams(),
|
|
281
|
+
);
|
|
282
|
+
return data;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
export default { tools, callTool, meter: { credits: 1 } } satisfies McpToolExport;
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "bundler",
|
|
6
|
+
"strict": true,
|
|
7
|
+
"esModuleInterop": true,
|
|
8
|
+
"skipLibCheck": true,
|
|
9
|
+
"outDir": "dist",
|
|
10
|
+
"rootDir": "src",
|
|
11
|
+
"declaration": true
|
|
12
|
+
},
|
|
13
|
+
"include": ["src"]
|
|
14
|
+
}
|