@pipeworx/mcp-ine-pt 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 +150 -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-ine-pt
|
|
2
|
+
|
|
3
|
+
Statistics Portugal (INE) JSON indicator MCP.
|
|
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
|
+
"ine-pt": {
|
|
20
|
+
"url": "https://gateway.pipeworx.io/ine-pt/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 Ine Pt 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-ine-pt",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Statistics Portugal (INE) JSON indicator MCP.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "src/index.ts",
|
|
7
|
+
"types": "src/index.ts",
|
|
8
|
+
"keywords": ["mcp", "mcp-server", "model-context-protocol", "pipeworx", "ine-pt"],
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/pipeworx-io/mcp-ine-pt"
|
|
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/ine-pt",
|
|
4
|
+
"title": "Ine Pt",
|
|
5
|
+
"description": "Statistics Portugal (INE) JSON indicator MCP.",
|
|
6
|
+
"version": "0.1.0",
|
|
7
|
+
"websiteUrl": "https://pipeworx.io/packs/ine-pt",
|
|
8
|
+
"repository": {
|
|
9
|
+
"url": "https://github.com/pipeworx-io/mcp-ine-pt",
|
|
10
|
+
"source": "github"
|
|
11
|
+
},
|
|
12
|
+
"remotes": [
|
|
13
|
+
{
|
|
14
|
+
"type": "streamable-http",
|
|
15
|
+
"url": "https://gateway.pipeworx.io/ine-pt/mcp"
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
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
|
+
* Statistics Portugal (INE) JSON indicator MCP.
|
|
21
|
+
*
|
|
22
|
+
* Wraps the keyless INE indicator API at https://www.ine.pt/ine/json_indicador.
|
|
23
|
+
*
|
|
24
|
+
* IMPORTANT: INE has NO public indicator-search API. There is no endpoint to
|
|
25
|
+
* look up an indicator by keyword. Callers MUST already know the indicator code
|
|
26
|
+
* (varcd) from INE's website/catalog at https://www.ine.pt (e.g. via the
|
|
27
|
+
* BDDXplorer database browser). Both tools require a varcd.
|
|
28
|
+
*
|
|
29
|
+
* Workflow: call `indicator_meta` first to discover an indicator's dimensions
|
|
30
|
+
* and their valid dimension-value codes, then call `get_indicator` passing those
|
|
31
|
+
* codes as a `dims` map (Dim1/Dim2/...) to select the slice you want.
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
const BASE = 'https://www.ine.pt/ine/json_indicador';
|
|
36
|
+
const UA = 'pipeworx-mcp-ine-pt/1.0 (+https://pipeworx.io)';
|
|
37
|
+
|
|
38
|
+
const VARCD_NOTE =
|
|
39
|
+
'INE indicator code (varcd), e.g. "0008273". INE has no keyword search API — find the varcd on https://www.ine.pt (BDDXplorer database browser) first.';
|
|
40
|
+
|
|
41
|
+
const tools: McpToolExport['tools'] = [
|
|
42
|
+
{
|
|
43
|
+
name: 'indicator_meta',
|
|
44
|
+
description:
|
|
45
|
+
'Metadata for an INE (Statistics Portugal) indicator: title, periodicity, unit, time range, and the full list of dimensions with their valid dimension-value codes. Call this BEFORE get_indicator so you know which Dim1/Dim2/... codes are valid. Requires the indicator code (varcd) — INE has no keyword/search endpoint, so look the code up on https://www.ine.pt first.',
|
|
46
|
+
inputSchema: {
|
|
47
|
+
type: 'object',
|
|
48
|
+
properties: {
|
|
49
|
+
varcd: { type: 'string', description: VARCD_NOTE },
|
|
50
|
+
lang: { type: 'string', enum: ['EN', 'PT'], description: 'Response language. Default EN.' },
|
|
51
|
+
},
|
|
52
|
+
required: ['varcd'],
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
name: 'get_indicator',
|
|
57
|
+
description:
|
|
58
|
+
'Fetch data values for an INE (Statistics Portugal) indicator. Pass the indicator code (varcd) and optionally a `dims` object mapping dimension slots ("Dim1","Dim2",...) to dimension-value codes to select a slice (codes come from indicator_meta). Omit a Dim slot to return all of its values. Requires varcd — INE has no keyword/search endpoint, so look the code up on https://www.ine.pt first.',
|
|
59
|
+
inputSchema: {
|
|
60
|
+
type: 'object',
|
|
61
|
+
properties: {
|
|
62
|
+
varcd: { type: 'string', description: VARCD_NOTE },
|
|
63
|
+
dims: {
|
|
64
|
+
type: 'object',
|
|
65
|
+
description:
|
|
66
|
+
'Dimension selections, e.g. {"Dim1":"S7A2021","Dim3":"1"}. Keys are Dim1..DimN (matching the dim_num from indicator_meta); values are dimension-value codes. May also be passed as an array, treated as [Dim1, Dim2, ...].',
|
|
67
|
+
},
|
|
68
|
+
lang: { type: 'string', enum: ['EN', 'PT'], description: 'Response language. Default EN.' },
|
|
69
|
+
},
|
|
70
|
+
required: ['varcd'],
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
];
|
|
74
|
+
|
|
75
|
+
async function callTool(name: string, args: Record<string, unknown>): Promise<unknown> {
|
|
76
|
+
switch (name) {
|
|
77
|
+
case 'indicator_meta': {
|
|
78
|
+
const varcd = reqVarcd(args);
|
|
79
|
+
const params = new URLSearchParams({ varcd, lang: lang(args) });
|
|
80
|
+
return ineGet(`/pindicaMeta.jsp?${params.toString()}`);
|
|
81
|
+
}
|
|
82
|
+
case 'get_indicator': {
|
|
83
|
+
const varcd = reqVarcd(args);
|
|
84
|
+
const params = new URLSearchParams({ op: '2', varcd, lang: lang(args) });
|
|
85
|
+
for (const [slot, value] of dimEntries(args.dims)) params.set(slot, value);
|
|
86
|
+
return ineGet(`/pindica.jsp?${params.toString()}`);
|
|
87
|
+
}
|
|
88
|
+
default:
|
|
89
|
+
throw new Error(`Unknown tool: ${name}`);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
async function ineGet(path: string): Promise<unknown> {
|
|
94
|
+
const res = await fetch(`${BASE}${path}`, { headers: { Accept: 'application/json', 'User-Agent': UA } });
|
|
95
|
+
if (!res.ok) throw new Error(`INE Portugal: ${res.status} ${await res.text().then((t) => t.slice(0, 200))}`);
|
|
96
|
+
const data = (await res.json()) as unknown;
|
|
97
|
+
// INE returns HTTP 200 with a {Sucesso:{Falso:[{Msg,...}]}} envelope for
|
|
98
|
+
// unknown/invalid indicator codes — surface that as an error.
|
|
99
|
+
const fail = findFailure(data);
|
|
100
|
+
if (fail) throw new Error(`INE Portugal: ${fail.slice(0, 200)}`);
|
|
101
|
+
return data;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function findFailure(data: unknown): string | null {
|
|
105
|
+
const first = Array.isArray(data) ? data[0] : data;
|
|
106
|
+
if (!first || typeof first !== 'object') return null;
|
|
107
|
+
const sucesso = (first as Record<string, unknown>).Sucesso;
|
|
108
|
+
if (!sucesso || typeof sucesso !== 'object') return null;
|
|
109
|
+
const falso = (sucesso as Record<string, unknown>).Falso;
|
|
110
|
+
const entry = Array.isArray(falso) ? falso[0] : undefined;
|
|
111
|
+
if (entry && typeof entry === 'object') {
|
|
112
|
+
const msg = (entry as Record<string, unknown>).Msg;
|
|
113
|
+
if (typeof msg === 'string') return msg;
|
|
114
|
+
return 'indicator request failed';
|
|
115
|
+
}
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** Normalize a `dims` arg into [["Dim1","value"], ...] entries. */
|
|
120
|
+
function dimEntries(dims: unknown): Array<[string, string]> {
|
|
121
|
+
if (dims == null) return [];
|
|
122
|
+
if (Array.isArray(dims)) {
|
|
123
|
+
return dims
|
|
124
|
+
.map((v, i) => [`Dim${i + 1}`, String(v)] as [string, string])
|
|
125
|
+
.filter(([, v]) => v.trim() !== '');
|
|
126
|
+
}
|
|
127
|
+
if (typeof dims === 'object') {
|
|
128
|
+
return Object.entries(dims as Record<string, unknown>)
|
|
129
|
+
.filter(([k]) => /^Dim\d+$/.test(k))
|
|
130
|
+
.map(([k, v]) => [k, String(v)] as [string, string])
|
|
131
|
+
.filter(([, v]) => v.trim() !== '');
|
|
132
|
+
}
|
|
133
|
+
throw new Error('"dims" must be an object like {"Dim1":"S7A2021"} or an array [Dim1, Dim2, ...].');
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function reqVarcd(args: Record<string, unknown>): string {
|
|
137
|
+
const v = args.varcd;
|
|
138
|
+
if (typeof v !== 'string' || !v.trim())
|
|
139
|
+
throw new Error(
|
|
140
|
+
'Required argument "varcd" is missing. INE has no keyword/search API — find the indicator code on https://www.ine.pt (BDDXplorer) and pass it, e.g. varcd="0008273".'
|
|
141
|
+
);
|
|
142
|
+
return v.trim();
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function lang(args: Record<string, unknown>): string {
|
|
146
|
+
const l = typeof args.lang === 'string' ? args.lang.toUpperCase() : '';
|
|
147
|
+
return l === 'PT' ? 'PT' : 'EN';
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
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
|
+
}
|