@mcp-monorepo/weather 1.0.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/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/tools/geocoding.d.ts +3 -0
- package/dist/tools/geocoding.d.ts.map +1 -0
- package/dist/tools/geocoding.js +63 -0
- package/dist/tools/geocoding.js.map +1 -0
- package/dist/tools/geocoding.types.d.ts +25 -0
- package/dist/tools/geocoding.types.d.ts.map +1 -0
- package/dist/tools/geocoding.types.js +2 -0
- package/dist/tools/geocoding.types.js.map +1 -0
- package/dist/tools/weather-by-coords.d.ts +69 -0
- package/dist/tools/weather-by-coords.d.ts.map +1 -0
- package/dist/tools/weather-by-coords.js +105 -0
- package/dist/tools/weather-by-coords.js.map +1 -0
- package/dist/tools/weather-by-coords.types.d.ts +48 -0
- package/dist/tools/weather-by-coords.types.d.ts.map +1 -0
- package/dist/tools/weather-by-coords.types.js +2 -0
- package/dist/tools/weather-by-coords.types.js.map +1 -0
- package/package.json +38 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createMcpServer } from '@mcp-monorepo/shared';
|
|
3
|
+
import { registerGeocodingTool } from './tools/geocoding.js';
|
|
4
|
+
import { registerWeatherByCoordsTool } from './tools/weather-by-coords.js';
|
|
5
|
+
createMcpServer({
|
|
6
|
+
name: 'weather',
|
|
7
|
+
importMetaPath: import.meta.filename,
|
|
8
|
+
title: 'Weather MCP Server',
|
|
9
|
+
tools: [registerGeocodingTool, registerWeatherByCoordsTool],
|
|
10
|
+
});
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAEtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAA;AAC5D,OAAO,EAAE,2BAA2B,EAAE,MAAM,8BAA8B,CAAA;AAE1E,eAAe,CAAC;IACd,IAAI,EAAE,SAAS;IACf,cAAc,EAAE,MAAM,CAAC,IAAI,CAAC,QAAQ;IACpC,KAAK,EAAE,oBAAoB;IAC3B,KAAK,EAAE,CAAC,qBAAqB,EAAE,2BAA2B,CAAC;CAC5D,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geocoding.d.ts","sourceRoot":"","sources":["../../src/tools/geocoding.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AAExE,eAAO,MAAM,qBAAqB,GAAI,QAAQ,SAAS,SA8DnD,CAAA"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { registerTool } from '@mcp-monorepo/shared';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
export const registerGeocodingTool = (server) => registerTool(server, {
|
|
4
|
+
name: 'geocoding',
|
|
5
|
+
title: 'Get Location Coordinates',
|
|
6
|
+
description: 'Finds the latitude and longitude for a named place (city, town, or landmark) via Open-Meteo geocoding API. Returns results for ambiguous names.',
|
|
7
|
+
inputSchema: {
|
|
8
|
+
name: z.string().min(1, 'Location name required').describe('Name of a city or location'),
|
|
9
|
+
},
|
|
10
|
+
outputSchema: {
|
|
11
|
+
locations: z.array(z.object({
|
|
12
|
+
id: z.number(),
|
|
13
|
+
name: z.string(),
|
|
14
|
+
latitude: z.number(),
|
|
15
|
+
longitude: z.number(),
|
|
16
|
+
elevation: z.number(),
|
|
17
|
+
country_code: z.string(),
|
|
18
|
+
timezone: z.string(),
|
|
19
|
+
country: z.string(),
|
|
20
|
+
admin: z.array(z.string()),
|
|
21
|
+
})),
|
|
22
|
+
},
|
|
23
|
+
isReadOnly: true,
|
|
24
|
+
async fetcher({ name }) {
|
|
25
|
+
const trimmedName = name?.trim();
|
|
26
|
+
if (!trimmedName) {
|
|
27
|
+
throw new Error('Location name cannot be empty');
|
|
28
|
+
}
|
|
29
|
+
const encodedName = encodeURIComponent(name);
|
|
30
|
+
const url = `https://geocoding-api.open-meteo.com/v1/search?name=${encodedName}&count=10&language=en&format=json`;
|
|
31
|
+
const response = await fetch(url);
|
|
32
|
+
if (!response.ok) {
|
|
33
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
34
|
+
}
|
|
35
|
+
return (await response.json());
|
|
36
|
+
},
|
|
37
|
+
formatter(data) {
|
|
38
|
+
const locations = data.results?.map((result) => {
|
|
39
|
+
const admin = [];
|
|
40
|
+
if (result.admin1)
|
|
41
|
+
admin.push(result.admin1);
|
|
42
|
+
if (result.admin2)
|
|
43
|
+
admin.push(result.admin2);
|
|
44
|
+
if (result.admin3)
|
|
45
|
+
admin.push(result.admin3);
|
|
46
|
+
if (result.admin4)
|
|
47
|
+
admin.push(result.admin4);
|
|
48
|
+
return {
|
|
49
|
+
id: result.id,
|
|
50
|
+
name: result.name,
|
|
51
|
+
latitude: result.latitude,
|
|
52
|
+
longitude: result.longitude,
|
|
53
|
+
elevation: result.elevation,
|
|
54
|
+
country_code: result.country_code,
|
|
55
|
+
timezone: result.timezone,
|
|
56
|
+
country: result.country,
|
|
57
|
+
admin,
|
|
58
|
+
};
|
|
59
|
+
}) ?? [];
|
|
60
|
+
return { locations };
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
//# sourceMappingURL=geocoding.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geocoding.js","sourceRoot":"","sources":["../../src/tools/geocoding.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,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1,25 @@
|
|
|
1
|
+
export interface GeocodingApiResponse {
|
|
2
|
+
results?: GeocodingResult[];
|
|
3
|
+
generationtime_ms?: number;
|
|
4
|
+
}
|
|
5
|
+
export interface GeocodingResult {
|
|
6
|
+
id: number;
|
|
7
|
+
name: string;
|
|
8
|
+
latitude: number;
|
|
9
|
+
longitude: number;
|
|
10
|
+
elevation: number;
|
|
11
|
+
feature_code?: string;
|
|
12
|
+
country_code: string;
|
|
13
|
+
admin1_id?: number;
|
|
14
|
+
admin2_id?: number;
|
|
15
|
+
admin3_id?: number;
|
|
16
|
+
admin4_id?: number;
|
|
17
|
+
timezone: string;
|
|
18
|
+
country_id?: number;
|
|
19
|
+
country: string;
|
|
20
|
+
admin1?: string;
|
|
21
|
+
admin2?: string;
|
|
22
|
+
admin3?: string;
|
|
23
|
+
admin4?: string;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=geocoding.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geocoding.types.d.ts","sourceRoot":"","sources":["../../src/tools/geocoding.types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,oBAAoB;IACnC,OAAO,CAAC,EAAE,eAAe,EAAE,CAAA;IAC3B,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAC3B;AAED,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;IACjB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,YAAY,EAAE,MAAM,CAAA;IACpB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,MAAM,CAAA;IAChB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geocoding.types.js","sourceRoot":"","sources":["../../src/tools/geocoding.types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { type SchemaTypeOf } from '@mcp-monorepo/shared';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
4
|
+
declare const OutputSchemaDef: {
|
|
5
|
+
location: z.ZodObject<{
|
|
6
|
+
timezone: z.ZodString;
|
|
7
|
+
timezone_abbreviation: z.ZodString;
|
|
8
|
+
elevation: z.ZodString;
|
|
9
|
+
}, "strip", z.ZodTypeAny, {
|
|
10
|
+
elevation: string;
|
|
11
|
+
timezone: string;
|
|
12
|
+
timezone_abbreviation: string;
|
|
13
|
+
}, {
|
|
14
|
+
elevation: string;
|
|
15
|
+
timezone: string;
|
|
16
|
+
timezone_abbreviation: string;
|
|
17
|
+
}>;
|
|
18
|
+
hourly: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
19
|
+
temp: z.ZodString;
|
|
20
|
+
wind: z.ZodString;
|
|
21
|
+
precip: z.ZodString;
|
|
22
|
+
precip_prop: z.ZodString;
|
|
23
|
+
temp_apparent: z.ZodString;
|
|
24
|
+
dew_point: z.ZodString;
|
|
25
|
+
}, "strip", z.ZodTypeAny, {
|
|
26
|
+
temp: string;
|
|
27
|
+
wind: string;
|
|
28
|
+
precip: string;
|
|
29
|
+
precip_prop: string;
|
|
30
|
+
temp_apparent: string;
|
|
31
|
+
dew_point: string;
|
|
32
|
+
}, {
|
|
33
|
+
temp: string;
|
|
34
|
+
wind: string;
|
|
35
|
+
precip: string;
|
|
36
|
+
precip_prop: string;
|
|
37
|
+
temp_apparent: string;
|
|
38
|
+
dew_point: string;
|
|
39
|
+
}>>;
|
|
40
|
+
daily: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
41
|
+
sunrise: z.ZodString;
|
|
42
|
+
sunset: z.ZodString;
|
|
43
|
+
temp_max: z.ZodString;
|
|
44
|
+
temp_min: z.ZodString;
|
|
45
|
+
precip_sum: z.ZodString;
|
|
46
|
+
precip_prop: z.ZodString;
|
|
47
|
+
sunshine: z.ZodString;
|
|
48
|
+
}, "strip", z.ZodTypeAny, {
|
|
49
|
+
precip_prop: string;
|
|
50
|
+
sunrise: string;
|
|
51
|
+
sunset: string;
|
|
52
|
+
temp_max: string;
|
|
53
|
+
temp_min: string;
|
|
54
|
+
precip_sum: string;
|
|
55
|
+
sunshine: string;
|
|
56
|
+
}, {
|
|
57
|
+
precip_prop: string;
|
|
58
|
+
sunrise: string;
|
|
59
|
+
sunset: string;
|
|
60
|
+
temp_max: string;
|
|
61
|
+
temp_min: string;
|
|
62
|
+
precip_sum: string;
|
|
63
|
+
sunshine: string;
|
|
64
|
+
}>>;
|
|
65
|
+
};
|
|
66
|
+
export type ProcessedWeatherData = SchemaTypeOf<typeof OutputSchemaDef>;
|
|
67
|
+
export declare const registerWeatherByCoordsTool: (server: McpServer) => void;
|
|
68
|
+
export {};
|
|
69
|
+
//# sourceMappingURL=weather-by-coords.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"weather-by-coords.d.ts","sourceRoot":"","sources":["../../src/tools/weather-by-coords.ts"],"names":[],"mappings":"AACA,OAAO,EAAgB,KAAK,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACtE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AAExE,QAAA,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2BpB,CAAA;AAED,MAAM,MAAM,oBAAoB,GAAG,YAAY,CAAC,OAAO,eAAe,CAAC,CAAA;AAEvE,eAAO,MAAM,2BAA2B,GAAI,QAAQ,SAAS,SA0EzD,CAAA"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
// MCP tool registration for weather-by-coords
|
|
2
|
+
import { registerTool } from '@mcp-monorepo/shared';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
const OutputSchemaDef = {
|
|
5
|
+
location: z.object({
|
|
6
|
+
timezone: z.string(),
|
|
7
|
+
timezone_abbreviation: z.string(),
|
|
8
|
+
elevation: z.string(),
|
|
9
|
+
}),
|
|
10
|
+
hourly: z.record(z.object({
|
|
11
|
+
temp: z.string(),
|
|
12
|
+
wind: z.string(),
|
|
13
|
+
precip: z.string(),
|
|
14
|
+
precip_prop: z.string(),
|
|
15
|
+
temp_apparent: z.string(),
|
|
16
|
+
dew_point: z.string(),
|
|
17
|
+
})),
|
|
18
|
+
daily: z.record(z.object({
|
|
19
|
+
sunrise: z.string(),
|
|
20
|
+
sunset: z.string(),
|
|
21
|
+
temp_max: z.string(),
|
|
22
|
+
temp_min: z.string(),
|
|
23
|
+
precip_sum: z.string(),
|
|
24
|
+
precip_prop: z.string(),
|
|
25
|
+
sunshine: z.string(),
|
|
26
|
+
})),
|
|
27
|
+
};
|
|
28
|
+
export const registerWeatherByCoordsTool = (server) => registerTool(server, {
|
|
29
|
+
name: 'weather-by-coords',
|
|
30
|
+
title: 'Get Weather by Coordinates',
|
|
31
|
+
description: 'Fetches multi-day and multi-hour weather forecast for a location (lat/lon) using Open-Meteo.',
|
|
32
|
+
inputSchema: {
|
|
33
|
+
latitude: z.number().min(-90).max(90).describe('Latitude, -90 to 90'),
|
|
34
|
+
longitude: z.number().min(-180).max(180).describe('Longitude, -180 to 180'),
|
|
35
|
+
},
|
|
36
|
+
outputSchema: OutputSchemaDef,
|
|
37
|
+
isReadOnly: true,
|
|
38
|
+
async fetcher({ latitude, longitude }) {
|
|
39
|
+
const params = {
|
|
40
|
+
latitude: latitude.toString(),
|
|
41
|
+
longitude: longitude.toString(),
|
|
42
|
+
daily: 'sunrise,sunset,temperature_2m_max,precipitation_probability_max,precipitation_sum,sunshine_duration,temperature_2m_min',
|
|
43
|
+
hourly: 'temperature_2m,wind_speed_10m,precipitation_probability,precipitation,apparent_temperature,dew_point_2m',
|
|
44
|
+
timezone: 'auto',
|
|
45
|
+
forecast_hours: '24',
|
|
46
|
+
forecast_days: '10',
|
|
47
|
+
};
|
|
48
|
+
const url = new URL('https://api.open-meteo.com/v1/forecast');
|
|
49
|
+
Object.entries(params).forEach(([key, value]) => {
|
|
50
|
+
url.searchParams.set(key, value);
|
|
51
|
+
});
|
|
52
|
+
const response = await fetch(url.toString());
|
|
53
|
+
if (!response.ok) {
|
|
54
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
55
|
+
}
|
|
56
|
+
return (await response.json());
|
|
57
|
+
},
|
|
58
|
+
formatter(data) {
|
|
59
|
+
const hourly = {};
|
|
60
|
+
data.hourly.time.forEach((time, i) => {
|
|
61
|
+
hourly[time] = {
|
|
62
|
+
temp: `${data.hourly.temperature_2m[i]}${data.hourly_units.temperature_2m}`,
|
|
63
|
+
wind: `${data.hourly.wind_speed_10m[i]}${data.hourly_units.wind_speed_10m}`,
|
|
64
|
+
precip: `${data.hourly.precipitation?.[i] ?? 0}${data.hourly_units.precipitation}`,
|
|
65
|
+
precip_prop: `${data.hourly.precipitation_probability?.[i] ?? 0}${data.hourly_units.precipitation_probability}`,
|
|
66
|
+
temp_apparent: `${data.hourly.apparent_temperature[i]}${data.hourly_units.apparent_temperature}`,
|
|
67
|
+
dew_point: `${data.hourly.dew_point_2m[i]}${data.hourly_units.dew_point_2m}`,
|
|
68
|
+
};
|
|
69
|
+
});
|
|
70
|
+
const daily = {};
|
|
71
|
+
data.daily.time.forEach((date, i) => {
|
|
72
|
+
const sunriseTime = data.daily.sunrise[i]?.split('T')[1] || data.daily.sunrise[i] || '';
|
|
73
|
+
const sunsetTime = data.daily.sunset[i]?.split('T')[1] || data.daily.sunset[i] || '';
|
|
74
|
+
const sunshineDuration = formatSunshineDuration(data.daily.sunshine_duration?.[i] ?? 0);
|
|
75
|
+
daily[date] = {
|
|
76
|
+
sunrise: sunriseTime,
|
|
77
|
+
sunset: sunsetTime,
|
|
78
|
+
temp_max: `${data.daily.temperature_2m_max[i]}${data.daily_units.temperature_2m_max}`,
|
|
79
|
+
temp_min: `${data.daily.temperature_2m_min[i]}${data.daily_units.temperature_2m_min}`,
|
|
80
|
+
precip_sum: `${data.daily.precipitation_sum?.[i] ?? 0}${data.daily_units.precipitation_sum}`,
|
|
81
|
+
precip_prop: `${data.daily.precipitation_probability_max?.[i] ?? 0}${data.daily_units.precipitation_probability_max}`,
|
|
82
|
+
sunshine: sunshineDuration,
|
|
83
|
+
};
|
|
84
|
+
});
|
|
85
|
+
return {
|
|
86
|
+
location: {
|
|
87
|
+
timezone: data.timezone,
|
|
88
|
+
timezone_abbreviation: data.timezone_abbreviation,
|
|
89
|
+
elevation: `${data.elevation}m`,
|
|
90
|
+
},
|
|
91
|
+
hourly,
|
|
92
|
+
daily,
|
|
93
|
+
};
|
|
94
|
+
},
|
|
95
|
+
});
|
|
96
|
+
const formatSunshineDuration = (seconds) => {
|
|
97
|
+
const hours = Math.floor(seconds / 3600);
|
|
98
|
+
const minutes = Math.floor((seconds % 3600) / 60);
|
|
99
|
+
if (hours === 0)
|
|
100
|
+
return `${minutes}m`;
|
|
101
|
+
if (minutes === 0)
|
|
102
|
+
return `${hours}h`;
|
|
103
|
+
return `${hours}h ${minutes}m`;
|
|
104
|
+
};
|
|
105
|
+
//# sourceMappingURL=weather-by-coords.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"weather-by-coords.js","sourceRoot":"","sources":["../../src/tools/weather-by-coords.ts"],"names":[],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CAAA;IACH,CAAC;CACF,CAAC,CAAA;AAEJ,MAAM,sBAAsB,GAAG,CAAC,OAAe,EAAU,EAAE;IACzD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC,CAAA;IACxC,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,CAAA;IACjD,IAAI,KAAK,KAAK,CAAC;QAAE,OAAO,GAAG,OAAO,GAAG,CAAA;IACrC,IAAI,OAAO,KAAK,CAAC;QAAE,OAAO,GAAG,KAAK,GAAG,CAAA;IACrC,OAAO,GAAG,KAAK,KAAK,OAAO,GAAG,CAAA;AAChC,CAAC,CAAA"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export interface WeatherApiResponse {
|
|
2
|
+
latitude: number;
|
|
3
|
+
longitude: number;
|
|
4
|
+
generationtime_ms: number;
|
|
5
|
+
utc_offset_seconds: number;
|
|
6
|
+
timezone: string;
|
|
7
|
+
timezone_abbreviation: string;
|
|
8
|
+
elevation: number;
|
|
9
|
+
hourly_units: {
|
|
10
|
+
time: string;
|
|
11
|
+
temperature_2m: string;
|
|
12
|
+
wind_speed_10m: string;
|
|
13
|
+
precipitation_probability: string;
|
|
14
|
+
precipitation: string;
|
|
15
|
+
apparent_temperature: string;
|
|
16
|
+
dew_point_2m: string;
|
|
17
|
+
};
|
|
18
|
+
hourly: {
|
|
19
|
+
time: string[];
|
|
20
|
+
temperature_2m: number[];
|
|
21
|
+
wind_speed_10m: number[];
|
|
22
|
+
precipitation_probability: number[];
|
|
23
|
+
precipitation: number[];
|
|
24
|
+
apparent_temperature: number[];
|
|
25
|
+
dew_point_2m: number[];
|
|
26
|
+
};
|
|
27
|
+
daily_units: {
|
|
28
|
+
time: string;
|
|
29
|
+
sunrise: string;
|
|
30
|
+
sunset: string;
|
|
31
|
+
temperature_2m_max: string;
|
|
32
|
+
precipitation_probability_max: string;
|
|
33
|
+
precipitation_sum: string;
|
|
34
|
+
sunshine_duration: string;
|
|
35
|
+
temperature_2m_min: string;
|
|
36
|
+
};
|
|
37
|
+
daily: {
|
|
38
|
+
time: string[];
|
|
39
|
+
sunrise: string[];
|
|
40
|
+
sunset: string[];
|
|
41
|
+
temperature_2m_max: number[];
|
|
42
|
+
precipitation_probability_max: number[];
|
|
43
|
+
precipitation_sum: number[];
|
|
44
|
+
sunshine_duration: number[];
|
|
45
|
+
temperature_2m_min: number[];
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=weather-by-coords.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"weather-by-coords.types.d.ts","sourceRoot":"","sources":["../../src/tools/weather-by-coords.types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;IACjB,iBAAiB,EAAE,MAAM,CAAA;IACzB,kBAAkB,EAAE,MAAM,CAAA;IAC1B,QAAQ,EAAE,MAAM,CAAA;IAChB,qBAAqB,EAAE,MAAM,CAAA;IAC7B,SAAS,EAAE,MAAM,CAAA;IACjB,YAAY,EAAE;QACZ,IAAI,EAAE,MAAM,CAAA;QACZ,cAAc,EAAE,MAAM,CAAA;QACtB,cAAc,EAAE,MAAM,CAAA;QACtB,yBAAyB,EAAE,MAAM,CAAA;QACjC,aAAa,EAAE,MAAM,CAAA;QACrB,oBAAoB,EAAE,MAAM,CAAA;QAC5B,YAAY,EAAE,MAAM,CAAA;KACrB,CAAA;IACD,MAAM,EAAE;QACN,IAAI,EAAE,MAAM,EAAE,CAAA;QACd,cAAc,EAAE,MAAM,EAAE,CAAA;QACxB,cAAc,EAAE,MAAM,EAAE,CAAA;QACxB,yBAAyB,EAAE,MAAM,EAAE,CAAA;QACnC,aAAa,EAAE,MAAM,EAAE,CAAA;QACvB,oBAAoB,EAAE,MAAM,EAAE,CAAA;QAC9B,YAAY,EAAE,MAAM,EAAE,CAAA;KACvB,CAAA;IACD,WAAW,EAAE;QACX,IAAI,EAAE,MAAM,CAAA;QACZ,OAAO,EAAE,MAAM,CAAA;QACf,MAAM,EAAE,MAAM,CAAA;QACd,kBAAkB,EAAE,MAAM,CAAA;QAC1B,6BAA6B,EAAE,MAAM,CAAA;QACrC,iBAAiB,EAAE,MAAM,CAAA;QACzB,iBAAiB,EAAE,MAAM,CAAA;QACzB,kBAAkB,EAAE,MAAM,CAAA;KAC3B,CAAA;IACD,KAAK,EAAE;QACL,IAAI,EAAE,MAAM,EAAE,CAAA;QACd,OAAO,EAAE,MAAM,EAAE,CAAA;QACjB,MAAM,EAAE,MAAM,EAAE,CAAA;QAChB,kBAAkB,EAAE,MAAM,EAAE,CAAA;QAC5B,6BAA6B,EAAE,MAAM,EAAE,CAAA;QACvC,iBAAiB,EAAE,MAAM,EAAE,CAAA;QAC3B,iBAAiB,EAAE,MAAM,EAAE,CAAA;QAC3B,kBAAkB,EAAE,MAAM,EAAE,CAAA;KAC7B,CAAA;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"weather-by-coords.types.js","sourceRoot":"","sources":["../../src/tools/weather-by-coords.types.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mcp-monorepo/weather",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Weather MCP tools (geocoding, weather-by-coords) for ModelContextProtocol.",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"bin": {
|
|
9
|
+
"mcp-npm-server": "./dist/index.js"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"dist"
|
|
13
|
+
],
|
|
14
|
+
"publishConfig": {
|
|
15
|
+
"access": "public"
|
|
16
|
+
},
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "tsc -b",
|
|
19
|
+
"dev": "tsc --watch",
|
|
20
|
+
"start": "node dist/index.js",
|
|
21
|
+
"test": "vitest run --passWithNoTests",
|
|
22
|
+
"test:watch": "vitest",
|
|
23
|
+
"test:coverage": "vitest run --coverage",
|
|
24
|
+
"typecheck": "tsc --noEmit",
|
|
25
|
+
"clean": "rimraf dist tsconfig.tsbuildinfo"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@modelcontextprotocol/sdk": "^1.0.0",
|
|
29
|
+
"zod": "^3.25.76",
|
|
30
|
+
"@mcp-monorepo/shared": "*"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@types/node": "^22.14.1",
|
|
34
|
+
"typescript": "^5.8.3",
|
|
35
|
+
"vitest": "^3.2.4",
|
|
36
|
+
"rimraf": "^6.0.1"
|
|
37
|
+
}
|
|
38
|
+
}
|