@pipeworx/mcp-stat-lv 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 +57 -0
- package/package.json +20 -0
- package/server.json +18 -0
- package/src/index.ts +104 -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,57 @@
|
|
|
1
|
+
# mcp-stat-lv
|
|
2
|
+
|
|
3
|
+
Statistics Latvia / Official Statistics Portal (data.stat.gov.lv) PxWeb 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
|
+
| `table_meta` | Table definition (dimensions, valid values). Use the bare table path with no ".px" suffix. |
|
|
12
|
+
| `query_table` | Pull data from a table. body is a PxWeb query object. Use the bare table path with no ".px" suffix. |
|
|
13
|
+
|
|
14
|
+
## Quick Start
|
|
15
|
+
|
|
16
|
+
Add to your MCP client (Claude Desktop, Cursor, Windsurf, etc.):
|
|
17
|
+
|
|
18
|
+
```json
|
|
19
|
+
{
|
|
20
|
+
"mcpServers": {
|
|
21
|
+
"stat-lv": {
|
|
22
|
+
"url": "https://gateway.pipeworx.io/stat-lv/mcp"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Or connect to the full Pipeworx gateway for access to all 965+ data sources:
|
|
29
|
+
|
|
30
|
+
```json
|
|
31
|
+
{
|
|
32
|
+
"mcpServers": {
|
|
33
|
+
"pipeworx": {
|
|
34
|
+
"url": "https://gateway.pipeworx.io/mcp"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Using with ask_pipeworx
|
|
41
|
+
|
|
42
|
+
Instead of calling tools directly, you can ask questions in plain English:
|
|
43
|
+
|
|
44
|
+
```
|
|
45
|
+
ask_pipeworx({ question: "your question about Stat Lv data" })
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
The gateway picks the right tool and fills the arguments automatically.
|
|
49
|
+
|
|
50
|
+
## More
|
|
51
|
+
|
|
52
|
+
- [All tools and guides](https://github.com/pipeworx-io/examples)
|
|
53
|
+
- [pipeworx.io](https://pipeworx.io)
|
|
54
|
+
|
|
55
|
+
## License
|
|
56
|
+
|
|
57
|
+
MIT
|
package/package.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pipeworx/mcp-stat-lv",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Statistics Latvia / Official Statistics Portal (data.stat.gov.lv) PxWeb MCP.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "src/index.ts",
|
|
7
|
+
"types": "src/index.ts",
|
|
8
|
+
"keywords": ["mcp", "mcp-server", "model-context-protocol", "pipeworx", "stat-lv"],
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/pipeworx-io/mcp-stat-lv"
|
|
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/stat-lv",
|
|
4
|
+
"title": "Stat Lv",
|
|
5
|
+
"description": "Statistics Latvia / Official Statistics Portal (data.stat.gov.lv) PxWeb MCP.",
|
|
6
|
+
"version": "0.1.0",
|
|
7
|
+
"websiteUrl": "https://pipeworx.io/packs/stat-lv",
|
|
8
|
+
"repository": {
|
|
9
|
+
"url": "https://github.com/pipeworx-io/mcp-stat-lv",
|
|
10
|
+
"source": "github"
|
|
11
|
+
},
|
|
12
|
+
"remotes": [
|
|
13
|
+
{
|
|
14
|
+
"type": "streamable-http",
|
|
15
|
+
"url": "https://gateway.pipeworx.io/stat-lv/mcp"
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
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 Latvia / Official Statistics Portal (data.stat.gov.lv) PxWeb MCP.
|
|
21
|
+
*
|
|
22
|
+
* Keyless PxWeb API. The tree starts with database folders (e.g. OSP_PUB),
|
|
23
|
+
* then drills through subject folders (type "l") down to tables (type "t").
|
|
24
|
+
*
|
|
25
|
+
* Note: unlike most PxWeb deployments, this instance addresses tables by their
|
|
26
|
+
* bare id (e.g. "OSP_PUB/POP/IR/IRS/IRS010"). Do NOT append a ".px" suffix —
|
|
27
|
+
* appending ".px" returns 400 Bad Request here.
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
const BASE = 'https://data.stat.gov.lv/api/v1/en';
|
|
32
|
+
const UA = 'pipeworx-mcp-stat-lv/1.0 (+https://pipeworx.io)';
|
|
33
|
+
|
|
34
|
+
const tools: McpToolExport['tools'] = [
|
|
35
|
+
{
|
|
36
|
+
name: 'subjects',
|
|
37
|
+
description:
|
|
38
|
+
'Navigate the subject tree. Root (empty path) lists database folders (e.g. OSP_PUB); drill into sub-paths — entries with type "l" are folders, type "t" are tables.',
|
|
39
|
+
inputSchema: {
|
|
40
|
+
type: 'object',
|
|
41
|
+
properties: { path: { type: 'string', description: 'Sub-path under the API base (default empty = root, lists databases like OSP_PUB).' } },
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
name: 'table_meta',
|
|
46
|
+
description: 'Table definition (dimensions, valid values). Use the bare table path with no ".px" suffix.',
|
|
47
|
+
inputSchema: {
|
|
48
|
+
type: 'object',
|
|
49
|
+
properties: { path: { type: 'string', description: 'e.g. "OSP_PUB/POP/IR/IRS/IRS010"' } },
|
|
50
|
+
required: ['path'],
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: 'query_table',
|
|
55
|
+
description: 'Pull data from a table. body is a PxWeb query object. Use the bare table path with no ".px" suffix.',
|
|
56
|
+
inputSchema: {
|
|
57
|
+
type: 'object',
|
|
58
|
+
properties: {
|
|
59
|
+
path: { type: 'string', description: 'e.g. "OSP_PUB/POP/IR/IRS/IRS010"' },
|
|
60
|
+
body: { type: 'object', description: '{query: [{code, selection: {filter, values}}], response: {format: "json-stat2"}}' },
|
|
61
|
+
},
|
|
62
|
+
required: ['path', 'body'],
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
];
|
|
66
|
+
|
|
67
|
+
async function callTool(name: string, args: Record<string, unknown>): Promise<unknown> {
|
|
68
|
+
switch (name) {
|
|
69
|
+
case 'subjects': {
|
|
70
|
+
const path = (args.path as string | undefined)?.replace(/^\/+|\/+$/g, '') ?? '';
|
|
71
|
+
return statGet(path ? `/${path}` : '/');
|
|
72
|
+
}
|
|
73
|
+
case 'table_meta':
|
|
74
|
+
return statGet(`/${reqStr(args, 'path', '"OSP_PUB/POP/IR/IRS/IRS010"').replace(/^\/+|\/+$/g, '')}`);
|
|
75
|
+
case 'query_table': {
|
|
76
|
+
const path = reqStr(args, 'path', '"OSP_PUB/POP/IR/IRS/IRS010"').replace(/^\/+|\/+$/g, '');
|
|
77
|
+
const body = args.body;
|
|
78
|
+
if (!body || typeof body !== 'object') throw new Error('body must be a PxWeb query object.');
|
|
79
|
+
const res = await fetch(`${BASE}/${path}`, {
|
|
80
|
+
method: 'POST',
|
|
81
|
+
headers: { 'Content-Type': 'application/json', Accept: 'application/json', 'User-Agent': UA },
|
|
82
|
+
body: JSON.stringify(body),
|
|
83
|
+
});
|
|
84
|
+
if (!res.ok) throw new Error(`Statistics Latvia: ${res.status} ${await res.text().then((t) => t.slice(0, 200))}`);
|
|
85
|
+
return res.json();
|
|
86
|
+
}
|
|
87
|
+
default:
|
|
88
|
+
throw new Error(`Unknown tool: ${name}`);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
async function statGet(path: string): Promise<unknown> {
|
|
93
|
+
const res = await fetch(`${BASE}${path}`, { headers: { Accept: 'application/json', 'User-Agent': UA } });
|
|
94
|
+
if (!res.ok) throw new Error(`Statistics Latvia: ${res.status} ${await res.text().then((t) => t.slice(0, 200))}`);
|
|
95
|
+
return res.json();
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function reqStr(args: Record<string, unknown>, key: string, example: string): string {
|
|
99
|
+
const v = args[key];
|
|
100
|
+
if (typeof v !== 'string' || !v.trim()) throw new Error(`Required argument "${key}" is missing. Pass a string like ${example}.`);
|
|
101
|
+
return v;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
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
|
+
}
|