weather-agent-mcp 0.1.7 → 0.1.8
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/README.md +1 -1
- package/dist/weather-mcp.js +157 -112
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -70,7 +70,7 @@ Reload MCP. Tools: `geocode`, `getCurrentWeather`, `getForecast`, `getHistorical
|
|
|
70
70
|
|
|
71
71
|
1. Войдите в [Кабинет разработчика](https://developer.tech.yandex.ru/) с Яндекс ID.
|
|
72
72
|
2. Нажмите «Подключить API» и выберите «JavaScript API и HTTP Геокодер».
|
|
73
|
-
3. Заполните форму. Ключ появится в разделе «Ключи». Он начинает отвечать примерно через 15
|
|
73
|
+
3. Заполните форму. Ключ появится в разделе «Ключи». Он начинает отвечать примерно через 15 минут. Запрос идёт на `https://geocode-maps.yandex.ru/v1/` ([формат запроса](https://yandex.ru/dev/geocode/doc/ru/request)).
|
|
74
74
|
|
|
75
75
|
**`YANDEX_WEATHER_API_KEY`** — API Яндекс Погоды.
|
|
76
76
|
|
package/dist/weather-mcp.js
CHANGED
|
@@ -173,7 +173,7 @@ var init_http = __esm({
|
|
|
173
173
|
}
|
|
174
174
|
});
|
|
175
175
|
|
|
176
|
-
// src/weather/open-meteo
|
|
176
|
+
// src/weather/open-meteo/client.ts
|
|
177
177
|
function defaultConfig(overrides = {}) {
|
|
178
178
|
return {
|
|
179
179
|
forecastBaseUrl: process.env.OPEN_METEO_FORECAST_URL ?? "https://api.open-meteo.com",
|
|
@@ -207,14 +207,52 @@ async function meteoGet(baseUrl, path, params, config2) {
|
|
|
207
207
|
}
|
|
208
208
|
return res.data;
|
|
209
209
|
}
|
|
210
|
-
var
|
|
211
|
-
"src/weather/open-meteo
|
|
210
|
+
var init_client = __esm({
|
|
211
|
+
"src/weather/open-meteo/client.ts"() {
|
|
212
212
|
"use strict";
|
|
213
213
|
init_http();
|
|
214
214
|
init_errors();
|
|
215
215
|
}
|
|
216
216
|
});
|
|
217
217
|
|
|
218
|
+
// src/weather/open-meteo/geocode.ts
|
|
219
|
+
var geocode_exports = {};
|
|
220
|
+
__export(geocode_exports, {
|
|
221
|
+
geocodeOpenMeteo: () => geocodeOpenMeteo
|
|
222
|
+
});
|
|
223
|
+
async function geocodeOpenMeteo(city, config2 = {}) {
|
|
224
|
+
const cfg = defaultConfig(config2);
|
|
225
|
+
const data = await meteoGet(
|
|
226
|
+
cfg.geocodingBaseUrl,
|
|
227
|
+
"/v1/search",
|
|
228
|
+
{ name: city, count: 5, language: "en", format: "json" },
|
|
229
|
+
cfg
|
|
230
|
+
);
|
|
231
|
+
if (!data.results || data.results.length === 0) {
|
|
232
|
+
throw new ToolError("CITY_NOT_FOUND", `No location found for city: ${city}`, false, { city });
|
|
233
|
+
}
|
|
234
|
+
const sorted = [...data.results].sort(
|
|
235
|
+
(a, b) => (b.population ?? 0) - (a.population ?? 0)
|
|
236
|
+
);
|
|
237
|
+
const best = sorted[0];
|
|
238
|
+
return {
|
|
239
|
+
name: best.name,
|
|
240
|
+
latitude: best.latitude,
|
|
241
|
+
longitude: best.longitude,
|
|
242
|
+
country: best.country ?? best.country_code ?? "Unknown",
|
|
243
|
+
admin1: best.admin1,
|
|
244
|
+
population: best.population,
|
|
245
|
+
timezone: best.timezone
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
var init_geocode = __esm({
|
|
249
|
+
"src/weather/open-meteo/geocode.ts"() {
|
|
250
|
+
"use strict";
|
|
251
|
+
init_errors();
|
|
252
|
+
init_client();
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
|
|
218
256
|
// src/weather/wmo-codes.ts
|
|
219
257
|
function describeWmo(code) {
|
|
220
258
|
return WMO[code] ?? `Unknown weather code ${code}`;
|
|
@@ -249,7 +287,11 @@ var init_wmo_codes = __esm({
|
|
|
249
287
|
}
|
|
250
288
|
});
|
|
251
289
|
|
|
252
|
-
// src/weather/current.ts
|
|
290
|
+
// src/weather/open-meteo/current.ts
|
|
291
|
+
var current_exports = {};
|
|
292
|
+
__export(current_exports, {
|
|
293
|
+
getCurrentWeatherOpenMeteo: () => getCurrentWeatherOpenMeteo
|
|
294
|
+
});
|
|
253
295
|
async function getCurrentWeatherOpenMeteo(latitude, longitude, config2 = {}) {
|
|
254
296
|
const cfg = defaultConfig(config2);
|
|
255
297
|
const data = await meteoGet(
|
|
@@ -277,16 +319,11 @@ async function getCurrentWeatherOpenMeteo(latitude, longitude, config2 = {}) {
|
|
|
277
319
|
observedAt: c.time
|
|
278
320
|
};
|
|
279
321
|
}
|
|
280
|
-
async function getCurrentWeather(latitude, longitude, config2) {
|
|
281
|
-
if (config2) return getCurrentWeatherOpenMeteo(latitude, longitude, config2);
|
|
282
|
-
const { createWeatherUpstream: createWeatherUpstream2 } = await Promise.resolve().then(() => (init_upstream(), upstream_exports));
|
|
283
|
-
return createWeatherUpstream2().getCurrentWeather(latitude, longitude);
|
|
284
|
-
}
|
|
285
322
|
var init_current = __esm({
|
|
286
|
-
"src/weather/current.ts"() {
|
|
323
|
+
"src/weather/open-meteo/current.ts"() {
|
|
287
324
|
"use strict";
|
|
288
325
|
init_wmo_codes();
|
|
289
|
-
|
|
326
|
+
init_client();
|
|
290
327
|
}
|
|
291
328
|
});
|
|
292
329
|
|
|
@@ -320,6 +357,28 @@ function isValidCalendarDate(iso) {
|
|
|
320
357
|
const dt = new Date(Date.UTC(y, m - 1, d));
|
|
321
358
|
return dt.getUTCFullYear() === y && dt.getUTCMonth() === m - 1 && dt.getUTCDate() === d;
|
|
322
359
|
}
|
|
360
|
+
async function getForecast(latitude, longitude, startDate, endDate, config2) {
|
|
361
|
+
if (config2) {
|
|
362
|
+
const { getForecastOpenMeteo: getForecastOpenMeteo2 } = await Promise.resolve().then(() => (init_forecast2(), forecast_exports));
|
|
363
|
+
return getForecastOpenMeteo2(latitude, longitude, startDate, endDate, config2);
|
|
364
|
+
}
|
|
365
|
+
const { createWeatherUpstream: createWeatherUpstream2 } = await Promise.resolve().then(() => (init_upstream3(), upstream_exports));
|
|
366
|
+
return createWeatherUpstream2().getForecast(latitude, longitude, startDate, endDate);
|
|
367
|
+
}
|
|
368
|
+
var DATE_RE;
|
|
369
|
+
var init_forecast = __esm({
|
|
370
|
+
"src/weather/forecast.ts"() {
|
|
371
|
+
"use strict";
|
|
372
|
+
init_errors();
|
|
373
|
+
DATE_RE = /^\d{4}-\d{2}-\d{2}$/;
|
|
374
|
+
}
|
|
375
|
+
});
|
|
376
|
+
|
|
377
|
+
// src/weather/open-meteo/forecast.ts
|
|
378
|
+
var forecast_exports = {};
|
|
379
|
+
__export(forecast_exports, {
|
|
380
|
+
getForecastOpenMeteo: () => getForecastOpenMeteo
|
|
381
|
+
});
|
|
323
382
|
async function getForecastOpenMeteo(latitude, longitude, startDate, endDate, config2 = {}) {
|
|
324
383
|
assertDateRange(startDate, endDate);
|
|
325
384
|
const cfg = defaultConfig(config2);
|
|
@@ -354,19 +413,12 @@ async function getForecastOpenMeteo(latitude, longitude, startDate, endDate, con
|
|
|
354
413
|
days
|
|
355
414
|
};
|
|
356
415
|
}
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
const { createWeatherUpstream: createWeatherUpstream2 } = await Promise.resolve().then(() => (init_upstream(), upstream_exports));
|
|
360
|
-
return createWeatherUpstream2().getForecast(latitude, longitude, startDate, endDate);
|
|
361
|
-
}
|
|
362
|
-
var DATE_RE;
|
|
363
|
-
var init_forecast = __esm({
|
|
364
|
-
"src/weather/forecast.ts"() {
|
|
416
|
+
var init_forecast2 = __esm({
|
|
417
|
+
"src/weather/open-meteo/forecast.ts"() {
|
|
365
418
|
"use strict";
|
|
366
|
-
|
|
419
|
+
init_forecast();
|
|
367
420
|
init_wmo_codes();
|
|
368
|
-
|
|
369
|
-
DATE_RE = /^\d{4}-\d{2}-\d{2}$/;
|
|
421
|
+
init_client();
|
|
370
422
|
}
|
|
371
423
|
});
|
|
372
424
|
|
|
@@ -421,6 +473,45 @@ function assertHistoricalSpan(month, day, startYear, endYear) {
|
|
|
421
473
|
);
|
|
422
474
|
}
|
|
423
475
|
}
|
|
476
|
+
async function getHistoricalWeather(latitude, longitude, month, day, startYear, endYear, config2) {
|
|
477
|
+
if (config2) {
|
|
478
|
+
const { getHistoricalWeatherOpenMeteo: getHistoricalWeatherOpenMeteo2 } = await Promise.resolve().then(() => (init_history2(), history_exports));
|
|
479
|
+
return getHistoricalWeatherOpenMeteo2(
|
|
480
|
+
latitude,
|
|
481
|
+
longitude,
|
|
482
|
+
month,
|
|
483
|
+
day,
|
|
484
|
+
startYear,
|
|
485
|
+
endYear,
|
|
486
|
+
config2
|
|
487
|
+
);
|
|
488
|
+
}
|
|
489
|
+
const { createWeatherUpstream: createWeatherUpstream2 } = await Promise.resolve().then(() => (init_upstream3(), upstream_exports));
|
|
490
|
+
return createWeatherUpstream2().getHistoricalWeather(
|
|
491
|
+
latitude,
|
|
492
|
+
longitude,
|
|
493
|
+
month,
|
|
494
|
+
day,
|
|
495
|
+
startYear,
|
|
496
|
+
endYear
|
|
497
|
+
);
|
|
498
|
+
}
|
|
499
|
+
var MAX_HISTORICAL_YEARS, ARCHIVE_FIRST_YEAR, DAYS_IN_MONTH;
|
|
500
|
+
var init_history = __esm({
|
|
501
|
+
"src/weather/history.ts"() {
|
|
502
|
+
"use strict";
|
|
503
|
+
init_errors();
|
|
504
|
+
MAX_HISTORICAL_YEARS = 20;
|
|
505
|
+
ARCHIVE_FIRST_YEAR = 1940;
|
|
506
|
+
DAYS_IN_MONTH = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
507
|
+
}
|
|
508
|
+
});
|
|
509
|
+
|
|
510
|
+
// src/weather/open-meteo/history.ts
|
|
511
|
+
var history_exports = {};
|
|
512
|
+
__export(history_exports, {
|
|
513
|
+
getHistoricalWeatherOpenMeteo: () => getHistoricalWeatherOpenMeteo
|
|
514
|
+
});
|
|
424
515
|
function isoDate(year, month, day) {
|
|
425
516
|
const m = String(month).padStart(2, "0");
|
|
426
517
|
const d = String(day).padStart(2, "0");
|
|
@@ -556,42 +647,17 @@ async function getHistoricalWeatherOpenMeteo(latitude, longitude, month, day, st
|
|
|
556
647
|
summary: summarize(rows)
|
|
557
648
|
};
|
|
558
649
|
}
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
return getHistoricalWeatherOpenMeteo(
|
|
562
|
-
latitude,
|
|
563
|
-
longitude,
|
|
564
|
-
month,
|
|
565
|
-
day,
|
|
566
|
-
startYear,
|
|
567
|
-
endYear,
|
|
568
|
-
config2
|
|
569
|
-
);
|
|
570
|
-
}
|
|
571
|
-
const { createWeatherUpstream: createWeatherUpstream2 } = await Promise.resolve().then(() => (init_upstream(), upstream_exports));
|
|
572
|
-
return createWeatherUpstream2().getHistoricalWeather(
|
|
573
|
-
latitude,
|
|
574
|
-
longitude,
|
|
575
|
-
month,
|
|
576
|
-
day,
|
|
577
|
-
startYear,
|
|
578
|
-
endYear
|
|
579
|
-
);
|
|
580
|
-
}
|
|
581
|
-
var MAX_HISTORICAL_YEARS, ARCHIVE_FIRST_YEAR, DAYS_IN_MONTH;
|
|
582
|
-
var init_history = __esm({
|
|
583
|
-
"src/weather/history.ts"() {
|
|
650
|
+
var init_history2 = __esm({
|
|
651
|
+
"src/weather/open-meteo/history.ts"() {
|
|
584
652
|
"use strict";
|
|
585
653
|
init_errors();
|
|
654
|
+
init_history();
|
|
586
655
|
init_wmo_codes();
|
|
587
|
-
|
|
588
|
-
MAX_HISTORICAL_YEARS = 20;
|
|
589
|
-
ARCHIVE_FIRST_YEAR = 1940;
|
|
590
|
-
DAYS_IN_MONTH = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
656
|
+
init_client();
|
|
591
657
|
}
|
|
592
658
|
});
|
|
593
659
|
|
|
594
|
-
// src/weather/open-meteo
|
|
660
|
+
// src/weather/open-meteo/upstream.ts
|
|
595
661
|
function createOpenMeteoUpstream() {
|
|
596
662
|
return {
|
|
597
663
|
name: "open-meteo",
|
|
@@ -616,17 +682,17 @@ function createOpenMeteoUpstream() {
|
|
|
616
682
|
}
|
|
617
683
|
};
|
|
618
684
|
}
|
|
619
|
-
var
|
|
620
|
-
"src/weather/open-meteo
|
|
685
|
+
var init_upstream = __esm({
|
|
686
|
+
"src/weather/open-meteo/upstream.ts"() {
|
|
621
687
|
"use strict";
|
|
622
688
|
init_current();
|
|
623
|
-
|
|
689
|
+
init_forecast2();
|
|
624
690
|
init_geocode();
|
|
625
|
-
|
|
691
|
+
init_history2();
|
|
626
692
|
}
|
|
627
693
|
});
|
|
628
694
|
|
|
629
|
-
// src/weather/yandex
|
|
695
|
+
// src/weather/yandex/map.ts
|
|
630
696
|
function conditionToWmo(condition) {
|
|
631
697
|
if (!condition) return 2;
|
|
632
698
|
return CONDITION_WMO[condition] ?? 2;
|
|
@@ -717,8 +783,8 @@ function mapYandexForecast(latitude, longitude, startDate, endDate, body) {
|
|
|
717
783
|
};
|
|
718
784
|
}
|
|
719
785
|
var CONDITION_WMO;
|
|
720
|
-
var
|
|
721
|
-
"src/weather/yandex
|
|
786
|
+
var init_map = __esm({
|
|
787
|
+
"src/weather/yandex/map.ts"() {
|
|
722
788
|
"use strict";
|
|
723
789
|
init_errors();
|
|
724
790
|
init_wmo_codes();
|
|
@@ -745,11 +811,11 @@ var init_yandex_map = __esm({
|
|
|
745
811
|
}
|
|
746
812
|
});
|
|
747
813
|
|
|
748
|
-
// src/weather/yandex
|
|
814
|
+
// src/weather/yandex/client.ts
|
|
749
815
|
function yandexEndpoints(env) {
|
|
750
816
|
return {
|
|
751
817
|
weatherUrl: env.YANDEX_WEATHER_URL ?? "https://api.weather.yandex.ru/graphql/query",
|
|
752
|
-
geocoderUrl: env.YANDEX_GEOCODER_URL ?? "https://geocode-maps.yandex.ru/
|
|
818
|
+
geocoderUrl: env.YANDEX_GEOCODER_URL ?? "https://geocode-maps.yandex.ru/v1/",
|
|
753
819
|
weatherKey: env.YANDEX_WEATHER_API_KEY ?? "",
|
|
754
820
|
geocoderKey: env.YANDEX_GEOCODER_API_KEY ?? "",
|
|
755
821
|
timeoutMs: 1e4
|
|
@@ -814,13 +880,13 @@ async function yandexForecast(latitude, longitude, startDate, endDate, endpoints
|
|
|
814
880
|
return mapYandexForecast(latitude, longitude, startDate, endDate, body);
|
|
815
881
|
}
|
|
816
882
|
var WEATHER_QUERY;
|
|
817
|
-
var
|
|
818
|
-
"src/weather/yandex
|
|
883
|
+
var init_client2 = __esm({
|
|
884
|
+
"src/weather/yandex/client.ts"() {
|
|
819
885
|
"use strict";
|
|
820
886
|
init_errors();
|
|
821
887
|
init_http();
|
|
822
888
|
init_forecast();
|
|
823
|
-
|
|
889
|
+
init_map();
|
|
824
890
|
WEATHER_QUERY = `{
|
|
825
891
|
weatherByPoint(request: { lat: $lat, lon: $lon }) {
|
|
826
892
|
now {
|
|
@@ -850,7 +916,7 @@ var init_yandex_client = __esm({
|
|
|
850
916
|
}
|
|
851
917
|
});
|
|
852
918
|
|
|
853
|
-
// src/weather/yandex
|
|
919
|
+
// src/weather/yandex/upstream.ts
|
|
854
920
|
function createYandexUpstream(env) {
|
|
855
921
|
const endpoints = yandexEndpoints(env);
|
|
856
922
|
return {
|
|
@@ -873,11 +939,11 @@ function createYandexUpstream(env) {
|
|
|
873
939
|
}
|
|
874
940
|
};
|
|
875
941
|
}
|
|
876
|
-
var
|
|
877
|
-
"src/weather/yandex
|
|
942
|
+
var init_upstream2 = __esm({
|
|
943
|
+
"src/weather/yandex/upstream.ts"() {
|
|
878
944
|
"use strict";
|
|
879
945
|
init_errors();
|
|
880
|
-
|
|
946
|
+
init_client2();
|
|
881
947
|
}
|
|
882
948
|
});
|
|
883
949
|
|
|
@@ -898,51 +964,12 @@ function createWeatherUpstream(env = process.env) {
|
|
|
898
964
|
if (name === "yandex") return createYandexUpstream(env);
|
|
899
965
|
return createOpenMeteoUpstream();
|
|
900
966
|
}
|
|
901
|
-
var
|
|
967
|
+
var init_upstream3 = __esm({
|
|
902
968
|
"src/weather/upstream.ts"() {
|
|
903
969
|
"use strict";
|
|
904
970
|
init_errors();
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
}
|
|
908
|
-
});
|
|
909
|
-
|
|
910
|
-
// src/weather/geocode.ts
|
|
911
|
-
async function geocodeOpenMeteo(city, config2 = {}) {
|
|
912
|
-
const cfg = defaultConfig(config2);
|
|
913
|
-
const data = await meteoGet(
|
|
914
|
-
cfg.geocodingBaseUrl,
|
|
915
|
-
"/v1/search",
|
|
916
|
-
{ name: city, count: 5, language: "en", format: "json" },
|
|
917
|
-
cfg
|
|
918
|
-
);
|
|
919
|
-
if (!data.results || data.results.length === 0) {
|
|
920
|
-
throw new ToolError("CITY_NOT_FOUND", `No location found for city: ${city}`, false, { city });
|
|
921
|
-
}
|
|
922
|
-
const sorted = [...data.results].sort(
|
|
923
|
-
(a, b) => (b.population ?? 0) - (a.population ?? 0)
|
|
924
|
-
);
|
|
925
|
-
const best = sorted[0];
|
|
926
|
-
return {
|
|
927
|
-
name: best.name,
|
|
928
|
-
latitude: best.latitude,
|
|
929
|
-
longitude: best.longitude,
|
|
930
|
-
country: best.country ?? best.country_code ?? "Unknown",
|
|
931
|
-
admin1: best.admin1,
|
|
932
|
-
population: best.population,
|
|
933
|
-
timezone: best.timezone
|
|
934
|
-
};
|
|
935
|
-
}
|
|
936
|
-
async function geocode(city, config2) {
|
|
937
|
-
if (config2) return geocodeOpenMeteo(city, config2);
|
|
938
|
-
const { createWeatherUpstream: createWeatherUpstream2 } = await Promise.resolve().then(() => (init_upstream(), upstream_exports));
|
|
939
|
-
return createWeatherUpstream2().geocode(city);
|
|
940
|
-
}
|
|
941
|
-
var init_geocode = __esm({
|
|
942
|
-
"src/weather/geocode.ts"() {
|
|
943
|
-
"use strict";
|
|
944
|
-
init_errors();
|
|
945
|
-
init_open_meteo_client();
|
|
971
|
+
init_upstream();
|
|
972
|
+
init_upstream2();
|
|
946
973
|
}
|
|
947
974
|
});
|
|
948
975
|
|
|
@@ -35333,9 +35360,27 @@ function toError(value) {
|
|
|
35333
35360
|
// node_modules/@modelcontextprotocol/server/dist/index.mjs
|
|
35334
35361
|
var DEFAULT_MAX_REQUEST_BODY_SIZE = 4 * 1024 * 1024;
|
|
35335
35362
|
|
|
35363
|
+
// src/weather/geocode.ts
|
|
35364
|
+
async function geocode(city, config2) {
|
|
35365
|
+
if (config2) {
|
|
35366
|
+
const { geocodeOpenMeteo: geocodeOpenMeteo2 } = await Promise.resolve().then(() => (init_geocode(), geocode_exports));
|
|
35367
|
+
return geocodeOpenMeteo2(city, config2);
|
|
35368
|
+
}
|
|
35369
|
+
const { createWeatherUpstream: createWeatherUpstream2 } = await Promise.resolve().then(() => (init_upstream3(), upstream_exports));
|
|
35370
|
+
return createWeatherUpstream2().geocode(city);
|
|
35371
|
+
}
|
|
35372
|
+
|
|
35373
|
+
// src/weather/current.ts
|
|
35374
|
+
async function getCurrentWeather(latitude, longitude, config2) {
|
|
35375
|
+
if (config2) {
|
|
35376
|
+
const { getCurrentWeatherOpenMeteo: getCurrentWeatherOpenMeteo2 } = await Promise.resolve().then(() => (init_current(), current_exports));
|
|
35377
|
+
return getCurrentWeatherOpenMeteo2(latitude, longitude, config2);
|
|
35378
|
+
}
|
|
35379
|
+
const { createWeatherUpstream: createWeatherUpstream2 } = await Promise.resolve().then(() => (init_upstream3(), upstream_exports));
|
|
35380
|
+
return createWeatherUpstream2().getCurrentWeather(latitude, longitude);
|
|
35381
|
+
}
|
|
35382
|
+
|
|
35336
35383
|
// src/weather/index.ts
|
|
35337
|
-
init_geocode();
|
|
35338
|
-
init_current();
|
|
35339
35384
|
init_forecast();
|
|
35340
35385
|
init_history();
|
|
35341
35386
|
|