@pipeworx/mcp-grants-gov 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-grants-gov
2
+
3
+ Grants.gov MCP — open federal grant opportunities (free, no auth)
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
+
12
+ ## Quick Start
13
+
14
+ Add to your MCP client (Claude Desktop, Cursor, Windsurf, etc.):
15
+
16
+ ```json
17
+ {
18
+ "mcpServers": {
19
+ "grants-gov": {
20
+ "url": "https://gateway.pipeworx.io/grants-gov/mcp"
21
+ }
22
+ }
23
+ }
24
+ ```
25
+
26
+ Or connect to the full Pipeworx gateway for access to all 250+ 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 Grants Gov 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-grants-gov",
3
+ "version": "0.1.0",
4
+ "description": "Grants.gov MCP — open federal grant opportunities (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", "grants-gov"],
9
+ "license": "MIT",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/pipeworx-io/mcp-grants-gov"
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/grants-gov",
4
+ "title": "Grants Gov",
5
+ "description": "Grants.gov MCP — open federal grant opportunities (free, no auth)",
6
+ "version": "0.1.0",
7
+ "websiteUrl": "https://pipeworx.io/packs/grants-gov",
8
+ "repository": {
9
+ "url": "https://github.com/pipeworx-io/mcp-grants-gov",
10
+ "source": "github"
11
+ },
12
+ "remotes": [
13
+ {
14
+ "type": "streamable-http",
15
+ "url": "https://gateway.pipeworx.io/grants-gov/mcp"
16
+ }
17
+ ]
18
+ }
package/src/index.ts ADDED
@@ -0,0 +1,244 @@
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
+ * Grants.gov MCP — open federal grant opportunities (free, no auth)
21
+ *
22
+ * Sister pack to nih-reporter (awarded grants) and nsf-awards. Grants.gov is
23
+ * the federal-wide clearinghouse for currently-open and forecasted opportunities.
24
+ *
25
+ * API: https://www.grants.gov/web/grants/s2s/grantor/schemas/grants-gov-search2.html
26
+ * Tools:
27
+ * - search_opportunities: filter by keyword, status, agency, funding category, dates
28
+ * - get_opportunity: single full record with attachments and synopsis text
29
+ */
30
+
31
+
32
+ const BASE_URL = 'https://api.grants.gov/v1/api';
33
+
34
+ const tools: McpToolExport['tools'] = [
35
+ {
36
+ name: 'search_opportunities',
37
+ description:
38
+ 'Search Grants.gov for currently-open or recently-closed federal funding opportunities. Filter by keyword, opportunity status, agency code, funding category, or date range. Returns opportunity number, title, agency, open/close dates, and assistance listing numbers (formerly CFDA).',
39
+ inputSchema: {
40
+ type: 'object',
41
+ properties: {
42
+ keyword: { type: 'string', description: 'Full-text query' },
43
+ status: {
44
+ type: 'string',
45
+ description: 'forecasted | posted | closed | archived (default posted; use a pipe to combine, e.g. "posted|forecasted")',
46
+ },
47
+ agencies: { type: 'string', description: 'Comma-separated agency codes (e.g., "EPA,USDA,NIH")' },
48
+ funding_categories: {
49
+ type: 'string',
50
+ description: 'Comma-separated category codes (e.g., "ED" education, "ENV" environment, "ST" science)',
51
+ },
52
+ aln: { type: 'string', description: 'Assistance Listing Number / CFDA number (e.g., "10.001")' },
53
+ limit: { type: 'number', description: 'Rows per page (1-1000, default 25)' },
54
+ offset: { type: 'number', description: '0-based start record (default 0)' },
55
+ },
56
+ required: [],
57
+ },
58
+ },
59
+ {
60
+ name: 'get_opportunity',
61
+ description:
62
+ 'Fetch full details for a Grants.gov opportunity by ID. Returns synopsis text, eligibility, award ceiling/floor, attachments, contact info, and version history.',
63
+ inputSchema: {
64
+ type: 'object',
65
+ properties: {
66
+ opportunity_id: {
67
+ type: 'number',
68
+ description: 'Numeric opportunity ID (returned by search_opportunities as "id")',
69
+ },
70
+ },
71
+ required: ['opportunity_id'],
72
+ },
73
+ },
74
+ ];
75
+
76
+ async function callTool(name: string, args: Record<string, unknown>): Promise<unknown> {
77
+ switch (name) {
78
+ case 'search_opportunities':
79
+ return searchOpps(args);
80
+ case 'get_opportunity':
81
+ return getOpp(args.opportunity_id as number);
82
+ default:
83
+ throw new Error(`Unknown tool: ${name}`);
84
+ }
85
+ }
86
+
87
+ async function grantsPost<T>(path: string, body: unknown): Promise<T> {
88
+ const res = await fetch(`${BASE_URL}${path}`, {
89
+ method: 'POST',
90
+ headers: { 'Content-Type': 'application/json', Accept: 'application/json' },
91
+ body: JSON.stringify(body),
92
+ });
93
+ if (!res.ok) {
94
+ const text = await res.text();
95
+ throw new Error(`Grants.gov error: ${res.status} ${text.slice(0, 200)}`);
96
+ }
97
+ return res.json() as Promise<T>;
98
+ }
99
+
100
+ async function searchOpps(args: Record<string, unknown>) {
101
+ const body: Record<string, unknown> = {
102
+ rows: Math.min(1000, Math.max(1, (args.limit as number) ?? 25)),
103
+ startRecordNum: (args.offset as number) ?? 0,
104
+ sortBy: 'openDate|desc',
105
+ oppStatuses: (args.status as string) ?? 'posted',
106
+ };
107
+ if (args.keyword) body.keyword = String(args.keyword);
108
+ if (args.agencies) body.agencies = String(args.agencies);
109
+ if (args.funding_categories) body.fundingCategories = String(args.funding_categories);
110
+ if (args.aln) body.cfda = String(args.aln);
111
+
112
+ const data = await grantsPost<{
113
+ errorcode?: number;
114
+ msg?: string;
115
+ data?: {
116
+ hitCount?: number;
117
+ oppHits?: SearchHit[];
118
+ };
119
+ }>('/search2', body);
120
+
121
+ if (data.errorcode && data.errorcode !== 0) {
122
+ throw new Error(`Grants.gov: ${data.msg ?? 'unknown error'}`);
123
+ }
124
+
125
+ const hits = data.data?.oppHits ?? [];
126
+ return {
127
+ total: data.data?.hitCount ?? 0,
128
+ returned: hits.length,
129
+ opportunities: hits.map(normalizeHit),
130
+ };
131
+ }
132
+
133
+ async function getOpp(opportunityId: number) {
134
+ const data = await grantsPost<{
135
+ errorcode?: number;
136
+ msg?: string;
137
+ data?: OpportunityDetail;
138
+ }>('/fetchOpportunity', { opportunityId });
139
+
140
+ if (data.errorcode && data.errorcode !== 0) {
141
+ throw new Error(`Grants.gov: ${data.msg ?? `no opportunity ${opportunityId}`}`);
142
+ }
143
+ const d = data.data;
144
+ if (!d) throw new Error(`Grants.gov: no data for opportunity ${opportunityId}`);
145
+
146
+ return normalizeDetail(d);
147
+ }
148
+
149
+ interface SearchHit {
150
+ id?: string;
151
+ number?: string;
152
+ title?: string;
153
+ agencyCode?: string;
154
+ agencyName?: string;
155
+ agency?: string;
156
+ openDate?: string;
157
+ closeDate?: string;
158
+ oppStatus?: string;
159
+ docType?: string;
160
+ alnist?: { alnis?: string }[];
161
+ }
162
+
163
+ function normalizeHit(h: SearchHit) {
164
+ return {
165
+ id: h.id ? Number(h.id) : null,
166
+ number: h.number ?? null,
167
+ title: h.title ?? null,
168
+ agency_code: h.agencyCode ?? null,
169
+ agency: h.agencyName ?? h.agency ?? null,
170
+ open_date: h.openDate ?? null,
171
+ close_date: h.closeDate ?? null,
172
+ status: h.oppStatus ?? null,
173
+ doc_type: h.docType ?? null,
174
+ assistance_listing_numbers: (h.alnist ?? []).map((a) => a.alnis).filter(Boolean),
175
+ grants_gov_url: h.id ? `https://www.grants.gov/search-results-detail/${h.id}` : null,
176
+ };
177
+ }
178
+
179
+ interface OpportunityDetail {
180
+ id?: number;
181
+ opportunityNumber?: string;
182
+ opportunityTitle?: string;
183
+ agencyCode?: string;
184
+ agencyName?: string;
185
+ topAgencyDetails?: { agencyCode?: string; agencyName?: string };
186
+ synopsis?: {
187
+ synopsisDesc?: string;
188
+ awardCeiling?: string;
189
+ awardFloor?: string;
190
+ estimatedFunding?: string;
191
+ awardNumber?: string;
192
+ fundingInstrument?: { fundingInstrumentName?: string }[];
193
+ fundingActivityCategories?: { categoryName?: string }[];
194
+ applicantTypes?: { applicantTypeName?: string }[];
195
+ eligibilityDesc?: string;
196
+ agencyContactName?: string;
197
+ agencyContactEmail?: string;
198
+ agencyContactPhone?: string;
199
+ postingDate?: string;
200
+ responseDate?: string;
201
+ closingDateDesc?: string;
202
+ archiveDate?: string;
203
+ };
204
+ cfdas?: { cfdaNumber?: string; programTitle?: string }[];
205
+ synopsisAttachmentFolders?: { folderName?: string; attachments?: { fileName?: string; downloadURL?: string }[] }[];
206
+ }
207
+
208
+ function normalizeDetail(d: OpportunityDetail) {
209
+ const s = d.synopsis ?? {};
210
+ return {
211
+ id: d.id ?? null,
212
+ number: d.opportunityNumber ?? null,
213
+ title: d.opportunityTitle ?? null,
214
+ agency_code: d.agencyCode ?? d.topAgencyDetails?.agencyCode ?? null,
215
+ agency: d.agencyName ?? d.topAgencyDetails?.agencyName ?? null,
216
+ synopsis: s.synopsisDesc ?? null,
217
+ eligibility: s.eligibilityDesc ?? null,
218
+ award_ceiling: s.awardCeiling ? Number(s.awardCeiling) : null,
219
+ award_floor: s.awardFloor ? Number(s.awardFloor) : null,
220
+ estimated_funding: s.estimatedFunding ? Number(s.estimatedFunding) : null,
221
+ expected_awards: s.awardNumber ? Number(s.awardNumber) : null,
222
+ funding_instruments: (s.fundingInstrument ?? []).map((f) => f.fundingInstrumentName).filter(Boolean),
223
+ funding_categories: (s.fundingActivityCategories ?? []).map((c) => c.categoryName).filter(Boolean),
224
+ applicant_types: (s.applicantTypes ?? []).map((a) => a.applicantTypeName).filter(Boolean),
225
+ cfdas: (d.cfdas ?? []).map((c) => ({ number: c.cfdaNumber ?? null, title: c.programTitle ?? null })),
226
+ posting_date: s.postingDate ?? null,
227
+ response_date: s.responseDate ?? null,
228
+ closing_date_desc: s.closingDateDesc ?? null,
229
+ archive_date: s.archiveDate ?? null,
230
+ contact_name: s.agencyContactName ?? null,
231
+ contact_email: s.agencyContactEmail ?? null,
232
+ contact_phone: s.agencyContactPhone ?? null,
233
+ attachments: (d.synopsisAttachmentFolders ?? []).flatMap((f) =>
234
+ (f.attachments ?? []).map((a) => ({
235
+ folder: f.folderName ?? null,
236
+ file_name: a.fileName ?? null,
237
+ download_url: a.downloadURL ?? null,
238
+ })),
239
+ ),
240
+ grants_gov_url: d.id ? `https://www.grants.gov/search-results-detail/${d.id}` : null,
241
+ };
242
+ }
243
+
244
+ 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
+ }