@cyanheads/noaa-spaceweather-mcp-server 0.1.1

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.
Files changed (49) hide show
  1. package/AGENTS.md +328 -0
  2. package/CLAUDE.md +328 -0
  3. package/Dockerfile +99 -0
  4. package/LICENSE +201 -0
  5. package/README.md +315 -0
  6. package/changelog/0.1.x/0.1.1.md +31 -0
  7. package/changelog/template.md +127 -0
  8. package/dist/index.d.ts +7 -0
  9. package/dist/index.d.ts.map +1 -0
  10. package/dist/index.js +23 -0
  11. package/dist/index.js.map +1 -0
  12. package/dist/mcp-server/tools/definitions/get-alerts.tool.d.ts +37 -0
  13. package/dist/mcp-server/tools/definitions/get-alerts.tool.d.ts.map +1 -0
  14. package/dist/mcp-server/tools/definitions/get-alerts.tool.js +114 -0
  15. package/dist/mcp-server/tools/definitions/get-alerts.tool.js.map +1 -0
  16. package/dist/mcp-server/tools/definitions/get-aurora-forecast.tool.d.ts +37 -0
  17. package/dist/mcp-server/tools/definitions/get-aurora-forecast.tool.d.ts.map +1 -0
  18. package/dist/mcp-server/tools/definitions/get-aurora-forecast.tool.js +202 -0
  19. package/dist/mcp-server/tools/definitions/get-aurora-forecast.tool.js.map +1 -0
  20. package/dist/mcp-server/tools/definitions/get-conditions.tool.d.ts +55 -0
  21. package/dist/mcp-server/tools/definitions/get-conditions.tool.d.ts.map +1 -0
  22. package/dist/mcp-server/tools/definitions/get-conditions.tool.js +129 -0
  23. package/dist/mcp-server/tools/definitions/get-conditions.tool.js.map +1 -0
  24. package/dist/mcp-server/tools/definitions/get-kp-index.tool.d.ts +34 -0
  25. package/dist/mcp-server/tools/definitions/get-kp-index.tool.d.ts.map +1 -0
  26. package/dist/mcp-server/tools/definitions/get-kp-index.tool.js +126 -0
  27. package/dist/mcp-server/tools/definitions/get-kp-index.tool.js.map +1 -0
  28. package/dist/mcp-server/tools/definitions/get-solar-activity.tool.d.ts +58 -0
  29. package/dist/mcp-server/tools/definitions/get-solar-activity.tool.d.ts.map +1 -0
  30. package/dist/mcp-server/tools/definitions/get-solar-activity.tool.js +237 -0
  31. package/dist/mcp-server/tools/definitions/get-solar-activity.tool.js.map +1 -0
  32. package/dist/mcp-server/tools/definitions/get-solar-wind.tool.d.ts +46 -0
  33. package/dist/mcp-server/tools/definitions/get-solar-wind.tool.d.ts.map +1 -0
  34. package/dist/mcp-server/tools/definitions/get-solar-wind.tool.js +197 -0
  35. package/dist/mcp-server/tools/definitions/get-solar-wind.tool.js.map +1 -0
  36. package/dist/mcp-server/tools/definitions/index.d.ts +225 -0
  37. package/dist/mcp-server/tools/definitions/index.d.ts.map +1 -0
  38. package/dist/mcp-server/tools/definitions/index.js +19 -0
  39. package/dist/mcp-server/tools/definitions/index.js.map +1 -0
  40. package/dist/services/space-weather/space-weather-service.d.ts +42 -0
  41. package/dist/services/space-weather/space-weather-service.d.ts.map +1 -0
  42. package/dist/services/space-weather/space-weather-service.js +402 -0
  43. package/dist/services/space-weather/space-weather-service.js.map +1 -0
  44. package/dist/services/space-weather/types.d.ts +189 -0
  45. package/dist/services/space-weather/types.d.ts.map +1 -0
  46. package/dist/services/space-weather/types.js +6 -0
  47. package/dist/services/space-weather/types.js.map +1 -0
  48. package/package.json +105 -0
  49. package/server.json +99 -0
@@ -0,0 +1,129 @@
1
+ /**
2
+ * @fileoverview Tool: noaa_spaceweather_get_conditions — current space-weather snapshot.
3
+ * @module mcp-server/tools/definitions/get-conditions
4
+ */
5
+ import { tool, z } from '@cyanheads/mcp-ts-core';
6
+ import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
7
+ import { getSpaceWeatherService } from '../../../services/space-weather/space-weather-service.js';
8
+ // ── Output sub-schemas ──────────────────────────────────────────────────────
9
+ const ScaleSummarySchema = z
10
+ .object({
11
+ scale: z.number().describe('Storm scale level 0–5.'),
12
+ text: z
13
+ .string()
14
+ .describe('Human-readable scale descriptor, e.g. "Moderate". Empty when scale is 0.'),
15
+ label: z.string().describe('NOAA scale string, e.g. "G2", "R1", "S0".'),
16
+ })
17
+ .describe('Current level and label for one NOAA storm scale category.');
18
+ const ForecastPeriodSchema = z
19
+ .object({
20
+ date: z.string().describe('Forecast date string.'),
21
+ G: ScaleSummarySchema.describe('Geomagnetic storm scale for this day.'),
22
+ R: ScaleSummarySchema.describe('Radio blackout scale for this day.'),
23
+ S: ScaleSummarySchema.describe('Solar radiation storm scale for this day.'),
24
+ })
25
+ .describe('3-day NOAA scale forecast for one calendar day.');
26
+ // ── Tool ────────────────────────────────────────────────────────────────────
27
+ export const getConditions = tool('noaa_spaceweather_get_conditions', {
28
+ title: 'Get Space Weather Conditions',
29
+ description: 'Current space-weather snapshot: NOAA R/S/G storm scales (today + 3-day forecast), latest Kp ' +
30
+ 'index with its G-scale equivalent and aurora-visibility latitude, and a plain-language status ' +
31
+ 'summary. The quickest way to answer "is anything happening right now?" — use before deciding ' +
32
+ 'whether to drill into solar wind (noaa_spaceweather_get_solar_wind), aurora ' +
33
+ '(noaa_spaceweather_get_aurora_forecast), or alert details (noaa_spaceweather_get_alerts).',
34
+ annotations: { readOnlyHint: true, openWorldHint: true, idempotentHint: true },
35
+ input: z.object({}),
36
+ output: z.object({
37
+ observedAt: z
38
+ .string()
39
+ .describe('UTC date and time of the NOAA scales data period this snapshot reflects, e.g. "2026-06-04 15:00:00".'),
40
+ currentKp: z.number().describe('Latest observed planetary K-index (0–9).'),
41
+ currentGScale: z.number().describe('NOAA G-scale equivalent for current Kp (0–5).'),
42
+ auroraLatitude: z
43
+ .string()
44
+ .describe('Aurora visibility guidance for current conditions, e.g. "Aurora possible to ~55° geomagnetic latitude".'),
45
+ today: z
46
+ .object({
47
+ G: ScaleSummarySchema.describe("Today's geomagnetic storm scale."),
48
+ R: ScaleSummarySchema.describe("Today's radio blackout scale."),
49
+ S: ScaleSummarySchema.describe("Today's solar radiation storm scale."),
50
+ })
51
+ .describe('Current observed NOAA storm scales for today.'),
52
+ forecast: z.array(ForecastPeriodSchema).describe('3-day NOAA scale forecast (next 1–3 days).'),
53
+ summary: z
54
+ .string()
55
+ .describe('Plain-language status summary suitable for display, e.g. "Quiet conditions" or "G2 moderate geomagnetic storm in progress."'),
56
+ }),
57
+ errors: [
58
+ {
59
+ reason: 'feed_unavailable',
60
+ code: JsonRpcErrorCode.ServiceUnavailable,
61
+ when: 'SWPC endpoint returns non-OK status or times out after retries.',
62
+ retryable: true,
63
+ recovery: 'Retry in 30–60 seconds; SWPC feeds occasionally lag during high-activity events.',
64
+ },
65
+ ],
66
+ async handler(_input, ctx) {
67
+ ctx.log.info('Fetching current space weather conditions');
68
+ const svc = getSpaceWeatherService();
69
+ const [scales, kpObs] = await Promise.all([svc.getNoaaScales(ctx), svc.getKpObserved(ctx)]);
70
+ // Latest Kp is the last element of the observed array
71
+ const latestKp = kpObs.length > 0 ? kpObs[kpObs.length - 1] : null;
72
+ const currentKp = latestKp?.kp ?? 0;
73
+ const currentGScale = latestKp?.gScale ?? 0;
74
+ const auroraLatitude = latestKp?.auroraLatitude ?? 'No significant aurora expected at mid-latitudes';
75
+ const today = scales.today;
76
+ // Build summary
77
+ const parts = [];
78
+ if (today.G.scale >= 1)
79
+ parts.push(`G${today.G.scale} ${today.G.text.toLowerCase()} geomagnetic storm`);
80
+ if (today.R.scale >= 1)
81
+ parts.push(`R${today.R.scale} ${today.R.text.toLowerCase()} radio blackout`);
82
+ if (today.S.scale >= 1)
83
+ parts.push(`S${today.S.scale} ${today.S.text.toLowerCase()} solar radiation storm`);
84
+ const summary = parts.length > 0
85
+ ? parts.map((p, i) => (i === 0 ? p.charAt(0).toUpperCase() + p.slice(1) : p)).join('; ') +
86
+ ' in progress.'
87
+ : 'Quiet conditions — no significant storms active.';
88
+ return {
89
+ observedAt: `${today.date} ${today.time}`,
90
+ currentKp,
91
+ currentGScale,
92
+ auroraLatitude,
93
+ today: {
94
+ G: { scale: today.G.scale, text: today.G.text, label: `G${today.G.scale}` },
95
+ R: { scale: today.R.scale, text: today.R.text, label: `R${today.R.scale}` },
96
+ S: { scale: today.S.scale, text: today.S.text, label: `S${today.S.scale}` },
97
+ },
98
+ forecast: scales.forecast.map((p) => ({
99
+ date: p.date,
100
+ G: { scale: p.G.scale, text: p.G.text, label: `G${p.G.scale}` },
101
+ R: { scale: p.R.scale, text: p.R.text, label: `R${p.R.scale}` },
102
+ S: { scale: p.S.scale, text: p.S.text, label: `S${p.S.scale}` },
103
+ })),
104
+ summary,
105
+ };
106
+ },
107
+ format: (result) => {
108
+ const lines = [];
109
+ lines.push(`## Space Weather Conditions — ${result.observedAt} UTC`);
110
+ lines.push('');
111
+ lines.push(`**Summary:** ${result.summary}`);
112
+ lines.push('');
113
+ lines.push(`**Current Kp:** ${result.currentKp} | **G-scale:** ${result.currentGScale} — ${result.auroraLatitude}`);
114
+ lines.push('');
115
+ lines.push('### Today');
116
+ lines.push(`- **Geomagnetic (G):** ${result.today.G.label} (scale ${result.today.G.scale}) ${result.today.G.text || 'None'}`);
117
+ lines.push(`- **Radio Blackout (R):** ${result.today.R.label} (scale ${result.today.R.scale}) ${result.today.R.text || 'None'}`);
118
+ lines.push(`- **Solar Radiation (S):** ${result.today.S.label} (scale ${result.today.S.scale}) ${result.today.S.text || 'None'}`);
119
+ if (result.forecast.length > 0) {
120
+ lines.push('');
121
+ lines.push('### 3-Day Forecast');
122
+ for (const day of result.forecast) {
123
+ lines.push(`**${day.date}:** ${day.G.label} (scale ${day.G.scale}) ${day.G.text || 'None'} | ${day.R.label} (scale ${day.R.scale}) ${day.R.text || 'None'} | ${day.S.label} (scale ${day.S.scale}) ${day.S.text || 'None'}`);
124
+ }
125
+ }
126
+ return [{ type: 'text', text: lines.join('\n') }];
127
+ },
128
+ });
129
+ //# sourceMappingURL=get-conditions.tool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-conditions.tool.js","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/get-conditions.tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAA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etary K-index time series.
3
+ * @module mcp-server/tools/definitions/get-kp-index
4
+ */
5
+ import { z } from '@cyanheads/mcp-ts-core';
6
+ import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
7
+ export declare const getKpIndex: import("@cyanheads/mcp-ts-core").ToolDefinition<z.ZodObject<{
8
+ window_days: z.ZodDefault<z.ZodNumber>;
9
+ }, z.core.$strip>, z.ZodObject<{
10
+ observed: z.ZodArray<z.ZodObject<{
11
+ timeTag: z.ZodString;
12
+ kp: z.ZodNumber;
13
+ gScale: z.ZodNumber;
14
+ gLabel: z.ZodString;
15
+ auroraLatitude: z.ZodString;
16
+ }, z.core.$strip>>;
17
+ forecast: z.ZodArray<z.ZodObject<{
18
+ timeTag: z.ZodString;
19
+ kp: z.ZodNumber;
20
+ observed: z.ZodString;
21
+ noaaScale: z.ZodNullable<z.ZodString>;
22
+ }, z.core.$strip>>;
23
+ currentKp: z.ZodNumber;
24
+ currentGScale: z.ZodNumber;
25
+ auroraLatitude: z.ZodString;
26
+ observedCount: z.ZodNumber;
27
+ }, z.core.$strip>, readonly [{
28
+ readonly reason: "feed_unavailable";
29
+ readonly code: JsonRpcErrorCode.ServiceUnavailable;
30
+ readonly when: "SWPC endpoint returns non-OK status or times out after retries.";
31
+ readonly retryable: true;
32
+ readonly recovery: "Retry in 30–60 seconds; SWPC feeds occasionally lag during high-activity events.";
33
+ }], undefined>;
34
+ //# sourceMappingURL=get-kp-index.tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-kp-index.tool.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/get-kp-index.tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAQ,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AA2BjE,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;cA2GrB,CAAC"}
@@ -0,0 +1,126 @@
1
+ /**
2
+ * @fileoverview Tool: noaa_spaceweather_get_kp_index — planetary K-index time series.
3
+ * @module mcp-server/tools/definitions/get-kp-index
4
+ */
5
+ import { tool, z } from '@cyanheads/mcp-ts-core';
6
+ import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
7
+ import { getSpaceWeatherService } from '../../../services/space-weather/space-weather-service.js';
8
+ const KpObsSchema = z
9
+ .object({
10
+ timeTag: z.string().describe('ISO 8601 3-hour interval time tag.'),
11
+ kp: z.number().describe('Kp index value 0–9.'),
12
+ gScale: z.number().describe('NOAA G-scale equivalent (0–5).'),
13
+ gLabel: z.string().describe('NOAA G-scale label, e.g. "G0", "G3".'),
14
+ auroraLatitude: z.string().describe('Aurora visibility guidance for this Kp level.'),
15
+ })
16
+ .describe('One observed Kp 3-hour interval reading.');
17
+ const KpForecastSchema = z
18
+ .object({
19
+ timeTag: z.string().describe('ISO 8601 time tag for the forecast interval.'),
20
+ kp: z.number().describe('Forecasted Kp value.'),
21
+ observed: z
22
+ .string()
23
+ .describe('"observed" for confirmed readings, "predicted" for forecast points.'),
24
+ noaaScale: z
25
+ .string()
26
+ .nullable()
27
+ .describe('NOAA scale string, e.g. "G1", null when not available.'),
28
+ })
29
+ .describe('One Kp forecast interval.');
30
+ export const getKpIndex = tool('noaa_spaceweather_get_kp_index', {
31
+ title: 'Get Kp Index',
32
+ description: 'Planetary K-index (0–9 geomagnetic activity scale) — recent observed 3-hour values with their ' +
33
+ 'NOAA G-scale equivalents and aurora-latitude guidance, plus the 3-day Kp forecast series. ' +
34
+ 'Kp is the primary driver of aurora visibility and geomagnetic storm severity: Kp≥5 is G1, Kp≥7 ' +
35
+ 'is G3 (aurora to ~50°), Kp≥9 is G5 extreme. Use noaa_spaceweather_get_conditions for a ' +
36
+ 'combined snapshot including storm scales; use this tool when you need the Kp time series or ' +
37
+ 'forecast detail.',
38
+ annotations: { readOnlyHint: true, openWorldHint: true, idempotentHint: true },
39
+ input: z.object({
40
+ window_days: z
41
+ .number()
42
+ .int()
43
+ .min(1)
44
+ .max(7)
45
+ .default(1)
46
+ .describe('Number of past days of observed Kp to return (1–7, default 1). Larger windows show trend context.'),
47
+ }),
48
+ output: z.object({
49
+ observed: z
50
+ .array(KpObsSchema)
51
+ .describe('Observed Kp readings within the requested window, oldest first.'),
52
+ forecast: z.array(KpForecastSchema).describe('3-day Kp forecast series.'),
53
+ currentKp: z.number().describe('Latest observed Kp value.'),
54
+ currentGScale: z.number().describe('NOAA G-scale for current Kp.'),
55
+ auroraLatitude: z.string().describe('Aurora visibility guidance for current conditions.'),
56
+ observedCount: z
57
+ .number()
58
+ .describe('Number of Kp observations in the observed array, matching the requested window.'),
59
+ }),
60
+ errors: [
61
+ {
62
+ reason: 'feed_unavailable',
63
+ code: JsonRpcErrorCode.ServiceUnavailable,
64
+ when: 'SWPC endpoint returns non-OK status or times out after retries.',
65
+ retryable: true,
66
+ recovery: 'Retry in 30–60 seconds; SWPC feeds occasionally lag during high-activity events.',
67
+ },
68
+ ],
69
+ async handler(input, ctx) {
70
+ ctx.log.info('Fetching Kp index', { window_days: input.window_days });
71
+ const svc = getSpaceWeatherService();
72
+ const [allObs, forecast] = await Promise.all([svc.getKpObserved(ctx), svc.getKpForecast(ctx)]);
73
+ // Slice to the requested window
74
+ const cutoff = new Date();
75
+ cutoff.setDate(cutoff.getDate() - input.window_days);
76
+ const cutoffIso = cutoff.toISOString();
77
+ const observed = allObs.filter((r) => r.timeTag >= cutoffIso);
78
+ const latest = observed.length > 0 ? observed[observed.length - 1] : null;
79
+ const currentKp = latest?.kp ?? 0;
80
+ const currentGScale = latest?.gScale ?? 0;
81
+ const auroraLatitude = latest?.auroraLatitude ?? 'No significant aurora expected at mid-latitudes';
82
+ return {
83
+ observed: observed.map((r) => ({
84
+ timeTag: r.timeTag,
85
+ kp: r.kp,
86
+ gScale: r.gScale,
87
+ gLabel: `G${r.gScale}`,
88
+ auroraLatitude: r.auroraLatitude,
89
+ })),
90
+ forecast: forecast.map((r) => ({
91
+ timeTag: r.timeTag,
92
+ kp: r.kp,
93
+ observed: r.observed,
94
+ noaaScale: r.noaaScale,
95
+ })),
96
+ currentKp,
97
+ currentGScale,
98
+ auroraLatitude,
99
+ observedCount: observed.length,
100
+ };
101
+ },
102
+ format: (result) => {
103
+ const lines = [];
104
+ lines.push('## Kp Index');
105
+ lines.push(`**Current Kp:** ${result.currentKp} (G${result.currentGScale})`);
106
+ lines.push(`**Aurora:** ${result.auroraLatitude}`);
107
+ lines.push(`**Observed readings:** ${result.observedCount}`);
108
+ if (result.observed.length > 0) {
109
+ lines.push('');
110
+ lines.push('### Recent Observed Values');
111
+ for (const r of result.observed) {
112
+ lines.push(`- ${r.timeTag}: Kp ${r.kp} | G-scale ${r.gScale} (${r.gLabel}) — ${r.auroraLatitude}`);
113
+ }
114
+ }
115
+ if (result.forecast.length > 0) {
116
+ lines.push('');
117
+ lines.push('### 3-Day Forecast');
118
+ for (const r of result.forecast) {
119
+ const scale = r.noaaScale ? ` (${r.noaaScale})` : '';
120
+ lines.push(`- ${r.timeTag}: Kp ${r.kp}${scale} [${r.observed}]`);
121
+ }
122
+ }
123
+ return [{ type: 'text', text: lines.join('\n') }];
124
+ },
125
+ });
126
+ //# sourceMappingURL=get-kp-index.tool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-kp-index.tool.js","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/get-kp-index.tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,sBAAsB,EAAE,MAAM,mDAAmD,CAAC;AAE3F,MAAM,WAAW,GAAG,CAAC;KAClB,MAAM,CAAC;IACN,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,oCAAoC,CAAC;IAClE,EAAE,EAAE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AK,KAAK,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAC;YACnE,CAAC;QACH,CAAC;QACD,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACpD,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,58 @@
1
+ /**
2
+ * @fileoverview Tool: noaa_spaceweather_get_solar_activity — solar flares, regions, radiation storms.
3
+ * @module mcp-server/tools/definitions/get-solar-activity
4
+ */
5
+ import { z } from '@cyanheads/mcp-ts-core';
6
+ import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
7
+ export declare const getSolarActivity: import("@cyanheads/mcp-ts-core").ToolDefinition<z.ZodObject<{
8
+ include_regions: z.ZodDefault<z.ZodBoolean>;
9
+ }, z.core.$strip>, z.ZodObject<{
10
+ latestXray: z.ZodNullable<z.ZodObject<{
11
+ timeTag: z.ZodString;
12
+ fluxWm2: z.ZodNumber;
13
+ flareClass: z.ZodString;
14
+ satellite: z.ZodNumber;
15
+ }, z.core.$strip>>;
16
+ recentXray: z.ZodArray<z.ZodObject<{
17
+ timeTag: z.ZodString;
18
+ fluxWm2: z.ZodNumber;
19
+ flareClass: z.ZodString;
20
+ satellite: z.ZodNumber;
21
+ }, z.core.$strip>>;
22
+ probabilities: z.ZodArray<z.ZodObject<{
23
+ date: z.ZodString;
24
+ cClass1Day: z.ZodNumber;
25
+ mClass1Day: z.ZodNumber;
26
+ xClass1Day: z.ZodNumber;
27
+ protons1Day: z.ZodNumber;
28
+ }, z.core.$strip>>;
29
+ latestProton: z.ZodNullable<z.ZodObject<{
30
+ timeTag: z.ZodString;
31
+ fluxPfu: z.ZodNumber;
32
+ sScale: z.ZodNumber;
33
+ energy: z.ZodString;
34
+ }, z.core.$strip>>;
35
+ sScale: z.ZodNumber;
36
+ sScaleText: z.ZodString;
37
+ activeRegions: z.ZodArray<z.ZodObject<{
38
+ region: z.ZodNumber;
39
+ location: z.ZodString;
40
+ latitude: z.ZodString;
41
+ spotClass: z.ZodString;
42
+ numberSpots: z.ZodNumber;
43
+ magClass: z.ZodString;
44
+ cFlareProbability: z.ZodNumber;
45
+ mFlareProbability: z.ZodNumber;
46
+ xFlareProbability: z.ZodNumber;
47
+ protonProbability: z.ZodNumber;
48
+ observedDate: z.ZodString;
49
+ }, z.core.$strip>>;
50
+ fetchedAt: z.ZodString;
51
+ }, z.core.$strip>, readonly [{
52
+ readonly reason: "feed_unavailable";
53
+ readonly code: JsonRpcErrorCode.ServiceUnavailable;
54
+ readonly when: "SWPC endpoint returns non-OK status or times out after retries.";
55
+ readonly retryable: true;
56
+ readonly recovery: "Retry in 30–60 seconds; SWPC feeds occasionally lag during high-activity events.";
57
+ }], undefined>;
58
+ //# sourceMappingURL=get-solar-activity.tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-solar-activity.tool.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/get-solar-activity.tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAQ,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAkEjE,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAmM3B,CAAC"}
@@ -0,0 +1,237 @@
1
+ /**
2
+ * @fileoverview Tool: noaa_spaceweather_get_solar_activity — solar flares, regions, radiation storms.
3
+ * @module mcp-server/tools/definitions/get-solar-activity
4
+ */
5
+ import { tool, z } from '@cyanheads/mcp-ts-core';
6
+ import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
7
+ import { getSpaceWeatherService } from '../../../services/space-weather/space-weather-service.js';
8
+ /** Classify X-ray flux to flare class letter. */
9
+ function classifyFlare(fluxWm2) {
10
+ if (fluxWm2 >= 1e-4)
11
+ return 'X';
12
+ if (fluxWm2 >= 1e-5)
13
+ return 'M';
14
+ if (fluxWm2 >= 1e-6)
15
+ return 'C';
16
+ if (fluxWm2 >= 1e-7)
17
+ return 'B';
18
+ return 'A';
19
+ }
20
+ /** Classify proton flux to NOAA S-scale. */
21
+ function classifySScale(fluxPfu) {
22
+ if (fluxPfu >= 100000)
23
+ return 5;
24
+ if (fluxPfu >= 10000)
25
+ return 4;
26
+ if (fluxPfu >= 1000)
27
+ return 3;
28
+ if (fluxPfu >= 100)
29
+ return 2;
30
+ if (fluxPfu >= 10)
31
+ return 1;
32
+ return 0;
33
+ }
34
+ const XraySchema = z
35
+ .object({
36
+ timeTag: z.string().describe('ISO 8601 measurement time tag.'),
37
+ fluxWm2: z.number().describe('X-ray flux in W/m² (0.1-0.8nm long channel from GOES).'),
38
+ flareClass: z.string().describe('Flare classification letter: A, B, C, M, or X.'),
39
+ satellite: z.number().describe('GOES satellite number.'),
40
+ })
41
+ .describe('One GOES X-ray flux reading with flare class.');
42
+ const SolarRegionSchema = z
43
+ .object({
44
+ region: z.number().describe('NOAA active region number.'),
45
+ location: z.string().describe('Heliographic location, e.g. "N17E47".'),
46
+ latitude: z.string().describe('Heliographic latitude, e.g. "N17".'),
47
+ spotClass: z.string().describe('Sunspot morphology class.'),
48
+ numberSpots: z.number().describe('Number of sunspots in this region.'),
49
+ magClass: z.string().describe('Magnetic field class.'),
50
+ cFlareProbability: z.number().describe('Probability of a C-class flare (%).'),
51
+ mFlareProbability: z.number().describe('Probability of an M-class flare (%).'),
52
+ xFlareProbability: z.number().describe('Probability of an X-class flare (%).'),
53
+ protonProbability: z.number().describe('Probability of a proton event (%).'),
54
+ observedDate: z.string().describe('Date this region data was observed.'),
55
+ })
56
+ .describe('One active solar region with flare probabilities.');
57
+ const ProbsSchema = z
58
+ .object({
59
+ date: z.string().describe('Forecast date.'),
60
+ cClass1Day: z.number().describe('Total probability of a C-class flare for this day (%).'),
61
+ mClass1Day: z.number().describe('Total probability of an M-class flare for this day (%).'),
62
+ xClass1Day: z.number().describe('Total probability of an X-class flare for this day (%).'),
63
+ protons1Day: z.number().describe('Probability of ≥10 MeV proton event for this day (%).'),
64
+ })
65
+ .describe('Solar flare probability forecast for one day.');
66
+ const ProtonSchema = z
67
+ .object({
68
+ timeTag: z.string().describe('ISO 8601 measurement time tag.'),
69
+ fluxPfu: z.number().describe('Integral proton flux in particle flux units (pfu) at ≥10 MeV.'),
70
+ sScale: z.number().describe('NOAA S-scale level (0–5) for this flux reading.'),
71
+ energy: z.string().describe('Energy channel, e.g. ">=10 MeV".'),
72
+ })
73
+ .describe('One GOES integral proton flux reading with S-scale.');
74
+ export const getSolarActivity = tool('noaa_spaceweather_get_solar_activity', {
75
+ title: 'Get Solar Activity',
76
+ description: 'Solar flare and radiation storm picture: recent GOES X-ray flux with flare-class labels (A/B/C/M/X), ' +
77
+ '3-day flare-class probabilities (C/M/X), active solar regions with per-region flare probabilities, ' +
78
+ 'and GOES integral proton flux at ≥10 MeV with NOAA S-scale. For operators tracking HF radio ' +
79
+ 'blackout (R-scale, driven by X-ray) and radiation storm risk (S-scale, driven by protons). ' +
80
+ 'Active region data helps identify which region is driving current activity.',
81
+ annotations: { readOnlyHint: true, openWorldHint: true, idempotentHint: true },
82
+ input: z.object({
83
+ include_regions: z
84
+ .boolean()
85
+ .default(true)
86
+ .describe('Include active solar region details (default true). Set false to skip region data and reduce response size.'),
87
+ }),
88
+ output: z.object({
89
+ latestXray: XraySchema.nullable().describe('Most recent GOES X-ray flux reading, null if unavailable.'),
90
+ recentXray: z
91
+ .array(XraySchema)
92
+ .describe('GOES X-ray flux readings from the past hour, oldest first.'),
93
+ probabilities: z.array(ProbsSchema).describe('3-day flare probability forecasts.'),
94
+ latestProton: ProtonSchema.nullable().describe('Most recent ≥10 MeV proton flux reading, null if unavailable.'),
95
+ sScale: z
96
+ .number()
97
+ .describe('Current NOAA S-scale for solar radiation storms (0–5), derived from latest proton flux.'),
98
+ sScaleText: z
99
+ .string()
100
+ .describe('Plain-language S-scale description, e.g. "S2 moderate radiation storm".'),
101
+ activeRegions: z
102
+ .array(SolarRegionSchema)
103
+ .describe('Currently active solar regions with per-region flare probabilities. Empty when include_regions=false or no regions are active.'),
104
+ fetchedAt: z.string().describe('ISO 8601 timestamp of when this data was fetched.'),
105
+ }),
106
+ errors: [
107
+ {
108
+ reason: 'feed_unavailable',
109
+ code: JsonRpcErrorCode.ServiceUnavailable,
110
+ when: 'SWPC endpoint returns non-OK status or times out after retries.',
111
+ retryable: true,
112
+ recovery: 'Retry in 30–60 seconds; SWPC feeds occasionally lag during high-activity events.',
113
+ },
114
+ ],
115
+ async handler(input, ctx) {
116
+ ctx.log.info('Fetching solar activity', { include_regions: input.include_regions });
117
+ const svc = getSpaceWeatherService();
118
+ const [xray, probs, protons, regions] = await Promise.all([
119
+ svc.getXrayFlux(ctx),
120
+ svc.getSolarProbabilities(ctx),
121
+ svc.getProtonFlux(ctx),
122
+ input.include_regions ? svc.getSolarRegions(ctx) : Promise.resolve(null),
123
+ ]);
124
+ // Latest X-ray
125
+ const latestXrayRaw = xray.length > 0 ? xray[xray.length - 1] : null;
126
+ const latestXray = latestXrayRaw
127
+ ? {
128
+ timeTag: latestXrayRaw.timeTag,
129
+ fluxWm2: latestXrayRaw.fluxWm2,
130
+ flareClass: classifyFlare(latestXrayRaw.fluxWm2),
131
+ satellite: latestXrayRaw.satellite,
132
+ }
133
+ : null;
134
+ // Recent X-ray — last hour
135
+ const hourCutoff = new Date();
136
+ hourCutoff.setHours(hourCutoff.getHours() - 1);
137
+ const hourCutoffIso = hourCutoff.toISOString();
138
+ const recentXray = xray
139
+ .filter((r) => r.timeTag >= hourCutoffIso)
140
+ .map((r) => ({
141
+ timeTag: r.timeTag,
142
+ fluxWm2: r.fluxWm2,
143
+ flareClass: classifyFlare(r.fluxWm2),
144
+ satellite: r.satellite,
145
+ }));
146
+ // Latest proton / S-scale
147
+ const latestProtonRaw = protons.length > 0 ? protons[protons.length - 1] : null;
148
+ const sScale = latestProtonRaw ? classifySScale(latestProtonRaw.fluxPfu) : 0;
149
+ const sScaleDescriptors = [
150
+ 'No radiation storm',
151
+ 'S1 minor radiation storm',
152
+ 'S2 moderate radiation storm',
153
+ 'S3 strong radiation storm',
154
+ 'S4 severe radiation storm',
155
+ 'S5 extreme radiation storm',
156
+ ];
157
+ const sScaleText = sScaleDescriptors[sScale] ?? 'Unknown';
158
+ const latestProton = latestProtonRaw
159
+ ? {
160
+ timeTag: latestProtonRaw.timeTag,
161
+ fluxPfu: latestProtonRaw.fluxPfu,
162
+ sScale,
163
+ energy: latestProtonRaw.energy,
164
+ }
165
+ : null;
166
+ return {
167
+ latestXray,
168
+ recentXray,
169
+ probabilities: probs.map((p) => ({
170
+ date: p.date,
171
+ cClass1Day: p.cClass1Day,
172
+ mClass1Day: p.mClass1Day,
173
+ xClass1Day: p.xClass1Day,
174
+ protons1Day: p.protons1Day,
175
+ })),
176
+ latestProton,
177
+ sScale,
178
+ sScaleText,
179
+ activeRegions: (regions ?? []).map((r) => ({
180
+ region: r.region,
181
+ location: r.location,
182
+ latitude: r.latitude,
183
+ spotClass: r.spotClass,
184
+ numberSpots: r.numberSpots,
185
+ magClass: r.magClass,
186
+ cFlareProbability: r.cFlareProbability,
187
+ mFlareProbability: r.mFlareProbability,
188
+ xFlareProbability: r.xFlareProbability,
189
+ protonProbability: r.protonProbability,
190
+ observedDate: r.observedDate,
191
+ })),
192
+ fetchedAt: new Date().toISOString(),
193
+ };
194
+ },
195
+ format: (result) => {
196
+ const lines = [];
197
+ lines.push(`## Solar Activity — ${result.fetchedAt}`);
198
+ lines.push(`**Radiation Storm:** ${result.sScaleText} (S-scale ${result.sScale})`);
199
+ if (result.latestXray) {
200
+ const x = result.latestXray;
201
+ lines.push('');
202
+ lines.push('### Latest X-ray Flux');
203
+ lines.push(`**Time:** ${x.timeTag} | **Class:** ${x.flareClass} | **Flux:** ${x.fluxWm2} W/m² | **Satellite:** GOES-${x.satellite}`);
204
+ }
205
+ if (result.recentXray.length > 0) {
206
+ lines.push('');
207
+ lines.push('### X-ray (Past Hour)');
208
+ for (const r of result.recentXray) {
209
+ lines.push(`- ${r.timeTag}: ${r.flareClass} class — ${r.fluxWm2} W/m² | GOES-${r.satellite}`);
210
+ }
211
+ }
212
+ if (result.latestProton) {
213
+ const p = result.latestProton;
214
+ lines.push('');
215
+ lines.push('### Proton Flux (≥10 MeV)');
216
+ lines.push(`**Time:** ${p.timeTag} | **Flux:** ${p.fluxPfu} pfu | **S${p.sScale}** | **Channel:** ${p.energy}`);
217
+ }
218
+ if (result.probabilities.length > 0) {
219
+ lines.push('');
220
+ lines.push('### Flare Probabilities (3-day forecast)');
221
+ for (const p of result.probabilities) {
222
+ lines.push(`**${p.date}:** C=${p.cClass1Day}% | M=${p.mClass1Day}% | X=${p.xClass1Day}% | Proton=${p.protons1Day}%`);
223
+ }
224
+ }
225
+ if (result.activeRegions.length > 0) {
226
+ lines.push('');
227
+ lines.push('### Active Solar Regions');
228
+ for (const r of result.activeRegions) {
229
+ lines.push(`**AR${r.region}** — Location: ${r.location} | Latitude: ${r.latitude} | Observed: ${r.observedDate}`);
230
+ lines.push(` Class: ${r.spotClass}/${r.magClass} | Spots: ${r.numberSpots}`);
231
+ lines.push(` Flare: C=${r.cFlareProbability}% M=${r.mFlareProbability}% X=${r.xFlareProbability}% Proton=${r.protonProbability}%`);
232
+ }
233
+ }
234
+ return [{ type: 'text', text: lines.join('\n') }];
235
+ },
236
+ });
237
+ //# sourceMappingURL=get-solar-activity.tool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-solar-activity.tool.js","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/get-solar-activity.tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,sBAAsB,EAAE,MAAM,mDAAmD,C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