@pipeworx/mcp-montreal-events 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 +171 -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-montreal-events
|
|
2
|
+
|
|
3
|
+
Montréal Events MCP.
|
|
4
|
+
|
|
5
|
+
Part of [Pipeworx](https://pipeworx.io) — an MCP gateway connecting AI agents to 904+ 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
|
+
"montreal-events": {
|
|
20
|
+
"url": "https://gateway.pipeworx.io/montreal-events/mcp"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Or connect to the full Pipeworx gateway for access to all 904+ 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 Montreal Events 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-montreal-events",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Montréal Events MCP.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "src/index.ts",
|
|
7
|
+
"types": "src/index.ts",
|
|
8
|
+
"keywords": ["mcp", "mcp-server", "model-context-protocol", "pipeworx", "montreal-events"],
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/pipeworx-io/mcp-montreal-events"
|
|
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/montreal-events",
|
|
4
|
+
"title": "Montreal Events",
|
|
5
|
+
"description": "Montréal Events MCP.",
|
|
6
|
+
"version": "0.1.0",
|
|
7
|
+
"websiteUrl": "https://pipeworx.io/packs/montreal-events",
|
|
8
|
+
"repository": {
|
|
9
|
+
"url": "https://github.com/pipeworx-io/mcp-montreal-events",
|
|
10
|
+
"source": "github"
|
|
11
|
+
},
|
|
12
|
+
"remotes": [
|
|
13
|
+
{
|
|
14
|
+
"type": "streamable-http",
|
|
15
|
+
"url": "https://gateway.pipeworx.io/montreal-events/mcp"
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
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
|
+
* Montréal Events MCP.
|
|
21
|
+
*
|
|
22
|
+
* Public events across the city of Montréal (Canada) from the city's open-data
|
|
23
|
+
* portal (donnees.montreal.ca, "evenements-publics" CKAN datastore). Keyless,
|
|
24
|
+
* ~6,000 events. Filter by keyword, borough (arrondissement) and date window.
|
|
25
|
+
* Content is in French (Montréal source).
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
const SQL_URL = 'https://donnees.montreal.ca/api/3/action/datastore_search_sql';
|
|
30
|
+
const RESOURCE_ID = '6decf611-6f11-4f34-bb36-324d804c9bad';
|
|
31
|
+
const UA = 'pipeworx-mcp-montreal-events/1.0 (+https://pipeworx.io)';
|
|
32
|
+
const MAX_LIMIT = 50;
|
|
33
|
+
|
|
34
|
+
const tools: McpToolExport['tools'] = [
|
|
35
|
+
{
|
|
36
|
+
name: 'events',
|
|
37
|
+
description:
|
|
38
|
+
'Find upcoming public events in Montréal, Canada. Filter by keyword, borough (arrondissement, e.g. "Ville-Marie", "Le Plateau-Mont-Royal") and date window. Returns events sorted by start date. Content is in French.',
|
|
39
|
+
inputSchema: {
|
|
40
|
+
type: 'object',
|
|
41
|
+
properties: {
|
|
42
|
+
query: { type: 'string', description: 'Keyword over title and description, e.g. "musique", "festival", "famille".' },
|
|
43
|
+
borough: { type: 'string', description: 'Filter by arrondissement, e.g. "Ville-Marie", "Le Plateau-Mont-Royal", "Rosemont".' },
|
|
44
|
+
from: { type: 'string', description: 'Include events ending on/after this date YYYY-MM-DD (default: today).' },
|
|
45
|
+
to: { type: 'string', description: 'Include events starting on/before this date YYYY-MM-DD.' },
|
|
46
|
+
limit: { type: 'number', description: `Max events (1-${MAX_LIMIT}, default 20).` },
|
|
47
|
+
offset: { type: 'number', description: 'Pagination offset (default 0).' },
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
];
|
|
52
|
+
|
|
53
|
+
async function callTool(name: string, args: Record<string, unknown>): Promise<unknown> {
|
|
54
|
+
if (name !== 'events') throw new Error(`Unknown tool: ${name}`);
|
|
55
|
+
|
|
56
|
+
const from = dateArg(args.from) || todayISO();
|
|
57
|
+
const to = dateArg(args.to);
|
|
58
|
+
const where: string[] = [`date_fin >= '${from}'`];
|
|
59
|
+
if (to) where.push(`date_debut <= '${to}'`);
|
|
60
|
+
if (typeof args.borough === 'string' && args.borough.trim()) where.push(`arrondissement ILIKE '%${sql(args.borough)}%'`);
|
|
61
|
+
if (typeof args.query === 'string' && args.query.trim()) {
|
|
62
|
+
const q = sql(args.query);
|
|
63
|
+
where.push(`(titre ILIKE '%${q}%' OR description ILIKE '%${q}%')`);
|
|
64
|
+
}
|
|
65
|
+
const clause = where.join(' AND ');
|
|
66
|
+
const limit = clamp(numArg(args.limit, 20), 1, MAX_LIMIT);
|
|
67
|
+
const offset = Math.max(0, numArg(args.offset, 0));
|
|
68
|
+
|
|
69
|
+
const total = await countQuery(clause);
|
|
70
|
+
const rows = (await runSql(
|
|
71
|
+
`SELECT _id,titre,url_fiche,description,date_debut,date_fin,type_evenement,public_cible,emplacement,inscription,cout,arrondissement,adresse_principale,code_postal,lat,long FROM "${RESOURCE_ID}" WHERE ${clause} ORDER BY date_debut ASC LIMIT ${limit} OFFSET ${offset}`,
|
|
72
|
+
)) as MtlEvent[];
|
|
73
|
+
|
|
74
|
+
return {
|
|
75
|
+
city: 'Montréal',
|
|
76
|
+
country: 'Canada',
|
|
77
|
+
source: 'donnees.montreal.ca',
|
|
78
|
+
date_from: from,
|
|
79
|
+
date_to: to || null,
|
|
80
|
+
total_matching: total,
|
|
81
|
+
count: rows.length,
|
|
82
|
+
events: rows.map(normalize),
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
async function countQuery(clause: string): Promise<number> {
|
|
87
|
+
try {
|
|
88
|
+
const rows = (await runSql(`SELECT COUNT(*) AS n FROM "${RESOURCE_ID}" WHERE ${clause}`)) as { n?: string | number }[];
|
|
89
|
+
return Number(rows[0]?.n ?? 0);
|
|
90
|
+
} catch {
|
|
91
|
+
return 0;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
async function runSql(sqlText: string): Promise<unknown[]> {
|
|
96
|
+
const res = await fetch(`${SQL_URL}?sql=${encodeURIComponent(sqlText)}`, { headers: { Accept: 'application/json', 'User-Agent': UA } });
|
|
97
|
+
const body = (await res.json().catch(() => ({}))) as { success?: boolean; result?: { records?: unknown[] }; error?: { message?: string } };
|
|
98
|
+
if (!res.ok || body.success === false) throw new Error(`Montréal: ${body.error?.message || `HTTP ${res.status}`}`);
|
|
99
|
+
return body.result?.records ?? [];
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
interface MtlEvent {
|
|
103
|
+
_id?: number;
|
|
104
|
+
titre?: string;
|
|
105
|
+
url_fiche?: string;
|
|
106
|
+
description?: string;
|
|
107
|
+
date_debut?: string;
|
|
108
|
+
date_fin?: string;
|
|
109
|
+
type_evenement?: string;
|
|
110
|
+
public_cible?: string;
|
|
111
|
+
emplacement?: string;
|
|
112
|
+
inscription?: string;
|
|
113
|
+
cout?: string;
|
|
114
|
+
arrondissement?: string;
|
|
115
|
+
adresse_principale?: string;
|
|
116
|
+
code_postal?: string;
|
|
117
|
+
lat?: string | number;
|
|
118
|
+
long?: string | number;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function normalize(e: MtlEvent): Record<string, unknown> {
|
|
122
|
+
const cost = (e.cout || '').trim();
|
|
123
|
+
const reg = (e.inscription || '').trim();
|
|
124
|
+
return {
|
|
125
|
+
id: e._id,
|
|
126
|
+
title: e.titre,
|
|
127
|
+
url: e.url_fiche,
|
|
128
|
+
summary: e.description ? e.description.replace(/\s+/g, ' ').trim().slice(0, 600) : undefined,
|
|
129
|
+
date_start: e.date_debut || undefined,
|
|
130
|
+
date_end: e.date_fin && e.date_fin !== e.date_debut ? e.date_fin : undefined,
|
|
131
|
+
type: e.type_evenement || undefined,
|
|
132
|
+
audience: e.public_cible || undefined,
|
|
133
|
+
is_free: /gratuit|entrée libre|libre/i.test(`${cost} ${reg}`),
|
|
134
|
+
cost: cost || undefined,
|
|
135
|
+
registration: reg || undefined,
|
|
136
|
+
borough: e.arrondissement || undefined,
|
|
137
|
+
venue: {
|
|
138
|
+
location: e.emplacement || undefined,
|
|
139
|
+
address: [e.adresse_principale, e.code_postal].filter((p) => p && String(p).trim()).join(', ') || undefined,
|
|
140
|
+
latitude: numOrUndef(e.lat),
|
|
141
|
+
longitude: numOrUndef(e.long),
|
|
142
|
+
},
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/** Escape single quotes for the read-only datastore SQL (defence-in-depth; endpoint is SELECT-only). */
|
|
147
|
+
function sql(v: string): string {
|
|
148
|
+
return v.trim().replace(/'/g, "''").replace(/[;\\]/g, '').slice(0, 80);
|
|
149
|
+
}
|
|
150
|
+
function numOrUndef(v: unknown): number | undefined {
|
|
151
|
+
const n = typeof v === 'number' ? v : typeof v === 'string' ? Number(v) : NaN;
|
|
152
|
+
return Number.isFinite(n) && n !== 0 ? n : undefined;
|
|
153
|
+
}
|
|
154
|
+
function dateArg(v: unknown): string {
|
|
155
|
+
if (typeof v !== 'string') return '';
|
|
156
|
+
const m = v.trim().match(/^(\d{4})-(\d{2})-(\d{2})/);
|
|
157
|
+
return m ? `${m[1]}-${m[2]}-${m[3]}` : '';
|
|
158
|
+
}
|
|
159
|
+
function todayISO(): string {
|
|
160
|
+
const d = new Date(Date.now() - 4 * 3600 * 1000); // approx Montréal (EDT)
|
|
161
|
+
return `${d.getUTCFullYear()}-${String(d.getUTCMonth() + 1).padStart(2, '0')}-${String(d.getUTCDate()).padStart(2, '0')}`;
|
|
162
|
+
}
|
|
163
|
+
function numArg(v: unknown, dflt: number): number {
|
|
164
|
+
const n = typeof v === 'number' ? v : typeof v === 'string' ? Number(v) : NaN;
|
|
165
|
+
return Number.isFinite(n) ? n : dflt;
|
|
166
|
+
}
|
|
167
|
+
function clamp(n: number, lo: number, hi: number): number {
|
|
168
|
+
return Math.max(lo, Math.min(hi, Math.trunc(n)));
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
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
|
+
}
|