@pipeworx/mcp-madrid-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 +166 -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-madrid-events
|
|
2
|
+
|
|
3
|
+
Madrid Events MCP.
|
|
4
|
+
|
|
5
|
+
Part of [Pipeworx](https://pipeworx.io) — an MCP gateway connecting AI agents to 906+ 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
|
+
"madrid-events": {
|
|
20
|
+
"url": "https://gateway.pipeworx.io/madrid-events/mcp"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Or connect to the full Pipeworx gateway for access to all 906+ 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 Madrid 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-madrid-events",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Madrid Events MCP.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "src/index.ts",
|
|
7
|
+
"types": "src/index.ts",
|
|
8
|
+
"keywords": ["mcp", "mcp-server", "model-context-protocol", "pipeworx", "madrid-events"],
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/pipeworx-io/mcp-madrid-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/madrid-events",
|
|
4
|
+
"title": "Madrid Events",
|
|
5
|
+
"description": "Madrid Events MCP.",
|
|
6
|
+
"version": "0.1.0",
|
|
7
|
+
"websiteUrl": "https://pipeworx.io/packs/madrid-events",
|
|
8
|
+
"repository": {
|
|
9
|
+
"url": "https://github.com/pipeworx-io/mcp-madrid-events",
|
|
10
|
+
"source": "github"
|
|
11
|
+
},
|
|
12
|
+
"remotes": [
|
|
13
|
+
{
|
|
14
|
+
"type": "streamable-http",
|
|
15
|
+
"url": "https://gateway.pipeworx.io/madrid-events/mcp"
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
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
|
+
* Madrid Events MCP.
|
|
21
|
+
*
|
|
22
|
+
* Cultural events & activities in Madrid, Spain for the next ~100 days, from the
|
|
23
|
+
* city's open-data portal (datos.madrid.es). Keyless JSON feed (~870 events),
|
|
24
|
+
* filtered/normalized in-pack by keyword, free admission and date window. Rich
|
|
25
|
+
* per-event data: venue, address, geo, audience, price. Content is in Spanish.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
const FEED = 'https://datos.madrid.es/egob/catalogo/206974-0-agenda-eventos-culturales-100.json';
|
|
30
|
+
const UA = 'pipeworx-mcp-madrid-events/1.0 (+https://pipeworx.io)';
|
|
31
|
+
const MAX_LIMIT = 50;
|
|
32
|
+
|
|
33
|
+
const tools: McpToolExport['tools'] = [
|
|
34
|
+
{
|
|
35
|
+
name: 'events',
|
|
36
|
+
description:
|
|
37
|
+
'Find cultural events & activities in Madrid, Spain (next ~100 days). Filter by keyword, free admission, and date window. Returns events with venue, address, geo, audience and price. Content is in Spanish.',
|
|
38
|
+
inputSchema: {
|
|
39
|
+
type: 'object',
|
|
40
|
+
properties: {
|
|
41
|
+
query: { type: 'string', description: 'Keyword over title, description and venue, e.g. "música", "exposición", "teatro".' },
|
|
42
|
+
free_only: { type: 'boolean', description: 'If true, only free events.' },
|
|
43
|
+
from: { type: 'string', description: 'Include events on/after this date YYYY-MM-DD (default: today).' },
|
|
44
|
+
to: { type: 'string', description: 'Include events starting on/before this date YYYY-MM-DD.' },
|
|
45
|
+
limit: { type: 'number', description: `Max events (1-${MAX_LIMIT}, default 20).` },
|
|
46
|
+
offset: { type: 'number', description: 'Pagination offset (default 0).' },
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
];
|
|
51
|
+
|
|
52
|
+
async function callTool(name: string, args: Record<string, unknown>): Promise<unknown> {
|
|
53
|
+
if (name !== 'events') throw new Error(`Unknown tool: ${name}`);
|
|
54
|
+
|
|
55
|
+
const res = await fetch(FEED, { headers: { Accept: 'application/json', 'User-Agent': UA } });
|
|
56
|
+
if (!res.ok) throw new Error(`Madrid events: HTTP ${res.status}`);
|
|
57
|
+
const all = ((await res.json()) as { '@graph'?: MadridEvent[] })['@graph'] ?? [];
|
|
58
|
+
|
|
59
|
+
const from = dateArg(args.from) || todayISO();
|
|
60
|
+
const to = dateArg(args.to);
|
|
61
|
+
const q = typeof args.query === 'string' ? args.query.trim().toLowerCase() : '';
|
|
62
|
+
const freeOnly = args.free_only === true;
|
|
63
|
+
const limit = clamp(numArg(args.limit, 20), 1, MAX_LIMIT);
|
|
64
|
+
const offset = Math.max(0, numArg(args.offset, 0));
|
|
65
|
+
|
|
66
|
+
let out = all.filter((e) => {
|
|
67
|
+
const start = dpart(e.dtstart);
|
|
68
|
+
const end = dpart(e.dtend) || start;
|
|
69
|
+
if (end && end < from) return false;
|
|
70
|
+
if (to && start && start > to) return false;
|
|
71
|
+
if (freeOnly && !isFree(e)) return false;
|
|
72
|
+
if (q) {
|
|
73
|
+
const hay = `${e.title} ${e.description} ${e['event-location']} ${e.audience}`.toLowerCase();
|
|
74
|
+
if (!hay.includes(q)) return false;
|
|
75
|
+
}
|
|
76
|
+
return true;
|
|
77
|
+
});
|
|
78
|
+
out.sort((a, b) => (dpart(a.dtstart) || '9999').localeCompare(dpart(b.dtstart) || '9999'));
|
|
79
|
+
|
|
80
|
+
return {
|
|
81
|
+
city: 'Madrid',
|
|
82
|
+
country: 'Spain',
|
|
83
|
+
source: 'datos.madrid.es',
|
|
84
|
+
date_from: from,
|
|
85
|
+
date_to: to || null,
|
|
86
|
+
total_matching: out.length,
|
|
87
|
+
count: Math.min(Math.max(0, out.length - offset), limit),
|
|
88
|
+
events: out.slice(offset, offset + limit).map(normalize),
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
interface MadridAddress { area?: { locality?: string; 'postal-code'?: string; 'street-address'?: string }; district?: { '@id'?: string } }
|
|
93
|
+
interface MadridEvent {
|
|
94
|
+
id?: string | number;
|
|
95
|
+
title?: string;
|
|
96
|
+
description?: string;
|
|
97
|
+
free?: string | number | boolean;
|
|
98
|
+
price?: string;
|
|
99
|
+
dtstart?: string;
|
|
100
|
+
dtend?: string;
|
|
101
|
+
time?: string;
|
|
102
|
+
audience?: string;
|
|
103
|
+
link?: string;
|
|
104
|
+
'event-location'?: string;
|
|
105
|
+
address?: MadridAddress;
|
|
106
|
+
location?: { latitude?: number; longitude?: number };
|
|
107
|
+
organization?: { 'organization-name'?: string };
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function normalize(e: MadridEvent): Record<string, unknown> {
|
|
111
|
+
const a = e.address?.area;
|
|
112
|
+
const free = isFree(e);
|
|
113
|
+
return {
|
|
114
|
+
id: e.id,
|
|
115
|
+
title: e.title,
|
|
116
|
+
url: e.link,
|
|
117
|
+
summary: e.description ? e.description.replace(/\s+/g, ' ').trim().slice(0, 600) : undefined,
|
|
118
|
+
date_start: dpart(e.dtstart) || undefined,
|
|
119
|
+
date_end: dpart(e.dtend) && dpart(e.dtend) !== dpart(e.dtstart) ? dpart(e.dtend) : undefined,
|
|
120
|
+
time: e.time || undefined,
|
|
121
|
+
is_free: free,
|
|
122
|
+
price: free ? undefined : e.price?.trim() || undefined,
|
|
123
|
+
audience: e.audience || undefined,
|
|
124
|
+
venue: {
|
|
125
|
+
name: e['event-location'] || e.organization?.['organization-name'] || undefined,
|
|
126
|
+
address: [a?.['street-address'], a?.['postal-code'], a?.locality].filter((p) => p && String(p).trim()).join(', ') || undefined,
|
|
127
|
+
district: district(e.address?.district?.['@id']),
|
|
128
|
+
latitude: e.location?.latitude,
|
|
129
|
+
longitude: e.location?.longitude,
|
|
130
|
+
},
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function isFree(e: MadridEvent): boolean {
|
|
135
|
+
return e.free === 1 || e.free === '1' || e.free === true;
|
|
136
|
+
}
|
|
137
|
+
/** Pull the district name from its @id URL (…/Distrito/Hortaleza). */
|
|
138
|
+
function district(id?: string): string | undefined {
|
|
139
|
+
if (!id) return undefined;
|
|
140
|
+
const m = id.match(/\/Distrito\/([^/]+)/);
|
|
141
|
+
return m ? decodeURIComponent(m[1]) : undefined;
|
|
142
|
+
}
|
|
143
|
+
/** "2026-08-21 22:00:00.0" -> "2026-08-21". */
|
|
144
|
+
function dpart(s?: string): string {
|
|
145
|
+
if (typeof s !== 'string') return '';
|
|
146
|
+
const m = s.match(/^(\d{4})-(\d{2})-(\d{2})/);
|
|
147
|
+
return m ? `${m[1]}-${m[2]}-${m[3]}` : '';
|
|
148
|
+
}
|
|
149
|
+
function dateArg(v: unknown): string {
|
|
150
|
+
if (typeof v !== 'string') return '';
|
|
151
|
+
const m = v.trim().match(/^(\d{4})-(\d{2})-(\d{2})/);
|
|
152
|
+
return m ? `${m[1]}-${m[2]}-${m[3]}` : '';
|
|
153
|
+
}
|
|
154
|
+
function todayISO(): string {
|
|
155
|
+
const d = new Date(Date.now() + 2 * 3600 * 1000); // approx Madrid (CEST)
|
|
156
|
+
return `${d.getUTCFullYear()}-${String(d.getUTCMonth() + 1).padStart(2, '0')}-${String(d.getUTCDate()).padStart(2, '0')}`;
|
|
157
|
+
}
|
|
158
|
+
function numArg(v: unknown, dflt: number): number {
|
|
159
|
+
const n = typeof v === 'number' ? v : typeof v === 'string' ? Number(v) : NaN;
|
|
160
|
+
return Number.isFinite(n) ? n : dflt;
|
|
161
|
+
}
|
|
162
|
+
function clamp(n: number, lo: number, hi: number): number {
|
|
163
|
+
return Math.max(lo, Math.min(hi, Math.trunc(n)));
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
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
|
+
}
|