@pipeworx/mcp-federal-register 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 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,55 @@
1
+ # mcp-federal-register
2
+
3
+ Federal Register MCP — US Federal Register API (free, no auth)
4
+
5
+ Part of [Pipeworx](https://pipeworx.io) — an MCP gateway connecting AI agents to 965+ live data sources.
6
+
7
+ ## Tools
8
+
9
+ | Tool | Description |
10
+ |------|-------------|
11
+
12
+ ## Quick Start
13
+
14
+ Add to your MCP client (Claude Desktop, Cursor, Windsurf, etc.):
15
+
16
+ ```json
17
+ {
18
+ "mcpServers": {
19
+ "federal-register": {
20
+ "url": "https://gateway.pipeworx.io/federal-register/mcp"
21
+ }
22
+ }
23
+ }
24
+ ```
25
+
26
+ Or connect to the full Pipeworx gateway for access to all 965+ data sources:
27
+
28
+ ```json
29
+ {
30
+ "mcpServers": {
31
+ "pipeworx": {
32
+ "url": "https://gateway.pipeworx.io/mcp"
33
+ }
34
+ }
35
+ }
36
+ ```
37
+
38
+ ## Using with ask_pipeworx
39
+
40
+ Instead of calling tools directly, you can ask questions in plain English:
41
+
42
+ ```
43
+ ask_pipeworx({ question: "your question about Federal Register data" })
44
+ ```
45
+
46
+ The gateway picks the right tool and fills the arguments automatically.
47
+
48
+ ## More
49
+
50
+ - [All tools and guides](https://github.com/pipeworx-io/examples)
51
+ - [pipeworx.io](https://pipeworx.io)
52
+
53
+ ## License
54
+
55
+ MIT
package/package.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "@pipeworx/mcp-federal-register",
3
+ "version": "0.1.0",
4
+ "description": "Federal Register MCP — US Federal Register API (free, no auth)",
5
+ "type": "module",
6
+ "main": "src/index.ts",
7
+ "types": "src/index.ts",
8
+ "keywords": ["mcp", "mcp-server", "model-context-protocol", "pipeworx", "federal-register"],
9
+ "license": "MIT",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/pipeworx-io/mcp-federal-register"
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/federal-register",
4
+ "title": "Federal Register",
5
+ "description": "Federal Register MCP — US Federal Register API (free, no auth)",
6
+ "version": "0.1.0",
7
+ "websiteUrl": "https://pipeworx.io/packs/federal-register",
8
+ "repository": {
9
+ "url": "https://github.com/pipeworx-io/mcp-federal-register",
10
+ "source": "github"
11
+ },
12
+ "remotes": [
13
+ {
14
+ "type": "streamable-http",
15
+ "url": "https://gateway.pipeworx.io/federal-register/mcp"
16
+ }
17
+ ]
18
+ }
package/src/index.ts ADDED
@@ -0,0 +1,225 @@
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
+ * Federal Register MCP — US Federal Register API (free, no auth)
21
+ *
22
+ * Tools:
23
+ * - search_documents: search Federal Register documents by keyword
24
+ * - get_document: get a specific document by FR document number
25
+ * - recent_rules: get recently published rules and regulations
26
+ */
27
+
28
+
29
+ const BASE = 'https://www.federalregister.gov/api/v1';
30
+
31
+ // ── Types ─────────────────────────────────────────────────────────────
32
+
33
+ type FRDocument = {
34
+ document_number?: string | null;
35
+ title?: string | null;
36
+ type?: string | null;
37
+ abstract?: string | null;
38
+ citation?: string | null;
39
+ publication_date?: string | null;
40
+ agencies?: { name?: string | null; raw_name?: string | null }[] | null;
41
+ html_url?: string | null;
42
+ pdf_url?: string | null;
43
+ action?: string | null;
44
+ dates?: string | null;
45
+ docket_ids?: string[] | null;
46
+ page_length?: number | null;
47
+ start_page?: number | null;
48
+ end_page?: number | null;
49
+ significant?: boolean | null;
50
+ signing_date?: string | null;
51
+ subtype?: string | null;
52
+ body_html_url?: string | null;
53
+ json_url?: string | null;
54
+ };
55
+
56
+ type FRSearchResponse = {
57
+ count?: number;
58
+ total_pages?: number;
59
+ results: FRDocument[];
60
+ };
61
+
62
+ function formatDoc(d: FRDocument) {
63
+ return {
64
+ document_number: d.document_number ?? null,
65
+ title: d.title ?? null,
66
+ type: d.type ?? null,
67
+ abstract: d.abstract ?? null,
68
+ citation: d.citation ?? null,
69
+ publication_date: d.publication_date ?? null,
70
+ agencies: (d.agencies ?? []).map((a) => a.name ?? a.raw_name ?? null).filter(Boolean),
71
+ html_url: d.html_url ?? null,
72
+ pdf_url: d.pdf_url ?? null,
73
+ action: d.action ?? null,
74
+ dates: d.dates ?? null,
75
+ docket_ids: d.docket_ids ?? [],
76
+ page_length: d.page_length ?? null,
77
+ significant: d.significant ?? null,
78
+ };
79
+ }
80
+
81
+ // ── Tool definitions ──────────────────────────────────────────────────
82
+
83
+ const tools: McpToolExport['tools'] = [
84
+ {
85
+ name: 'search_documents',
86
+ description:
87
+ 'Search the US Federal Register by topic / keyword for proposed rules, final rules, notices, and presidential documents. **Use this whenever the question mentions a SUBJECT** ("EV tax credits", "AI export controls", "PFAS regulations", "clean energy", "ozempic labeling", etc.) — recent_rules takes no topic filter and would return random unrelated rules. Returns title, abstract, agency, publication date, links. Examples: search_documents({query: "EV tax credit", type: "rule"}), search_documents({query: "artificial intelligence", agency: "commerce-department"}), search_documents({query: "Strait of Hormuz", since: "365d"}). Pass `since` to constrain to recent documents — without it the relevance ranker can return decade-old docs for sparse-term queries.',
88
+ inputSchema: {
89
+ type: 'object',
90
+ properties: {
91
+ query: { type: 'string', description: 'Search keywords (e.g., "clean energy tax credit")' },
92
+ type: {
93
+ type: 'string',
94
+ description: 'Document type filter: "rule", "proposed_rule", "notice", "presidential_document"',
95
+ },
96
+ agency: { type: 'string', description: 'Agency slug filter (e.g., "environmental-protection-agency", "securities-and-exchange-commission")' },
97
+ since: { type: 'string', description: 'Publication date floor. Accepts ISO date ("2025-01-01") or shorthand ("30d", "12m", "365d", "1y"). Recommended for any topical search to avoid stale results — the relevance ranker can surface 2004-2008 documents for queries with sparse hits.' },
98
+ },
99
+ required: ['query'],
100
+ },
101
+ },
102
+ {
103
+ name: 'get_document',
104
+ description:
105
+ 'Get full details for a Federal Register document by its document number (e.g., "2024-12345"). Returns title, abstract, full text link, agencies, dates, and docket information.',
106
+ inputSchema: {
107
+ type: 'object',
108
+ properties: {
109
+ number: { type: 'string', description: 'Federal Register document number (e.g., "2024-12345")' },
110
+ },
111
+ required: ['number'],
112
+ },
113
+ },
114
+ {
115
+ name: 'recent_rules',
116
+ description:
117
+ 'Browse the most recently published final rules and regulations from the Federal Register, **with no topic filter** — returns whatever was published most recently across every agency (FAA airworthiness directives, Coast Guard safety zones, EPA tolerance exemptions, etc.). For questions about a specific topic ("EV tax credits", "AI rules", "drug pricing"), use search_documents instead. Returns title, abstract, agency, effective dates, significance.',
118
+ inputSchema: {
119
+ type: 'object',
120
+ properties: {
121
+ limit: { type: 'number', description: 'Number of results to return (default 20, max 100)' },
122
+ },
123
+ },
124
+ },
125
+ ];
126
+
127
+ // ── callTool dispatcher ───────────────────────────────────────────────
128
+
129
+ function requireString(args: Record<string, unknown>, key: string): string {
130
+ const v = args[key];
131
+ if (typeof v !== 'string' || v.trim() === '') {
132
+ throw new Error(`Missing required parameter: ${key} (string)`);
133
+ }
134
+ return v;
135
+ }
136
+
137
+ async function callTool(name: string, args: Record<string, unknown>): Promise<unknown> {
138
+ switch (name) {
139
+ case 'search_documents':
140
+ return searchDocuments(
141
+ requireString(args, 'query'),
142
+ args.type as string | undefined,
143
+ args.agency as string | undefined,
144
+ args.since as string | undefined,
145
+ );
146
+ case 'get_document':
147
+ return getDocument(requireString(args, 'number'));
148
+ case 'recent_rules':
149
+ return recentRules((args.limit as number) ?? 20);
150
+ default:
151
+ throw new Error(`Unknown tool: ${name}`);
152
+ }
153
+ }
154
+
155
+ // "30d", "12m", "1y", or ISO date → ISO date floor for the publication_date filter.
156
+ function parseSince(since: string): string | null {
157
+ const trimmed = since.trim();
158
+ if (/^\d{4}-\d{2}-\d{2}$/.test(trimmed)) return trimmed;
159
+ const m = /^(\d+)\s*([dmy])$/i.exec(trimmed);
160
+ if (!m) return null;
161
+ const n = parseInt(m[1], 10);
162
+ const unit = m[2].toLowerCase();
163
+ const days = unit === 'd' ? n : unit === 'm' ? n * 30 : n * 365;
164
+ const d = new Date(Date.now() - days * 86400000);
165
+ return d.toISOString().slice(0, 10);
166
+ }
167
+
168
+ // ── Tool implementations ─────────────────────────────────────────────
169
+
170
+ async function searchDocuments(query: string, type?: string, agency?: string, since?: string) {
171
+ const params = new URLSearchParams({
172
+ 'conditions[term]': query,
173
+ per_page: '20',
174
+ order: 'relevance',
175
+ });
176
+ if (type) params.set('conditions[type][]', type);
177
+ if (agency) params.set('conditions[agencies][]', agency);
178
+ const sinceISO = since ? parseSince(since) : null;
179
+ if (sinceISO) params.set('conditions[publication_date][gte]', sinceISO);
180
+
181
+ const res = await fetch(`${BASE}/documents.json?${params}`);
182
+ if (!res.ok) throw new Error(`Federal Register API error: ${res.status}`);
183
+
184
+ const data = (await res.json()) as FRSearchResponse;
185
+ const results = data.results ?? [];
186
+
187
+ return {
188
+ query,
189
+ since: sinceISO,
190
+ total: data.count ?? results.length,
191
+ returned: results.length,
192
+ documents: results.map(formatDoc),
193
+ };
194
+ }
195
+
196
+ async function getDocument(number: string) {
197
+ const res = await fetch(`${BASE}/documents/${number}.json`);
198
+ if (!res.ok) throw new Error(`Federal Register API error (${res.status}): document ${number} not found`);
199
+
200
+ const data = (await res.json()) as FRDocument;
201
+ return formatDoc(data);
202
+ }
203
+
204
+ async function recentRules(limit: number) {
205
+ const count = Math.min(100, Math.max(1, limit));
206
+ const params = new URLSearchParams({
207
+ 'conditions[type][]': 'RULE',
208
+ per_page: String(count),
209
+ order: 'newest',
210
+ });
211
+
212
+ const res = await fetch(`${BASE}/documents.json?${params}`);
213
+ if (!res.ok) throw new Error(`Federal Register API error: ${res.status}`);
214
+
215
+ const data = (await res.json()) as FRSearchResponse;
216
+ const results = data.results ?? [];
217
+
218
+ return {
219
+ total: data.count ?? results.length,
220
+ returned: results.length,
221
+ rules: results.map(formatDoc),
222
+ };
223
+ }
224
+
225
+ 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
+ }