@pipeworx/mcp-gov-bids 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-gov-bids
2
+
3
+ Live open US government bid solicitations (RFPs/RFQs) from Bonfire city & county portals — keyless
4
+
5
+ Part of [Pipeworx](https://pipeworx.io) — an MCP gateway connecting AI agents to 1330+ 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
+ "gov-bids": {
20
+ "url": "https://gateway.pipeworx.io/gov-bids/mcp"
21
+ }
22
+ }
23
+ }
24
+ ```
25
+
26
+ Or connect to the full Pipeworx gateway for access to all 1330+ 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 Gov Bids 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-gov-bids",
3
+ "version": "0.1.0",
4
+ "description": "Live open US government bid solicitations (RFPs/RFQs) from Bonfire city & county portals — keyless",
5
+ "type": "module",
6
+ "main": "src/index.ts",
7
+ "types": "src/index.ts",
8
+ "keywords": ["mcp", "mcp-server", "model-context-protocol", "pipeworx", "gov-bids"],
9
+ "license": "MIT",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/pipeworx-io/mcp-gov-bids"
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/gov-bids",
4
+ "title": "Gov Bids",
5
+ "description": "Live open US government bid solicitations (RFPs/RFQs) from Bonfire city & county portals — keyless",
6
+ "version": "0.1.0",
7
+ "websiteUrl": "https://pipeworx.io/packs/gov-bids",
8
+ "repository": {
9
+ "url": "https://github.com/pipeworx-io/mcp-gov-bids",
10
+ "source": "github"
11
+ },
12
+ "remotes": [
13
+ {
14
+ "type": "streamable-http",
15
+ "url": "https://gateway.pipeworx.io/gov-bids/mcp"
16
+ }
17
+ ]
18
+ }
package/src/index.ts ADDED
@@ -0,0 +1,191 @@
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
+ * Gov Bids MCP — live OPEN government bid solicitations from Bonfire portals.
21
+ *
22
+ * US state/local bid portals have no sanctioned public API, but Bonfire (Euna),
23
+ * the most common big-city/county bid platform, serves its public opportunity
24
+ * list from an anonymous session endpoint that its own SPA calls:
25
+ * 1. GET https://<portal>.bonfirehub.com/portal/ → sets `bonfirehub` session
26
+ * cookie + `XSRF-TOKEN` cookie.
27
+ * 2. GET /PublicPortal/getOpenPublicOpportunitiesSectionData with those cookies
28
+ * + the XSRF token echoed as `X-XSRF-TOKEN` → JSON {payload:{projects:{...}}}.
29
+ * No API key. This pack fronts that across a registry of Bonfire portals,
30
+ * normalized, so an agent can find open bids by jurisdiction/keyword.
31
+ *
32
+ * Wave 4a (live-fetch). The hosted-history version (never-delete moat, gov-auction
33
+ * pattern) is Wave 4b — see docs/us-procurement-build-plan.md.
34
+ */
35
+
36
+
37
+ const UA = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36';
38
+
39
+ // Bonfire portals (subdomain → display jurisdiction). Grows freely; every
40
+ // bonfirehub.com subdomain uses the identical endpoint. Seed = big verified ones.
41
+ const PORTALS: Array<{ key: string; sub: string; name: string }> = [
42
+ { key: 'fort-worth-tx', sub: 'fortworthtexas', name: 'Fort Worth, TX' },
43
+ { key: 'harris-county-tx', sub: 'harriscountytx', name: 'Harris County, TX' },
44
+ { key: 'broward-county-fl', sub: 'broward', name: 'Broward County, FL' },
45
+ { key: 'cook-county-il', sub: 'cookcountyil', name: 'Cook County, IL' },
46
+ { key: 'clark-county-nv', sub: 'clarkcountynv', name: 'Clark County, NV' },
47
+ { key: 'dallas-tx', sub: 'dallascityhall', name: 'Dallas, TX' },
48
+ ];
49
+
50
+ const BY_KEY = new Map(PORTALS.map((p) => [p.key, p]));
51
+
52
+ const tools: McpToolExport['tools'] = [
53
+ {
54
+ name: 'open_bids_search',
55
+ description:
56
+ "Find OPEN government bid solicitations (RFPs/RFQs/IFBs) that vendors can currently respond to, from US city & county Bonfire procurement portals — live, keyless. Filter by keyword (matches the solicitation title) and/or a specific jurisdiction; omit jurisdiction to search all covered portals. Returns each open opportunity with its title, reference number, awarding jurisdiction, close date, and the URL to view/respond. Use this for 'what contracts is <city/county> currently bidding out' or 'open RFPs for <keyword>'. This is LIVE OPEN BIDS (for awarded/historical contracts use gov_contracts_search).",
57
+ inputSchema: {
58
+ type: 'object' as const,
59
+ properties: {
60
+ jurisdiction: { type: 'string', description: 'Portal key to target (e.g. "fort-worth-tx", "harris-county-tx", "cook-county-il"). Omit to search all covered jurisdictions. Use gov_bids_jurisdictions to list keys.' },
61
+ keyword: { type: 'string', description: 'Case-insensitive substring to match against the solicitation title, e.g. "construction", "audit", "software".' },
62
+ limit: { type: ['number', 'string'], description: 'Max open bids per jurisdiction (default 25).' },
63
+ },
64
+ },
65
+ },
66
+ {
67
+ name: 'gov_bids_jurisdictions',
68
+ description:
69
+ 'List the US city & county Bonfire procurement portals covered by open_bids_search, with each portal key, jurisdiction name, and current live open-bid count.',
70
+ inputSchema: { type: 'object' as const, properties: {} },
71
+ },
72
+ ];
73
+
74
+ interface BonfireProject {
75
+ ProjectID?: string;
76
+ ReferenceID?: string;
77
+ ProjectName?: string;
78
+ DateClose?: string;
79
+ ProjectStatusID?: string;
80
+ DepartmentID?: string;
81
+ }
82
+
83
+ // Anonymous session handshake: fetch the portal page for the session +
84
+ // XSRF-TOKEN cookies, then call the section endpoint echoing the XSRF token.
85
+ async function fetchOpenProjects(sub: string): Promise<BonfireProject[]> {
86
+ const base = `https://${sub}.bonfirehub.com`;
87
+ const page = await fetch(`${base}/portal/`, { headers: { 'User-Agent': UA, Accept: 'text/html' } });
88
+ if (!page.ok) throw new Error(`portal ${page.status}`);
89
+ const setCookies: string[] =
90
+ typeof (page.headers as unknown as { getSetCookie?: () => string[] }).getSetCookie === 'function'
91
+ ? (page.headers as unknown as { getSetCookie: () => string[] }).getSetCookie()
92
+ : page.headers.get('set-cookie')
93
+ ? [page.headers.get('set-cookie') as string]
94
+ : [];
95
+ const jar = setCookies.map((c) => c.split(';')[0]);
96
+ const cookie = jar.join('; ');
97
+ const xsrf = jar.find((c) => c.startsWith('XSRF-TOKEN='))?.split('=')[1] ?? '';
98
+ const res = await fetch(`${base}/PublicPortal/getOpenPublicOpportunitiesSectionData`, {
99
+ headers: {
100
+ 'User-Agent': UA,
101
+ Accept: 'application/json',
102
+ 'X-Requested-With': 'XMLHttpRequest',
103
+ Cookie: cookie,
104
+ ...(xsrf ? { 'X-XSRF-TOKEN': decodeURIComponent(xsrf) } : {}),
105
+ },
106
+ });
107
+ if (!res.ok) throw new Error(`opportunities ${res.status}`);
108
+ const data = (await res.json()) as { success?: number; payload?: { projects?: Record<string, BonfireProject> } };
109
+ if (!data.success || !data.payload?.projects) return [];
110
+ return Object.values(data.payload.projects);
111
+ }
112
+
113
+ function normalize(p: BonfireProject, portal: { key: string; sub: string; name: string }): Record<string, unknown> {
114
+ const id = p.ProjectID ?? '';
115
+ return {
116
+ jurisdiction: portal.key,
117
+ jurisdiction_name: portal.name,
118
+ title: p.ProjectName ?? null,
119
+ reference: p.ReferenceID ?? null,
120
+ close_date: p.DateClose ?? null,
121
+ status: 'open',
122
+ url: id ? `https://${portal.sub}.bonfirehub.com/opportunities/${id}` : `https://${portal.sub}.bonfirehub.com/portal/`,
123
+ source: 'bonfire',
124
+ };
125
+ }
126
+
127
+ async function openFor(portal: { key: string; sub: string; name: string }, keyword: string | undefined, limit: number): Promise<Record<string, unknown>[]> {
128
+ let projects = await fetchOpenProjects(portal.sub);
129
+ if (keyword) {
130
+ const k = keyword.toLowerCase();
131
+ projects = projects.filter((p) => (p.ProjectName ?? '').toLowerCase().includes(k));
132
+ }
133
+ return projects.slice(0, limit).map((p) => normalize(p, portal));
134
+ }
135
+
136
+ async function search(args: Record<string, unknown>): Promise<unknown> {
137
+ const limit = Math.min(Math.max(Number(args.limit) || 25, 1), 100);
138
+ const keyword = typeof args.keyword === 'string' && args.keyword.trim() ? args.keyword.trim() : undefined;
139
+ const jurKey = typeof args.jurisdiction === 'string' && args.jurisdiction.trim() ? args.jurisdiction.trim().toLowerCase() : undefined;
140
+ let targets = PORTALS;
141
+ if (jurKey) {
142
+ const p = BY_KEY.get(jurKey);
143
+ if (!p) return { error: 'user_error', message: `Unknown jurisdiction "${jurKey}". Call gov_bids_jurisdictions for keys.` };
144
+ targets = [p];
145
+ }
146
+ const settled = await Promise.allSettled(targets.map((p) => openFor(p, keyword, limit)));
147
+ const bids: Record<string, unknown>[] = [];
148
+ const errors: Record<string, string> = {};
149
+ settled.forEach((s, i) => {
150
+ if (s.status === 'fulfilled') bids.push(...s.value);
151
+ else errors[targets[i].key] = s.reason instanceof Error ? s.reason.message : String(s.reason);
152
+ });
153
+ return {
154
+ jurisdictions_searched: targets.map((p) => p.key),
155
+ count: bids.length,
156
+ open_bids: bids,
157
+ ...(Object.keys(errors).length ? { errors } : {}),
158
+ };
159
+ }
160
+
161
+ async function jurisdictionsList(): Promise<unknown> {
162
+ const rows = await Promise.all(
163
+ PORTALS.map(async (p) => {
164
+ let open_bids: number | null = null;
165
+ try {
166
+ open_bids = (await fetchOpenProjects(p.sub)).length;
167
+ } catch {
168
+ open_bids = null;
169
+ }
170
+ return { key: p.key, name: p.name, portal: `${p.sub}.bonfirehub.com`, open_bids };
171
+ }),
172
+ );
173
+ return { count: rows.length, jurisdictions: rows };
174
+ }
175
+
176
+ async function callTool(name: string, args: Record<string, unknown>): Promise<unknown> {
177
+ try {
178
+ switch (name) {
179
+ case 'open_bids_search':
180
+ return await search(args);
181
+ case 'gov_bids_jurisdictions':
182
+ return await jurisdictionsList();
183
+ default:
184
+ return { error: `Unknown tool: ${name}` };
185
+ }
186
+ } catch (err) {
187
+ return { error: err instanceof Error ? err.message : String(err) };
188
+ }
189
+ }
190
+
191
+ 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
+ }