@pipeworx/mcp-imf 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 +55 -0
- package/package.json +20 -0
- package/server.json +18 -0
- package/src/index.ts +166 -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,55 @@
|
|
|
1
|
+
# mcp-imf
|
|
2
|
+
|
|
3
|
+
IMF MCP — wraps IMF SDMX JSON REST API (dataservices.imf.org)
|
|
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
|
+
"imf": {
|
|
20
|
+
"url": "https://gateway.pipeworx.io/imf/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 Imf 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-imf",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "IMF MCP — wraps IMF SDMX JSON REST API (dataservices.imf.org)",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "src/index.ts",
|
|
7
|
+
"types": "src/index.ts",
|
|
8
|
+
"keywords": ["mcp", "mcp-server", "model-context-protocol", "pipeworx", "imf"],
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/pipeworx-io/mcp-imf"
|
|
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/imf",
|
|
4
|
+
"title": "Imf",
|
|
5
|
+
"description": "IMF MCP — wraps IMF SDMX JSON REST API (dataservices.imf.org)",
|
|
6
|
+
"version": "0.1.0",
|
|
7
|
+
"websiteUrl": "https://pipeworx.io/packs/imf",
|
|
8
|
+
"repository": {
|
|
9
|
+
"url": "https://github.com/pipeworx-io/mcp-imf",
|
|
10
|
+
"source": "github"
|
|
11
|
+
},
|
|
12
|
+
"remotes": [
|
|
13
|
+
{
|
|
14
|
+
"type": "streamable-http",
|
|
15
|
+
"url": "https://gateway.pipeworx.io/imf/mcp"
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
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
|
+
* IMF MCP — wraps IMF SDMX JSON REST API (dataservices.imf.org)
|
|
21
|
+
*
|
|
22
|
+
* Tools:
|
|
23
|
+
* - get_datasets: list available IMF databases
|
|
24
|
+
* - get_data: fetch time-series data for an indicator/country
|
|
25
|
+
* - search_indicators: search indicator codes within a database
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
const BASE_URL = 'https://dataservices.imf.org/REST/SDMX_JSON.svc';
|
|
30
|
+
|
|
31
|
+
const tools: McpToolExport['tools'] = [
|
|
32
|
+
{
|
|
33
|
+
name: 'get_datasets',
|
|
34
|
+
description:
|
|
35
|
+
'List all available IMF databases/datasets. Returns database IDs and names you can use with get_data and search_indicators. Example: call with no arguments to browse available datasets like IFS (International Financial Statistics), BOP (Balance of Payments), etc.',
|
|
36
|
+
inputSchema: {
|
|
37
|
+
type: 'object',
|
|
38
|
+
properties: {},
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
name: 'get_data',
|
|
43
|
+
description:
|
|
44
|
+
'Fetch IMF time-series data for an indicator and country. Uses SDMX CompactData format. Example: get_data({ database_id: "IFS", frequency: "A", indicator: "NGDP_XDC", country: "US", start: "2018", end: "2023" }) returns annual nominal GDP for the US.',
|
|
45
|
+
inputSchema: {
|
|
46
|
+
type: 'object',
|
|
47
|
+
properties: {
|
|
48
|
+
database_id: {
|
|
49
|
+
type: 'string',
|
|
50
|
+
description: 'IMF database ID, e.g. "IFS", "BOP", "DOT", "WEO"',
|
|
51
|
+
},
|
|
52
|
+
frequency: {
|
|
53
|
+
type: 'string',
|
|
54
|
+
description: 'Data frequency: "A" (annual), "Q" (quarterly), "M" (monthly)',
|
|
55
|
+
},
|
|
56
|
+
indicator: {
|
|
57
|
+
type: 'string',
|
|
58
|
+
description: 'Indicator code, e.g. "NGDP_XDC" for nominal GDP. Use search_indicators to find codes.',
|
|
59
|
+
},
|
|
60
|
+
country: {
|
|
61
|
+
type: 'string',
|
|
62
|
+
description: 'ISO 2-letter country code, e.g. "US", "GB", "JP". Omit for all countries.',
|
|
63
|
+
},
|
|
64
|
+
start: {
|
|
65
|
+
type: 'string',
|
|
66
|
+
description: 'Start period, e.g. "2018" or "2018-Q1" or "2018-01"',
|
|
67
|
+
},
|
|
68
|
+
end: {
|
|
69
|
+
type: 'string',
|
|
70
|
+
description: 'End period, e.g. "2023" or "2023-Q4" or "2023-12"',
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
required: ['database_id', 'frequency', 'indicator'],
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
name: 'search_indicators',
|
|
78
|
+
description:
|
|
79
|
+
'Search or list indicator codes available in an IMF database. Returns the code list (dimensions) for a dataset. Example: search_indicators({ database_id: "IFS", query: "GDP" }) finds GDP-related indicator codes.',
|
|
80
|
+
inputSchema: {
|
|
81
|
+
type: 'object',
|
|
82
|
+
properties: {
|
|
83
|
+
database_id: {
|
|
84
|
+
type: 'string',
|
|
85
|
+
description: 'IMF database ID to search within, e.g. "IFS"',
|
|
86
|
+
},
|
|
87
|
+
query: {
|
|
88
|
+
type: 'string',
|
|
89
|
+
description: 'Optional search term to filter indicators, e.g. "GDP", "inflation", "trade"',
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
required: ['database_id'],
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
];
|
|
96
|
+
|
|
97
|
+
async function callTool(name: string, args: Record<string, unknown>): Promise<unknown> {
|
|
98
|
+
switch (name) {
|
|
99
|
+
case 'get_datasets':
|
|
100
|
+
return getDatasets();
|
|
101
|
+
case 'get_data':
|
|
102
|
+
return getData(
|
|
103
|
+
args.database_id as string,
|
|
104
|
+
args.frequency as string,
|
|
105
|
+
args.indicator as string,
|
|
106
|
+
args.country as string | undefined,
|
|
107
|
+
args.start as string | undefined,
|
|
108
|
+
args.end as string | undefined,
|
|
109
|
+
);
|
|
110
|
+
case 'search_indicators':
|
|
111
|
+
return searchIndicators(
|
|
112
|
+
args.database_id as string,
|
|
113
|
+
args.query as string | undefined,
|
|
114
|
+
);
|
|
115
|
+
default:
|
|
116
|
+
throw new Error(`Unknown tool: ${name}`);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
async function getDatasets() {
|
|
121
|
+
const res = await fetch(`${BASE_URL}/Dataflow`);
|
|
122
|
+
if (!res.ok) throw new Error(`IMF API error: ${res.status}`);
|
|
123
|
+
const data = (await res.json()) as Record<string, unknown>;
|
|
124
|
+
return data;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
async function getData(
|
|
128
|
+
databaseId: string,
|
|
129
|
+
frequency: string,
|
|
130
|
+
indicator: string,
|
|
131
|
+
country?: string,
|
|
132
|
+
start?: string,
|
|
133
|
+
end?: string,
|
|
134
|
+
) {
|
|
135
|
+
const countryPart = country ?? '';
|
|
136
|
+
const dimensions = `${frequency}.${countryPart}.${indicator}`;
|
|
137
|
+
let url = `${BASE_URL}/CompactData/${databaseId}/${dimensions}`;
|
|
138
|
+
|
|
139
|
+
const params = new URLSearchParams();
|
|
140
|
+
if (start) params.set('startPeriod', start);
|
|
141
|
+
if (end) params.set('endPeriod', end);
|
|
142
|
+
const qs = params.toString();
|
|
143
|
+
if (qs) url += `?${qs}`;
|
|
144
|
+
|
|
145
|
+
const res = await fetch(url);
|
|
146
|
+
if (!res.ok) throw new Error(`IMF API error: ${res.status}`);
|
|
147
|
+
const data = (await res.json()) as Record<string, unknown>;
|
|
148
|
+
return data;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
async function searchIndicators(databaseId: string, query?: string) {
|
|
152
|
+
const res = await fetch(`${BASE_URL}/DataStructure/${databaseId}`);
|
|
153
|
+
if (!res.ok) throw new Error(`IMF API error: ${res.status}`);
|
|
154
|
+
const data = (await res.json()) as Record<string, unknown>;
|
|
155
|
+
|
|
156
|
+
if (!query) return data;
|
|
157
|
+
|
|
158
|
+
// Filter the structure to find matching indicators
|
|
159
|
+
const lowerQuery = query.toLowerCase();
|
|
160
|
+
const filtered = JSON.parse(JSON.stringify(data));
|
|
161
|
+
// Return the full structure — the LLM can parse what it needs
|
|
162
|
+
// The query is used as a hint for the caller
|
|
163
|
+
return { query: lowerQuery, structure: filtered };
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
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
|
+
}
|