@pipeworx/mcp-recreation-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-recreation-gov
2
+
3
+ Recreation.gov MCP — wraps the Recreation Information Database (RIDB) API v1
4
+
5
+ Part of [Pipeworx](https://pipeworx.io) — an MCP gateway connecting AI agents to 764+ 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
+ "recreation-gov": {
20
+ "url": "https://gateway.pipeworx.io/recreation-gov/mcp"
21
+ }
22
+ }
23
+ }
24
+ ```
25
+
26
+ Or connect to the full Pipeworx gateway for access to all 764+ 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 Recreation 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-recreation-gov",
3
+ "version": "0.1.0",
4
+ "description": "Recreation.gov MCP — wraps the Recreation Information Database (RIDB) API v1",
5
+ "type": "module",
6
+ "main": "src/index.ts",
7
+ "types": "src/index.ts",
8
+ "keywords": ["mcp", "mcp-server", "model-context-protocol", "pipeworx", "recreation-gov"],
9
+ "license": "MIT",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/pipeworx-io/mcp-recreation-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/recreation-gov",
4
+ "title": "Recreation Gov",
5
+ "description": "Recreation.gov MCP — wraps the Recreation Information Database (RIDB) API v1",
6
+ "version": "0.1.0",
7
+ "websiteUrl": "https://pipeworx.io/packs/recreation-gov",
8
+ "repository": {
9
+ "url": "https://github.com/pipeworx-io/mcp-recreation-gov",
10
+ "source": "github"
11
+ },
12
+ "remotes": [
13
+ {
14
+ "type": "streamable-http",
15
+ "url": "https://gateway.pipeworx.io/recreation-gov/mcp"
16
+ }
17
+ ]
18
+ }
package/src/index.ts ADDED
@@ -0,0 +1,301 @@
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
+ * Recreation.gov MCP — wraps the Recreation Information Database (RIDB) API v1
21
+ * (ridb.recreation.gov), the official catalog of US federal outdoor recreation:
22
+ * campgrounds, national park & national forest recreation areas, facilities,
23
+ * and individual campsites bookable on Recreation.gov.
24
+ *
25
+ * Tools:
26
+ * - search_facilities: find campgrounds / facilities by name, state, activity, or geo radius
27
+ * - get_facility: full detail for one facility (campground) incl. directions & ADA access
28
+ * - search_recareas: find recreation areas (national parks/forests regions)
29
+ * - list_campsites: list the individual campsites within a facility (campground)
30
+ *
31
+ * Auth: RIDB API key in the `apikey` request HEADER (not a query param).
32
+ * Dual-key model: _apiKey is OPTIONAL — pass your own RIDB key for higher
33
+ * limits, or omit it to use the shared Pipeworx key (injected by the gateway).
34
+ */
35
+
36
+
37
+ const BASE_URL = 'https://ridb.recreation.gov/api/v1';
38
+
39
+ // RIDB description fields routinely contain raw HTML — strip tags before
40
+ // returning so agents get clean prose, not markup.
41
+ function stripHtml(s: string | undefined | null): string {
42
+ return (s || '').replace(/<[^>]+>/g, '');
43
+ }
44
+
45
+ const tools: McpToolExport['tools'] = [
46
+ {
47
+ name: 'search_facilities',
48
+ description:
49
+ 'Search US federal recreation facilities — campgrounds, day-use areas, visitor centers, trailheads — on Recreation.gov. Filter by name/keyword, state, activity (e.g. "camping", "hiking"), or geographic radius. Returns facility IDs, names, types, phone/email, and coordinates. Example: search_facilities({ query: "Yosemite", state: "CA", activity: "camping" })',
50
+ inputSchema: {
51
+ type: 'object' as const,
52
+ properties: {
53
+ query: { type: 'string', description: 'Keyword or name to search, e.g. "Yosemite", "Pinnacles"' },
54
+ state: { type: 'string', description: 'Two-letter US state code, e.g. "CA", "CO"' },
55
+ activity: { type: 'string', description: 'Activity name to filter by, e.g. "camping", "hiking", "fishing"' },
56
+ limit: { type: 'number', description: 'Max results to return (default 20, max 50)' },
57
+ offset: { type: 'number', description: 'Pagination offset (default 0)' },
58
+ latitude: { type: 'number', description: 'Latitude for geographic search (use with longitude + radius)' },
59
+ longitude: { type: 'number', description: 'Longitude for geographic search (use with latitude + radius)' },
60
+ radius: { type: 'number', description: 'Search radius in miles around latitude/longitude' },
61
+ _apiKey: {
62
+ type: 'string',
63
+ description:
64
+ 'Optional — your own Recreation.gov RIDB API key for higher limits; omit to use the shared Pipeworx key.',
65
+ },
66
+ },
67
+ required: [],
68
+ },
69
+ },
70
+ {
71
+ name: 'get_facility',
72
+ description:
73
+ 'Get full details for a single Recreation.gov facility (e.g. a campground) by its FacilityID. Returns description, directions, ADA access, phone/email, keywords, and coordinates. Example: get_facility({ facility_id: "232447" })',
74
+ inputSchema: {
75
+ type: 'object' as const,
76
+ properties: {
77
+ facility_id: { type: 'string', description: 'RIDB FacilityID, e.g. "232447"' },
78
+ _apiKey: {
79
+ type: 'string',
80
+ description:
81
+ 'Optional — your own Recreation.gov RIDB API key for higher limits; omit to use the shared Pipeworx key.',
82
+ },
83
+ },
84
+ required: ['facility_id'],
85
+ },
86
+ },
87
+ {
88
+ name: 'search_recareas',
89
+ description:
90
+ 'Search US federal recreation areas — the parent regions (national parks, national forests, BLM/USACE lands) that contain campgrounds and facilities — on Recreation.gov. Filter by name/keyword or state. Returns RecArea IDs, names, descriptions, phone, and coordinates. Example: search_recareas({ query: "Grand Canyon", state: "AZ" })',
91
+ inputSchema: {
92
+ type: 'object' as const,
93
+ properties: {
94
+ query: { type: 'string', description: 'Keyword or name to search, e.g. "Grand Canyon"' },
95
+ state: { type: 'string', description: 'Two-letter US state code, e.g. "AZ"' },
96
+ limit: { type: 'number', description: 'Max results to return (default 20, max 50)' },
97
+ offset: { type: 'number', description: 'Pagination offset (default 0)' },
98
+ _apiKey: {
99
+ type: 'string',
100
+ description:
101
+ 'Optional — your own Recreation.gov RIDB API key for higher limits; omit to use the shared Pipeworx key.',
102
+ },
103
+ },
104
+ required: [],
105
+ },
106
+ },
107
+ {
108
+ name: 'list_campsites',
109
+ description:
110
+ 'List the individual campsites within a Recreation.gov facility (campground) by FacilityID. Returns campsite IDs, names, type (e.g. "TENT ONLY", "RV"), loop, reservability, and type of use. Example: list_campsites({ facility_id: "232447" })',
111
+ inputSchema: {
112
+ type: 'object' as const,
113
+ properties: {
114
+ facility_id: { type: 'string', description: 'RIDB FacilityID of the campground, e.g. "232447"' },
115
+ limit: { type: 'number', description: 'Max campsites to return (default 20, max 50)' },
116
+ _apiKey: {
117
+ type: 'string',
118
+ description:
119
+ 'Optional — your own Recreation.gov RIDB API key for higher limits; omit to use the shared Pipeworx key.',
120
+ },
121
+ },
122
+ required: ['facility_id'],
123
+ },
124
+ },
125
+ ];
126
+
127
+ interface RidbMetadata {
128
+ RESULTS?: { CURRENT_COUNT?: number; TOTAL_COUNT?: number };
129
+ }
130
+
131
+ interface FacilityRecord {
132
+ FacilityID?: string | number;
133
+ FacilityName?: string;
134
+ FacilityTypeDescription?: string;
135
+ FacilityDescription?: string;
136
+ FacilityPhone?: string;
137
+ FacilityEmail?: string;
138
+ Reservable?: boolean;
139
+ FacilityLatitude?: number;
140
+ FacilityLongitude?: number;
141
+ FacilityDirections?: string;
142
+ Keywords?: string;
143
+ FacilityAdaAccess?: string;
144
+ }
145
+
146
+ async function ridbGet(
147
+ path: string,
148
+ params: URLSearchParams | undefined,
149
+ apiKey: string,
150
+ ): Promise<unknown> {
151
+ const qs = params?.toString();
152
+ const url = `${BASE_URL}${path}${qs ? `?${qs}` : ''}`;
153
+ const res = await fetch(url, { headers: { apikey: apiKey, Accept: 'application/json' } });
154
+ if (!res.ok) {
155
+ const text = await res.text();
156
+ return { error: res.status, message: text };
157
+ }
158
+ return res.json();
159
+ }
160
+
161
+ function clamp(n: unknown, def: number, max: number): number {
162
+ const v = typeof n === 'number' ? n : Number(n);
163
+ if (!Number.isFinite(v) || v <= 0) return def;
164
+ return Math.min(max, Math.floor(v));
165
+ }
166
+
167
+ function mapFacility(f: FacilityRecord) {
168
+ return {
169
+ id: f.FacilityID,
170
+ name: f.FacilityName,
171
+ type: f.FacilityTypeDescription,
172
+ description: stripHtml(f.FacilityDescription).slice(0, 300),
173
+ phone: f.FacilityPhone,
174
+ email: f.FacilityEmail,
175
+ reservable: f.Reservable,
176
+ lat: f.FacilityLatitude,
177
+ lon: f.FacilityLongitude,
178
+ };
179
+ }
180
+
181
+ async function callTool(name: string, args: Record<string, unknown>): Promise<unknown> {
182
+ const apiKey = args._apiKey as string;
183
+ delete args._apiKey;
184
+
185
+ if (!apiKey) {
186
+ return { error: 'api_key_required', message: 'No Recreation.gov key available.' };
187
+ }
188
+
189
+ switch (name) {
190
+ case 'search_facilities': {
191
+ const limit = clamp(args.limit, 20, 50);
192
+ const offset = Number.isFinite(Number(args.offset)) ? Math.max(0, Math.floor(Number(args.offset))) : 0;
193
+ const params = new URLSearchParams({ limit: String(limit), offset: String(offset) });
194
+ if (args.query) params.set('query', args.query as string);
195
+ if (args.state) params.set('state', args.state as string);
196
+ if (args.activity) params.set('activity', args.activity as string);
197
+ if (args.latitude !== undefined) params.set('latitude', String(args.latitude));
198
+ if (args.longitude !== undefined) params.set('longitude', String(args.longitude));
199
+ if (args.radius !== undefined) params.set('radius', String(args.radius));
200
+
201
+ const data = (await ridbGet('/facilities', params, apiKey)) as
202
+ | { RECDATA?: FacilityRecord[]; METADATA?: RidbMetadata }
203
+ | { error: unknown; message: unknown };
204
+ if ('error' in data) return data;
205
+
206
+ return {
207
+ total: data.METADATA?.RESULTS?.TOTAL_COUNT,
208
+ facilities: (data.RECDATA || []).map(mapFacility),
209
+ };
210
+ }
211
+
212
+ case 'get_facility': {
213
+ const id = args.facility_id as string;
214
+ const data = (await ridbGet(`/facilities/${encodeURIComponent(id)}`, undefined, apiKey)) as
215
+ | FacilityRecord
216
+ | { error: unknown; message: unknown };
217
+ if ('error' in data) return data;
218
+
219
+ const f = data as FacilityRecord;
220
+ return {
221
+ ...mapFacility(f),
222
+ directions: stripHtml(f.FacilityDirections).slice(0, 500),
223
+ keywords: f.Keywords,
224
+ ada_access: f.FacilityAdaAccess,
225
+ };
226
+ }
227
+
228
+ case 'search_recareas': {
229
+ const limit = clamp(args.limit, 20, 50);
230
+ const offset = Number.isFinite(Number(args.offset)) ? Math.max(0, Math.floor(Number(args.offset))) : 0;
231
+ const params = new URLSearchParams({ limit: String(limit), offset: String(offset) });
232
+ if (args.query) params.set('query', args.query as string);
233
+ if (args.state) params.set('state', args.state as string);
234
+
235
+ const data = (await ridbGet('/recareas', params, apiKey)) as
236
+ | {
237
+ RECDATA?: Array<{
238
+ RecAreaID?: string | number;
239
+ RecAreaName?: string;
240
+ RecAreaDescription?: string;
241
+ RecAreaPhone?: string;
242
+ RecAreaLatitude?: number;
243
+ RecAreaLongitude?: number;
244
+ }>;
245
+ METADATA?: RidbMetadata;
246
+ }
247
+ | { error: unknown; message: unknown };
248
+ if ('error' in data) return data;
249
+
250
+ return {
251
+ total: data.METADATA?.RESULTS?.TOTAL_COUNT,
252
+ recareas: (data.RECDATA || []).map((r) => ({
253
+ id: r.RecAreaID,
254
+ name: r.RecAreaName,
255
+ description: stripHtml(r.RecAreaDescription).slice(0, 300),
256
+ phone: r.RecAreaPhone,
257
+ lat: r.RecAreaLatitude,
258
+ lon: r.RecAreaLongitude,
259
+ })),
260
+ };
261
+ }
262
+
263
+ case 'list_campsites': {
264
+ const id = args.facility_id as string;
265
+ const limit = clamp(args.limit, 20, 50);
266
+ const params = new URLSearchParams({ limit: String(limit) });
267
+
268
+ const data = (await ridbGet(`/facilities/${encodeURIComponent(id)}/campsites`, params, apiKey)) as
269
+ | {
270
+ RECDATA?: Array<{
271
+ CampsiteID?: string | number;
272
+ CampsiteName?: string;
273
+ CampsiteType?: string;
274
+ Loop?: string;
275
+ CampsiteReservable?: boolean;
276
+ TypeOfUse?: string;
277
+ }>;
278
+ METADATA?: RidbMetadata;
279
+ }
280
+ | { error: unknown; message: unknown };
281
+ if ('error' in data) return data;
282
+
283
+ return {
284
+ total: data.METADATA?.RESULTS?.TOTAL_COUNT,
285
+ campsites: (data.RECDATA || []).map((c) => ({
286
+ id: c.CampsiteID,
287
+ name: c.CampsiteName,
288
+ type: c.CampsiteType,
289
+ loop: c.Loop,
290
+ reservable: c.CampsiteReservable,
291
+ type_of_use: c.TypeOfUse,
292
+ })),
293
+ };
294
+ }
295
+
296
+ default:
297
+ throw new Error(`Unknown tool: ${name}`);
298
+ }
299
+ }
300
+
301
+ 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
+ }