@pipeworx/mcp-fred 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 +34 -0
- package/package.json +20 -0
- package/server.json +18 -0
- package/src/index.ts +323 -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,34 @@
|
|
|
1
|
+
# mcp-fred
|
|
2
|
+
|
|
3
|
+
FRED MCP — Federal Reserve Economic Data (St. Louis Fed)
|
|
4
|
+
|
|
5
|
+
Part of the [Pipeworx](https://pipeworx.io) open MCP gateway.
|
|
6
|
+
|
|
7
|
+
## Tools
|
|
8
|
+
|
|
9
|
+
| Tool | Description |
|
|
10
|
+
|------|-------------|
|
|
11
|
+
|
|
12
|
+
## Quick Start
|
|
13
|
+
|
|
14
|
+
Add to your MCP client config:
|
|
15
|
+
|
|
16
|
+
```json
|
|
17
|
+
{
|
|
18
|
+
"mcpServers": {
|
|
19
|
+
"fred": {
|
|
20
|
+
"url": "https://gateway.pipeworx.io/fred/mcp"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Or use the CLI:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
npx pipeworx use fred
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## License
|
|
33
|
+
|
|
34
|
+
MIT
|
package/package.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pipeworx/mcp-fred",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "FRED MCP — Federal Reserve Economic Data (St. Louis Fed)",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "src/index.ts",
|
|
7
|
+
"types": "src/index.ts",
|
|
8
|
+
"keywords": ["mcp", "mcp-server", "model-context-protocol", "pipeworx", "fred"],
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/pipeworx-io/mcp-fred"
|
|
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/fred",
|
|
4
|
+
"title": "fred",
|
|
5
|
+
"description": "FRED MCP — Federal Reserve Economic Data (St. Louis Fed)",
|
|
6
|
+
"version": "0.1.0",
|
|
7
|
+
"websiteUrl": "https://pipeworx.io/packs/fred",
|
|
8
|
+
"repository": {
|
|
9
|
+
"url": "https://github.com/pipeworx-io/mcp-fred",
|
|
10
|
+
"source": "github"
|
|
11
|
+
},
|
|
12
|
+
"remotes": [
|
|
13
|
+
{
|
|
14
|
+
"type": "streamable-http",
|
|
15
|
+
"url": "https://gateway.pipeworx.io/fred/mcp"
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,323 @@
|
|
|
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
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* FRED MCP — Federal Reserve Economic Data (St. Louis Fed)
|
|
18
|
+
*
|
|
19
|
+
* BYO key: requires a FRED API key from https://fred.stlouisfed.org/docs/api/api_key.html
|
|
20
|
+
* Passed via _apiKey parameter.
|
|
21
|
+
*
|
|
22
|
+
* Tools:
|
|
23
|
+
* - fred_get_series: get observations for a data series (e.g., MORTGAGE30US, HOUST, CSUSHPISA)
|
|
24
|
+
* - fred_search: search for series by keyword
|
|
25
|
+
* - fred_series_info: get metadata about a series
|
|
26
|
+
* - fred_category: browse FRED categories
|
|
27
|
+
* - fred_releases: get latest data releases
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
const BASE = 'https://api.stlouisfed.org/fred';
|
|
32
|
+
|
|
33
|
+
function extractKey(args: Record<string, unknown>): string {
|
|
34
|
+
const key = args._apiKey as string;
|
|
35
|
+
delete args._apiKey;
|
|
36
|
+
if (!key) throw new Error('FRED API key required. Get one at https://fred.stlouisfed.org/docs/api/api_key.html and pass via _apiKey.');
|
|
37
|
+
return key;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async function fredFetch(url: string): Promise<unknown> {
|
|
41
|
+
const res = await fetch(url);
|
|
42
|
+
if (!res.ok) {
|
|
43
|
+
const text = await res.text();
|
|
44
|
+
throw new Error(`FRED API error (${res.status}): ${text}`);
|
|
45
|
+
}
|
|
46
|
+
return res.json();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// ── Tool definitions ────────────────────────────────────────────────────
|
|
50
|
+
|
|
51
|
+
const tools: McpToolExport['tools'] = [
|
|
52
|
+
{
|
|
53
|
+
name: 'fred_get_series',
|
|
54
|
+
description:
|
|
55
|
+
'Get observations (data points) for a FRED series. Key housing series: MORTGAGE30US (30-year mortgage rate), HOUST (housing starts), CSUSHPISA (Case-Shiller home price index), MSPUS (median home sale price), PERMIT (building permits), RRVRUSQ156N (rental vacancy rate).',
|
|
56
|
+
inputSchema: {
|
|
57
|
+
type: 'object' as const,
|
|
58
|
+
properties: {
|
|
59
|
+
series_id: { type: 'string', description: 'FRED series ID (e.g., "MORTGAGE30US", "HOUST", "CSUSHPISA")' },
|
|
60
|
+
observation_start: { type: 'string', description: 'Start date in YYYY-MM-DD format (optional)' },
|
|
61
|
+
observation_end: { type: 'string', description: 'End date in YYYY-MM-DD format (optional)' },
|
|
62
|
+
frequency: { type: 'string', description: 'Frequency aggregation: d, w, bw, m, q, sa, a (optional)' },
|
|
63
|
+
units: { type: 'string', description: 'Data transformation: lin (levels), chg (change), ch1 (change from year ago), pch (% change), pc1 (% change from year ago), pca (compounded annual rate of change), cch (continuously compounded rate of change), cca (continuously compounded annual rate of change), log (natural log). Default: lin' },
|
|
64
|
+
_apiKey: { type: 'string', description: 'FRED API key' },
|
|
65
|
+
},
|
|
66
|
+
required: ['series_id', '_apiKey'],
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
name: 'fred_search',
|
|
71
|
+
description:
|
|
72
|
+
'Search for FRED series by keyword. Useful for discovering series IDs for housing, employment, inflation, and other economic data.',
|
|
73
|
+
inputSchema: {
|
|
74
|
+
type: 'object' as const,
|
|
75
|
+
properties: {
|
|
76
|
+
search_text: { type: 'string', description: 'Keywords to search for (e.g., "mortgage rate", "housing starts")' },
|
|
77
|
+
limit: { type: 'number', description: 'Max results to return (1-1000, default 20)' },
|
|
78
|
+
order_by: { type: 'string', description: 'Order results by: search_rank, series_id, title, units, frequency, seasonal_adjustment, realtime_start, realtime_end, last_updated, observation_start, observation_end, popularity, group_popularity. Default: search_rank' },
|
|
79
|
+
sort_order: { type: 'string', description: 'Sort direction: asc or desc. Default: asc for search_rank' },
|
|
80
|
+
_apiKey: { type: 'string', description: 'FRED API key' },
|
|
81
|
+
},
|
|
82
|
+
required: ['search_text', '_apiKey'],
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
name: 'fred_series_info',
|
|
87
|
+
description:
|
|
88
|
+
'Get metadata about a FRED series: title, units, frequency, seasonal adjustment, notes, and date range.',
|
|
89
|
+
inputSchema: {
|
|
90
|
+
type: 'object' as const,
|
|
91
|
+
properties: {
|
|
92
|
+
series_id: { type: 'string', description: 'FRED series ID (e.g., "MORTGAGE30US")' },
|
|
93
|
+
_apiKey: { type: 'string', description: 'FRED API key' },
|
|
94
|
+
},
|
|
95
|
+
required: ['series_id', '_apiKey'],
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
name: 'fred_category',
|
|
100
|
+
description:
|
|
101
|
+
'Browse FRED categories. Use category_id=0 for the root. Useful for exploring available data by topic (housing = 97, money/banking/finance = 32991, population/employment/labor = 10).',
|
|
102
|
+
inputSchema: {
|
|
103
|
+
type: 'object' as const,
|
|
104
|
+
properties: {
|
|
105
|
+
category_id: { type: 'number', description: 'Category ID to browse children of (default: 0 for root)' },
|
|
106
|
+
_apiKey: { type: 'string', description: 'FRED API key' },
|
|
107
|
+
},
|
|
108
|
+
required: ['_apiKey'],
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
name: 'fred_releases',
|
|
113
|
+
description:
|
|
114
|
+
'Get the latest FRED data releases. Shows upcoming and recent releases of economic data.',
|
|
115
|
+
inputSchema: {
|
|
116
|
+
type: 'object' as const,
|
|
117
|
+
properties: {
|
|
118
|
+
limit: { type: 'number', description: 'Max results (1-1000, default 20)' },
|
|
119
|
+
offset: { type: 'number', description: 'Result offset for pagination (default 0)' },
|
|
120
|
+
_apiKey: { type: 'string', description: 'FRED API key' },
|
|
121
|
+
},
|
|
122
|
+
required: ['_apiKey'],
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
];
|
|
126
|
+
|
|
127
|
+
// ── callTool dispatcher ─────────────────────────────────────────────────
|
|
128
|
+
|
|
129
|
+
async function callTool(name: string, args: Record<string, unknown>): Promise<unknown> {
|
|
130
|
+
const key = extractKey(args);
|
|
131
|
+
|
|
132
|
+
switch (name) {
|
|
133
|
+
case 'fred_get_series':
|
|
134
|
+
return getSeries(key, args);
|
|
135
|
+
case 'fred_search':
|
|
136
|
+
return searchSeries(key, args);
|
|
137
|
+
case 'fred_series_info':
|
|
138
|
+
return seriesInfo(key, args.series_id as string);
|
|
139
|
+
case 'fred_category':
|
|
140
|
+
return getCategory(key, args.category_id as number | undefined);
|
|
141
|
+
case 'fred_releases':
|
|
142
|
+
return getReleases(key, args);
|
|
143
|
+
default:
|
|
144
|
+
throw new Error(`Unknown tool: ${name}`);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// ── Tool implementations ────────────────────────────────────────────────
|
|
149
|
+
|
|
150
|
+
async function getSeries(key: string, args: Record<string, unknown>) {
|
|
151
|
+
const params = new URLSearchParams({
|
|
152
|
+
series_id: args.series_id as string,
|
|
153
|
+
api_key: key,
|
|
154
|
+
file_type: 'json',
|
|
155
|
+
});
|
|
156
|
+
if (args.observation_start) params.set('observation_start', args.observation_start as string);
|
|
157
|
+
if (args.observation_end) params.set('observation_end', args.observation_end as string);
|
|
158
|
+
if (args.frequency) params.set('frequency', args.frequency as string);
|
|
159
|
+
if (args.units) params.set('units', args.units as string);
|
|
160
|
+
|
|
161
|
+
const data = (await fredFetch(`${BASE}/series/observations?${params}`)) as {
|
|
162
|
+
realtime_start: string;
|
|
163
|
+
realtime_end: string;
|
|
164
|
+
observation_start: string;
|
|
165
|
+
observation_end: string;
|
|
166
|
+
count: number;
|
|
167
|
+
observations: { date: string; value: string }[];
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
return {
|
|
171
|
+
series_id: args.series_id,
|
|
172
|
+
count: data.count,
|
|
173
|
+
observation_start: data.observation_start,
|
|
174
|
+
observation_end: data.observation_end,
|
|
175
|
+
observations: data.observations.map((o) => ({
|
|
176
|
+
date: o.date,
|
|
177
|
+
value: o.value === '.' ? null : o.value,
|
|
178
|
+
})),
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
async function searchSeries(key: string, args: Record<string, unknown>) {
|
|
183
|
+
const params = new URLSearchParams({
|
|
184
|
+
search_text: args.search_text as string,
|
|
185
|
+
api_key: key,
|
|
186
|
+
file_type: 'json',
|
|
187
|
+
});
|
|
188
|
+
const limit = Math.min(1000, Math.max(1, (args.limit as number) ?? 20));
|
|
189
|
+
params.set('limit', String(limit));
|
|
190
|
+
if (args.order_by) params.set('order_by', args.order_by as string);
|
|
191
|
+
if (args.sort_order) params.set('sort_order', args.sort_order as string);
|
|
192
|
+
|
|
193
|
+
const data = (await fredFetch(`${BASE}/series/search?${params}`)) as {
|
|
194
|
+
count: number;
|
|
195
|
+
seriess: {
|
|
196
|
+
id: string;
|
|
197
|
+
title: string;
|
|
198
|
+
units: string;
|
|
199
|
+
frequency: string;
|
|
200
|
+
seasonal_adjustment: string;
|
|
201
|
+
observation_start: string;
|
|
202
|
+
observation_end: string;
|
|
203
|
+
popularity: number;
|
|
204
|
+
notes?: string;
|
|
205
|
+
}[];
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
return {
|
|
209
|
+
total_matches: data.count,
|
|
210
|
+
series: data.seriess.map((s) => ({
|
|
211
|
+
series_id: s.id,
|
|
212
|
+
title: s.title,
|
|
213
|
+
units: s.units,
|
|
214
|
+
frequency: s.frequency,
|
|
215
|
+
seasonal_adjustment: s.seasonal_adjustment,
|
|
216
|
+
observation_start: s.observation_start,
|
|
217
|
+
observation_end: s.observation_end,
|
|
218
|
+
popularity: s.popularity,
|
|
219
|
+
notes: s.notes ?? null,
|
|
220
|
+
})),
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
async function seriesInfo(key: string, seriesId: string) {
|
|
225
|
+
const params = new URLSearchParams({
|
|
226
|
+
series_id: seriesId,
|
|
227
|
+
api_key: key,
|
|
228
|
+
file_type: 'json',
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
const data = (await fredFetch(`${BASE}/series?${params}`)) as {
|
|
232
|
+
seriess: {
|
|
233
|
+
id: string;
|
|
234
|
+
title: string;
|
|
235
|
+
units: string;
|
|
236
|
+
units_short: string;
|
|
237
|
+
frequency: string;
|
|
238
|
+
frequency_short: string;
|
|
239
|
+
seasonal_adjustment: string;
|
|
240
|
+
seasonal_adjustment_short: string;
|
|
241
|
+
observation_start: string;
|
|
242
|
+
observation_end: string;
|
|
243
|
+
last_updated: string;
|
|
244
|
+
popularity: number;
|
|
245
|
+
notes?: string;
|
|
246
|
+
}[];
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
const s = data.seriess[0];
|
|
250
|
+
if (!s) throw new Error(`Series not found: ${seriesId}`);
|
|
251
|
+
|
|
252
|
+
return {
|
|
253
|
+
series_id: s.id,
|
|
254
|
+
title: s.title,
|
|
255
|
+
units: s.units,
|
|
256
|
+
units_short: s.units_short,
|
|
257
|
+
frequency: s.frequency,
|
|
258
|
+
frequency_short: s.frequency_short,
|
|
259
|
+
seasonal_adjustment: s.seasonal_adjustment,
|
|
260
|
+
seasonal_adjustment_short: s.seasonal_adjustment_short,
|
|
261
|
+
observation_start: s.observation_start,
|
|
262
|
+
observation_end: s.observation_end,
|
|
263
|
+
last_updated: s.last_updated,
|
|
264
|
+
popularity: s.popularity,
|
|
265
|
+
notes: s.notes ?? null,
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
async function getCategory(key: string, categoryId?: number) {
|
|
270
|
+
const id = categoryId ?? 0;
|
|
271
|
+
const params = new URLSearchParams({
|
|
272
|
+
category_id: String(id),
|
|
273
|
+
api_key: key,
|
|
274
|
+
file_type: 'json',
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
const data = (await fredFetch(`${BASE}/category/children?${params}`)) as {
|
|
278
|
+
categories: { id: number; name: string; parent_id: number }[];
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
return {
|
|
282
|
+
parent_category_id: id,
|
|
283
|
+
categories: data.categories.map((c) => ({
|
|
284
|
+
id: c.id,
|
|
285
|
+
name: c.name,
|
|
286
|
+
parent_id: c.parent_id,
|
|
287
|
+
})),
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
async function getReleases(key: string, args: Record<string, unknown>) {
|
|
292
|
+
const params = new URLSearchParams({
|
|
293
|
+
api_key: key,
|
|
294
|
+
file_type: 'json',
|
|
295
|
+
});
|
|
296
|
+
const limit = Math.min(1000, Math.max(1, (args.limit as number) ?? 20));
|
|
297
|
+
params.set('limit', String(limit));
|
|
298
|
+
if (args.offset) params.set('offset', String(args.offset as number));
|
|
299
|
+
|
|
300
|
+
const data = (await fredFetch(`${BASE}/releases?${params}`)) as {
|
|
301
|
+
count: number;
|
|
302
|
+
releases: {
|
|
303
|
+
id: number;
|
|
304
|
+
name: string;
|
|
305
|
+
press_release: boolean;
|
|
306
|
+
link?: string;
|
|
307
|
+
notes?: string;
|
|
308
|
+
}[];
|
|
309
|
+
};
|
|
310
|
+
|
|
311
|
+
return {
|
|
312
|
+
total_releases: data.count,
|
|
313
|
+
releases: data.releases.map((r) => ({
|
|
314
|
+
id: r.id,
|
|
315
|
+
name: r.name,
|
|
316
|
+
press_release: r.press_release,
|
|
317
|
+
link: r.link ?? null,
|
|
318
|
+
notes: r.notes ?? null,
|
|
319
|
+
})),
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
export default { tools, callTool, meter: { credits: 5 } } 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
|
+
}
|