@pipeworx/mcp-opendata-canada 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-opendata-canada
2
+
3
+ open.canada.ca — Canada national open-data catalogue (CKAN)
4
+
5
+ Part of [Pipeworx](https://pipeworx.io) — an MCP gateway connecting AI agents to 250+ 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
+ "opendata-canada": {
20
+ "url": "https://gateway.pipeworx.io/opendata-canada/mcp"
21
+ }
22
+ }
23
+ }
24
+ ```
25
+
26
+ Or connect to the full Pipeworx gateway for access to all 250+ 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 Opendata Canada 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-opendata-canada",
3
+ "version": "0.1.0",
4
+ "description": "open.canada.ca — Canada national open-data catalogue (CKAN)",
5
+ "type": "module",
6
+ "main": "src/index.ts",
7
+ "types": "src/index.ts",
8
+ "keywords": ["mcp", "mcp-server", "model-context-protocol", "pipeworx", "opendata-canada"],
9
+ "license": "MIT",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/pipeworx-io/mcp-opendata-canada"
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/opendata-canada",
4
+ "title": "Opendata Canada",
5
+ "description": "open.canada.ca — Canada national open-data catalogue (CKAN)",
6
+ "version": "0.1.0",
7
+ "websiteUrl": "https://pipeworx.io/packs/opendata-canada",
8
+ "repository": {
9
+ "url": "https://github.com/pipeworx-io/mcp-opendata-canada",
10
+ "source": "github"
11
+ },
12
+ "remotes": [
13
+ {
14
+ "type": "streamable-http",
15
+ "url": "https://gateway.pipeworx.io/opendata-canada/mcp"
16
+ }
17
+ ]
18
+ }
package/src/index.ts ADDED
@@ -0,0 +1,70 @@
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
+ * open.canada.ca MCP — Canada CKAN catalogue.
21
+ */
22
+
23
+
24
+ const BASE = 'https://open.canada.ca/data/api/3';
25
+ const UA = 'pipeworx-mcp-opendata-canada/1.0 (+https://pipeworx.io)';
26
+
27
+ const tools: McpToolExport['tools'] = [
28
+ { name: 'search', description: 'CKAN package_search.', inputSchema: { type: 'object', properties: { query: { type: 'string' }, fq: { type: 'string' }, rows: { type: 'number' }, start: { type: 'number' } }, required: ['query'] } },
29
+ { name: 'package', description: 'Dataset by id/slug.', inputSchema: { type: 'object', properties: { id: { type: 'string' } }, required: ['id'] } },
30
+ { name: 'organizations', description: 'List orgs.', inputSchema: { type: 'object', properties: { limit: { type: 'number' } } } },
31
+ { name: 'groups', description: 'List themes.', inputSchema: { type: 'object', properties: { limit: { type: 'number' } } } },
32
+ ];
33
+
34
+ async function callTool(name: string, args: Record<string, unknown>): Promise<unknown> {
35
+ switch (name) {
36
+ case 'search': {
37
+ const p = new URLSearchParams({
38
+ q: reqStr(args, 'query', '"agriculture"'),
39
+ rows: String(Math.min(1000, Math.max(1, (args.rows as number) ?? 25))),
40
+ start: String(Math.max(0, (args.start as number) ?? 0)),
41
+ });
42
+ if (args.fq) p.set('fq', String(args.fq));
43
+ return ckanGet(`/action/package_search?${p}`);
44
+ }
45
+ case 'package':
46
+ return ckanGet(`/action/package_show?id=${encodeURIComponent(reqStr(args, 'id', '"<id>"'))}`);
47
+ case 'organizations':
48
+ return ckanGet(`/action/organization_list?all_fields=true&limit=${Math.min(1000, Math.max(1, (args.limit as number) ?? 100))}`);
49
+ case 'groups':
50
+ return ckanGet(`/action/group_list?all_fields=true&limit=${Math.min(1000, Math.max(1, (args.limit as number) ?? 100))}`);
51
+ default:
52
+ throw new Error(`Unknown tool: ${name}`);
53
+ }
54
+ }
55
+
56
+ async function ckanGet(path: string): Promise<unknown> {
57
+ const res = await fetch(`${BASE}${path}`, { headers: { Accept: 'application/json', 'User-Agent': UA } });
58
+ if (!res.ok) throw new Error(`open.canada.ca: ${res.status}`);
59
+ const json = (await res.json()) as { success?: boolean; error?: { message?: string }; result?: unknown };
60
+ if (json.success === false) throw new Error(`open.canada.ca: ${json.error?.message ?? 'unknown error'}`);
61
+ return json.result ?? json;
62
+ }
63
+
64
+ function reqStr(args: Record<string, unknown>, key: string, example: string): string {
65
+ const v = args[key];
66
+ if (typeof v !== 'string' || !v.trim()) throw new Error(`Required argument "${key}" is missing. Pass a string like ${example}.`);
67
+ return v;
68
+ }
69
+
70
+ 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
+ }