@pipeworx/mcp-airquality 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,35 @@
1
+ # @pipeworx/mcp-airquality
2
+
3
+ MCP server for the [Open-Meteo Air Quality API](https://air-quality-api.open-meteo.com) — current air quality conditions and hourly forecasts by location. Free, no auth required.
4
+
5
+ ## Tools
6
+
7
+ | Tool | Description |
8
+ |------|-------------|
9
+ | `get_air_quality` | Current AQI, PM2.5, PM10, CO, NO2, and ozone for a location |
10
+ | `get_forecast` | Hourly air quality forecast (1-7 days) |
11
+
12
+ ## Quick Start
13
+
14
+ Add to your MCP client config:
15
+
16
+ ```json
17
+ {
18
+ "mcpServers": {
19
+ "airquality": {
20
+ "type": "url",
21
+ "url": "https://gateway.pipeworx.io/airquality"
22
+ }
23
+ }
24
+ }
25
+ ```
26
+
27
+ ## CLI Usage
28
+
29
+ ```bash
30
+ npx @anthropic-ai/mcp-client https://gateway.pipeworx.io/airquality
31
+ ```
32
+
33
+ ## License
34
+
35
+ MIT
package/package.json ADDED
@@ -0,0 +1,10 @@
1
+ {
2
+ "name": "@pipeworx/mcp-airquality",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "license": "MIT",
6
+ "keywords": ["mcp", "mcp-server", "model-context-protocol", "pipeworx", "airquality"],
7
+ "devDependencies": {
8
+ "typescript": "^5.7.0"
9
+ }
10
+ }
package/src/index.ts ADDED
@@ -0,0 +1,153 @@
1
+ /**
2
+ * Air Quality MCP — wraps air-quality-api.open-meteo.com (free, no auth)
3
+ *
4
+ * Tools:
5
+ * - get_air_quality: Current air quality conditions for a location
6
+ * - get_forecast: Hourly air quality forecast for a location
7
+ */
8
+
9
+ interface McpToolDefinition {
10
+ name: string;
11
+ description: string;
12
+ inputSchema: {
13
+ type: 'object';
14
+ properties: Record<string, unknown>;
15
+ required?: string[];
16
+ };
17
+ }
18
+
19
+ interface McpToolExport {
20
+ tools: McpToolDefinition[];
21
+ callTool: (name: string, args: Record<string, unknown>) => Promise<unknown>;
22
+ }
23
+
24
+ const BASE_URL = 'https://air-quality-api.open-meteo.com/v1';
25
+
26
+ type RawCurrentResponse = {
27
+ latitude: number;
28
+ longitude: number;
29
+ current: {
30
+ us_aqi: number;
31
+ pm10: number;
32
+ pm2_5: number;
33
+ carbon_monoxide: number;
34
+ nitrogen_dioxide: number;
35
+ ozone: number;
36
+ };
37
+ };
38
+
39
+ type RawForecastResponse = {
40
+ latitude: number;
41
+ longitude: number;
42
+ hourly: {
43
+ time: string[];
44
+ us_aqi: number[];
45
+ pm2_5: number[];
46
+ pm10: number[];
47
+ };
48
+ };
49
+
50
+ function aqiCategory(aqi: number): string {
51
+ if (aqi <= 50) return 'Good';
52
+ if (aqi <= 100) return 'Moderate';
53
+ if (aqi <= 150) return 'Unhealthy for Sensitive Groups';
54
+ if (aqi <= 200) return 'Unhealthy';
55
+ if (aqi <= 300) return 'Very Unhealthy';
56
+ return 'Hazardous';
57
+ }
58
+
59
+ const tools: McpToolExport['tools'] = [
60
+ {
61
+ name: 'get_air_quality',
62
+ description:
63
+ 'Get current air quality conditions for a location. Returns US AQI, PM2.5, PM10, carbon monoxide, nitrogen dioxide, and ozone levels.',
64
+ inputSchema: {
65
+ type: 'object',
66
+ properties: {
67
+ latitude: { type: 'number', description: 'Latitude of the location.' },
68
+ longitude: { type: 'number', description: 'Longitude of the location.' },
69
+ },
70
+ required: ['latitude', 'longitude'],
71
+ },
72
+ },
73
+ {
74
+ name: 'get_forecast',
75
+ description:
76
+ 'Get an hourly air quality forecast for a location. Returns US AQI, PM2.5, and PM10 per hour.',
77
+ inputSchema: {
78
+ type: 'object',
79
+ properties: {
80
+ latitude: { type: 'number', description: 'Latitude of the location.' },
81
+ longitude: { type: 'number', description: 'Longitude of the location.' },
82
+ days: {
83
+ type: 'number',
84
+ description: 'Number of forecast days (1-7, default 3).',
85
+ },
86
+ },
87
+ required: ['latitude', 'longitude'],
88
+ },
89
+ },
90
+ ];
91
+
92
+ async function callTool(name: string, args: Record<string, unknown>): Promise<unknown> {
93
+ const lat = args.latitude as number;
94
+ const lon = args.longitude as number;
95
+ switch (name) {
96
+ case 'get_air_quality':
97
+ return getAirQuality(lat, lon);
98
+ case 'get_forecast':
99
+ return getForecast(lat, lon, (args.days as number | undefined) ?? 3);
100
+ default:
101
+ throw new Error(`Unknown tool: ${name}`);
102
+ }
103
+ }
104
+
105
+ async function getAirQuality(lat: number, lon: number) {
106
+ const params = new URLSearchParams({
107
+ latitude: String(lat),
108
+ longitude: String(lon),
109
+ current: 'us_aqi,pm10,pm2_5,carbon_monoxide,nitrogen_dioxide,ozone',
110
+ });
111
+ const res = await fetch(`${BASE_URL}/air-quality?${params}`);
112
+ if (!res.ok) throw new Error(`Air Quality API error: ${res.status}`);
113
+ const data = (await res.json()) as RawCurrentResponse;
114
+ const c = data.current;
115
+ return {
116
+ latitude: data.latitude,
117
+ longitude: data.longitude,
118
+ us_aqi: c.us_aqi,
119
+ aqi_category: aqiCategory(c.us_aqi),
120
+ pm2_5_ug_m3: c.pm2_5,
121
+ pm10_ug_m3: c.pm10,
122
+ carbon_monoxide_ug_m3: c.carbon_monoxide,
123
+ nitrogen_dioxide_ug_m3: c.nitrogen_dioxide,
124
+ ozone_ug_m3: c.ozone,
125
+ };
126
+ }
127
+
128
+ async function getForecast(lat: number, lon: number, days: number) {
129
+ const safeDays = Math.min(7, Math.max(1, days));
130
+ const params = new URLSearchParams({
131
+ latitude: String(lat),
132
+ longitude: String(lon),
133
+ hourly: 'us_aqi,pm2_5,pm10',
134
+ forecast_days: String(safeDays),
135
+ });
136
+ const res = await fetch(`${BASE_URL}/air-quality?${params}`);
137
+ if (!res.ok) throw new Error(`Air Quality API error: ${res.status}`);
138
+ const data = (await res.json()) as RawForecastResponse;
139
+ const h = data.hourly;
140
+ return {
141
+ latitude: data.latitude,
142
+ longitude: data.longitude,
143
+ hours: h.time.map((time, i) => ({
144
+ time,
145
+ us_aqi: h.us_aqi[i],
146
+ aqi_category: aqiCategory(h.us_aqi[i]),
147
+ pm2_5_ug_m3: h.pm2_5[i],
148
+ pm10_ug_m3: h.pm10[i],
149
+ })),
150
+ };
151
+ }
152
+
153
+ export default { tools, callTool } satisfies McpToolExport;
package/tsconfig.json ADDED
@@ -0,0 +1,9 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "ESNext",
5
+ "moduleResolution": "bundler",
6
+ "strict": true
7
+ },
8
+ "include": ["src"]
9
+ }