@pipeworx/mcp-openagenda 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-openagenda
2
+
3
+ OpenAgenda MCP.
4
+
5
+ Part of [Pipeworx](https://pipeworx.io) — an MCP gateway connecting AI agents to 907+ 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
+ "openagenda": {
20
+ "url": "https://gateway.pipeworx.io/openagenda/mcp"
21
+ }
22
+ }
23
+ }
24
+ ```
25
+
26
+ Or connect to the full Pipeworx gateway for access to all 907+ 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 Openagenda 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-openagenda",
3
+ "version": "0.1.0",
4
+ "description": "OpenAgenda MCP.",
5
+ "type": "module",
6
+ "main": "src/index.ts",
7
+ "types": "src/index.ts",
8
+ "keywords": ["mcp", "mcp-server", "model-context-protocol", "pipeworx", "openagenda"],
9
+ "license": "MIT",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/pipeworx-io/mcp-openagenda"
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/openagenda",
4
+ "title": "Openagenda",
5
+ "description": "OpenAgenda MCP.",
6
+ "version": "0.1.0",
7
+ "websiteUrl": "https://pipeworx.io/packs/openagenda",
8
+ "repository": {
9
+ "url": "https://github.com/pipeworx-io/mcp-openagenda",
10
+ "source": "github"
11
+ },
12
+ "remotes": [
13
+ {
14
+ "type": "streamable-http",
15
+ "url": "https://gateway.pipeworx.io/openagenda/mcp"
16
+ }
17
+ ]
18
+ }
package/src/index.ts ADDED
@@ -0,0 +1,220 @@
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
+ * OpenAgenda MCP.
21
+ *
22
+ * Events from the OpenAgenda network (openagenda.com) — thousands of public
23
+ * "agendas" (calendars) published by cities, cultural venues, tourism boards
24
+ * and organisations, mostly across France plus some international. Events live
25
+ * inside individual agendas (there is no global cross-agenda search), so this
26
+ * pack is two-step: `search_agendas` to discover an agenda, then `events` to
27
+ * query its events. Requires a free key: the gateway fronts a platform key
28
+ * (PLATFORM_OPENAGENDA_KEY) and callers may pass their own via `_apiKey`.
29
+ */
30
+
31
+
32
+ const BASE = 'https://api.openagenda.com/v2';
33
+ const UA = 'pipeworx-mcp-openagenda/1.0 (+https://pipeworx.io)';
34
+ const LANGS = ['en', 'fr'];
35
+
36
+ const tools: McpToolExport['tools'] = [
37
+ {
38
+ name: 'search_agendas',
39
+ description:
40
+ 'Find OpenAgenda agendas (event calendars) by keyword — e.g. a city, venue, festival or organisation name. Returns agenda uid + slug + title. Pass the uid to the events tool. Most agendas are French.',
41
+ inputSchema: {
42
+ type: 'object',
43
+ properties: {
44
+ query: { type: 'string', description: 'Search text, e.g. "Nantes", "festival jazz", "musée".' },
45
+ official_only: { type: 'boolean', description: 'If true, only official (verified) agendas.' },
46
+ size: { type: 'number', description: 'How many agendas to return (1-20, default 10).' },
47
+ },
48
+ required: ['query'],
49
+ },
50
+ },
51
+ {
52
+ name: 'events',
53
+ description:
54
+ 'List events from one OpenAgenda agenda (get its uid from search_agendas). Defaults to upcoming events. Optionally filter by keyword and date window. Returns title, dates, venue, coordinates and keywords (English where available, else French).',
55
+ inputSchema: {
56
+ type: 'object',
57
+ properties: {
58
+ agenda_uid: { type: 'string', description: 'Agenda uid from search_agendas, e.g. "6008621".' },
59
+ query: { type: 'string', description: 'Keyword filter over the agenda’s events.' },
60
+ from: { type: 'string', description: 'Earliest event date YYYY-MM-DD (default: today, upcoming only).' },
61
+ to: { type: 'string', description: 'Latest event date YYYY-MM-DD.' },
62
+ size: { type: 'number', description: 'Max events to return (1-50, default 20).' },
63
+ },
64
+ required: ['agenda_uid'],
65
+ },
66
+ },
67
+ ];
68
+
69
+ async function callTool(name: string, args: Record<string, unknown>): Promise<unknown> {
70
+ const key = keyOf(args);
71
+ switch (name) {
72
+ case 'search_agendas':
73
+ return searchAgendas(key, args);
74
+ case 'events':
75
+ return getEvents(key, args);
76
+ default:
77
+ throw new Error(`Unknown tool: ${name}`);
78
+ }
79
+ }
80
+
81
+ async function searchAgendas(key: string, args: Record<string, unknown>): Promise<unknown> {
82
+ const query = String(args.query ?? '').trim();
83
+ if (!query) throw new Error('Pass a `query` to search agendas.');
84
+ const qs = new URLSearchParams({ key, search: query, size: String(clamp(numArg(args.size, 10), 1, 20)) });
85
+ if (args.official_only === true) qs.set('official', '1');
86
+ const data = (await oaGet(`/agendas?${qs.toString()}`)) as { total?: number; agendas?: OaAgenda[] };
87
+ return {
88
+ total_matching: data.total ?? 0,
89
+ count: data.agendas?.length ?? 0,
90
+ agendas: (data.agendas ?? []).map((a) => ({
91
+ uid: a.uid,
92
+ slug: a.slug,
93
+ title: a.title,
94
+ description: typeof a.description === 'string' ? a.description : loc(a.description),
95
+ official: !!a.official,
96
+ url: a.slug ? `https://openagenda.com/${a.slug}` : undefined,
97
+ })),
98
+ };
99
+ }
100
+
101
+ async function getEvents(key: string, args: Record<string, unknown>): Promise<unknown> {
102
+ const uid = String(args.agenda_uid ?? '').trim();
103
+ if (!/^\d+$/.test(uid)) throw new Error('Pass a numeric `agenda_uid` (from search_agendas).');
104
+ const qs = new URLSearchParams({ key, size: String(clamp(numArg(args.size, 20), 1, 50)) });
105
+ const from = dateArg(args.from);
106
+ const to = dateArg(args.to);
107
+ if (from) qs.set('timings[gte]', from);
108
+ else qs.append('relative[]', 'upcoming');
109
+ if (to) qs.set('timings[lte]', `${to}T23:59:59`);
110
+ if (typeof args.query === 'string' && args.query.trim()) qs.set('search', args.query.trim());
111
+
112
+ const data = (await oaGet(`/agendas/${uid}/events?${qs.toString()}`)) as { total?: number; events?: OaEvent[] };
113
+ return {
114
+ source: 'openagenda.com',
115
+ agenda_uid: uid,
116
+ total_matching: data.total ?? 0,
117
+ count: data.events?.length ?? 0,
118
+ events: (data.events ?? []).map(normalize),
119
+ };
120
+ }
121
+
122
+ interface LangMap { [lang: string]: string | string[] }
123
+ interface OaAgenda { uid?: number; slug?: string; title?: string; description?: string | LangMap; official?: boolean }
124
+ interface OaTiming { begin?: string; end?: string }
125
+ interface OaLocation { name?: string; address?: string; city?: string; postalCode?: string; latitude?: number; longitude?: number; countryCode?: string }
126
+ interface OaEvent {
127
+ uid?: number;
128
+ slug?: string;
129
+ title?: LangMap;
130
+ description?: LangMap;
131
+ dateRange?: LangMap;
132
+ firstTiming?: OaTiming;
133
+ nextTiming?: OaTiming;
134
+ lastTiming?: OaTiming;
135
+ location?: OaLocation;
136
+ keywords?: LangMap;
137
+ onlineAccessLink?: string | null;
138
+ attendanceMode?: number;
139
+ originAgenda?: { slug?: string };
140
+ }
141
+
142
+ function normalize(e: OaEvent): Record<string, unknown> {
143
+ const t = e.nextTiming || e.firstTiming;
144
+ const loc0 = e.location;
145
+ const agSlug = e.originAgenda?.slug;
146
+ return {
147
+ id: e.uid,
148
+ title: loc(e.title),
149
+ when: loc(e.dateRange) || undefined,
150
+ start: t?.begin || undefined,
151
+ end: t?.end || undefined,
152
+ summary: clean(loc(e.description))?.slice(0, 500) || undefined,
153
+ venue: loc0
154
+ ? {
155
+ name: loc0.name,
156
+ address: [loc0.address, loc0.postalCode, loc0.city].filter((p) => p && String(p).trim()).join(', ') || undefined,
157
+ city: loc0.city,
158
+ latitude: loc0.latitude,
159
+ longitude: loc0.longitude,
160
+ }
161
+ : undefined,
162
+ keywords: locArr(e.keywords),
163
+ online_link: e.onlineAccessLink || undefined,
164
+ url: agSlug && e.slug ? `https://openagenda.com/${agSlug}/events/${e.slug}` : undefined,
165
+ };
166
+ }
167
+
168
+ /** Pick a localized string, preferring English then French then any. */
169
+ function loc(m?: string | LangMap): string {
170
+ if (!m) return '';
171
+ if (typeof m === 'string') return m;
172
+ for (const l of LANGS) if (typeof m[l] === 'string') return m[l] as string;
173
+ const v = Object.values(m).find((x) => typeof x === 'string');
174
+ return (v as string) || '';
175
+ }
176
+ function locArr(m?: LangMap): string[] {
177
+ if (!m) return [];
178
+ for (const l of LANGS) if (Array.isArray(m[l])) return (m[l] as string[]).slice(0, 12);
179
+ const v = Object.values(m).find((x) => Array.isArray(x));
180
+ return Array.isArray(v) ? (v as string[]).slice(0, 12) : [];
181
+ }
182
+ function clean(s: string): string {
183
+ return s.replace(/<[^>]+>/g, ' ').replace(/&amp;/g, '&').replace(/&nbsp;/g, ' ').replace(/\s+/g, ' ').trim();
184
+ }
185
+
186
+ async function oaGet(path: string): Promise<unknown> {
187
+ const res = await fetch(`${BASE}${path}`, { headers: { Accept: 'application/json', 'User-Agent': UA } });
188
+ const body = (await res.json().catch(() => ({}))) as Record<string, unknown>;
189
+ if (!res.ok || body.success === false) {
190
+ const msg = (body.error as string) || (body.message as string) || `HTTP ${res.status}`;
191
+ if (res.status === 401 || res.status === 403 || /key/i.test(msg)) {
192
+ throw new Error(`OpenAgenda: ${msg}. The platform key may be unset — pass your own free key via _apiKey (openagenda.com account).`);
193
+ }
194
+ throw new Error(`OpenAgenda: ${msg}`);
195
+ }
196
+ return body;
197
+ }
198
+
199
+ function keyOf(args: Record<string, unknown>): string {
200
+ const k = args._apiKey;
201
+ if (typeof k !== 'string' || !k.trim()) {
202
+ throw new Error('OpenAgenda requires an API key. The gateway normally fronts a platform key; otherwise pass _apiKey (free key from an openagenda.com account).');
203
+ }
204
+ delete args._apiKey;
205
+ return k.trim();
206
+ }
207
+ function dateArg(v: unknown): string {
208
+ if (typeof v !== 'string') return '';
209
+ const m = v.trim().match(/^(\d{4})-(\d{2})-(\d{2})/);
210
+ return m ? `${m[1]}-${m[2]}-${m[3]}` : '';
211
+ }
212
+ function numArg(v: unknown, dflt: number): number {
213
+ const n = typeof v === 'number' ? v : typeof v === 'string' ? Number(v) : NaN;
214
+ return Number.isFinite(n) ? n : dflt;
215
+ }
216
+ function clamp(n: number, lo: number, hi: number): number {
217
+ return Math.max(lo, Math.min(hi, Math.trunc(n)));
218
+ }
219
+
220
+ 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
+ }