@pipeworx/mcp-nasa 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 +356 -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-nasa
|
|
2
|
+
|
|
3
|
+
NASA MCP — wraps NASA Open APIs (api.nasa.gov)
|
|
4
|
+
|
|
5
|
+
Part of [Pipeworx](https://pipeworx.io) — an MCP gateway connecting AI agents to 965+ 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
|
+
"nasa": {
|
|
20
|
+
"url": "https://gateway.pipeworx.io/nasa/mcp"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Or connect to the full Pipeworx gateway for access to all 965+ 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 Nasa 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-nasa",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "NASA MCP — wraps NASA Open APIs (api.nasa.gov)",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "src/index.ts",
|
|
7
|
+
"types": "src/index.ts",
|
|
8
|
+
"keywords": ["mcp", "mcp-server", "model-context-protocol", "pipeworx", "nasa"],
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/pipeworx-io/mcp-nasa"
|
|
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/nasa",
|
|
4
|
+
"title": "Nasa",
|
|
5
|
+
"description": "NASA MCP — wraps NASA Open APIs (api.nasa.gov)",
|
|
6
|
+
"version": "0.1.0",
|
|
7
|
+
"websiteUrl": "https://pipeworx.io/packs/nasa",
|
|
8
|
+
"repository": {
|
|
9
|
+
"url": "https://github.com/pipeworx-io/mcp-nasa",
|
|
10
|
+
"source": "github"
|
|
11
|
+
},
|
|
12
|
+
"remotes": [
|
|
13
|
+
{
|
|
14
|
+
"type": "streamable-http",
|
|
15
|
+
"url": "https://gateway.pipeworx.io/nasa/mcp"
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,356 @@
|
|
|
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
|
+
* NASA MCP — wraps NASA Open APIs (api.nasa.gov)
|
|
21
|
+
*
|
|
22
|
+
* Tools:
|
|
23
|
+
* - get_apod: Astronomy Picture of the Day
|
|
24
|
+
* - get_asteroids: near-Earth asteroid data from NeoWs
|
|
25
|
+
* - get_mars_photos: photos from Mars rovers
|
|
26
|
+
* - search_nasa_images: NASA Image & Video Library search (keyless)
|
|
27
|
+
* - get_solar_flares: DONKI solar-flare space-weather events
|
|
28
|
+
*
|
|
29
|
+
* Uses `api_key` query param (gateway injects PLATFORM_DATAGOV_KEY; falls back to
|
|
30
|
+
* DEMO_KEY). The image library lives on a separate keyless host.
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
const BASE_URL = 'https://api.nasa.gov';
|
|
35
|
+
// NASA Image & Video Library — separate host, no api_key required.
|
|
36
|
+
const IMAGES_URL = 'https://images-api.nasa.gov';
|
|
37
|
+
|
|
38
|
+
const tools: McpToolExport['tools'] = [
|
|
39
|
+
{
|
|
40
|
+
name: 'get_apod',
|
|
41
|
+
description:
|
|
42
|
+
'Get the NASA Astronomy Picture of the Day with explanation. Optionally specify a date. Example: get_apod({ date: "2024-01-15", _apiKey: "DEMO_KEY" })',
|
|
43
|
+
inputSchema: {
|
|
44
|
+
type: 'object',
|
|
45
|
+
properties: {
|
|
46
|
+
date: {
|
|
47
|
+
type: 'string',
|
|
48
|
+
description: 'Date in YYYY-MM-DD format (optional, defaults to today). Range: 1995-06-16 to today.',
|
|
49
|
+
},
|
|
50
|
+
_apiKey: {
|
|
51
|
+
type: 'string',
|
|
52
|
+
description: 'NASA API key (optional, defaults to DEMO_KEY — get a free key at api.nasa.gov)',
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
required: [],
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
name: 'get_asteroids',
|
|
60
|
+
description:
|
|
61
|
+
'Get near-Earth asteroids approaching within a date range (max 7 days). Returns size, velocity, and miss distance. Example: get_asteroids({ start_date: "2024-01-01", end_date: "2024-01-07", _apiKey: "DEMO_KEY" })',
|
|
62
|
+
inputSchema: {
|
|
63
|
+
type: 'object',
|
|
64
|
+
properties: {
|
|
65
|
+
start_date: {
|
|
66
|
+
type: 'string',
|
|
67
|
+
description: 'Start date in YYYY-MM-DD format',
|
|
68
|
+
},
|
|
69
|
+
end_date: {
|
|
70
|
+
type: 'string',
|
|
71
|
+
description: 'End date in YYYY-MM-DD format (max 7 days after start)',
|
|
72
|
+
},
|
|
73
|
+
_apiKey: {
|
|
74
|
+
type: 'string',
|
|
75
|
+
description: 'NASA API key (optional, defaults to DEMO_KEY)',
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
required: ['start_date', 'end_date'],
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
name: 'get_mars_photos',
|
|
83
|
+
description:
|
|
84
|
+
'Get photos taken by Mars rovers (Curiosity, Opportunity, Spirit). Filter by Martian sol and camera. Example: get_mars_photos({ sol: 1000, camera: "FHAZ", _apiKey: "DEMO_KEY" })',
|
|
85
|
+
inputSchema: {
|
|
86
|
+
type: 'object',
|
|
87
|
+
properties: {
|
|
88
|
+
sol: {
|
|
89
|
+
type: 'number',
|
|
90
|
+
description: 'Martian sol (day) to retrieve photos from, e.g. 1000 (default: 1000)',
|
|
91
|
+
},
|
|
92
|
+
camera: {
|
|
93
|
+
type: 'string',
|
|
94
|
+
description: 'Camera abbreviation: "FHAZ" (front hazard), "RHAZ" (rear hazard), "MAST" (mast), "CHEMCAM", "MAHLI", "MARDI", "NAVCAM" (optional)',
|
|
95
|
+
},
|
|
96
|
+
_apiKey: {
|
|
97
|
+
type: 'string',
|
|
98
|
+
description: 'NASA API key (optional, defaults to DEMO_KEY)',
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
required: [],
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
name: 'search_nasa_images',
|
|
106
|
+
description:
|
|
107
|
+
'Search the NASA Image and Video Library for images/videos of any subject — planets, missions, astronauts, launches, galaxies, etc. PREFER for "NASA photos of Jupiter", "images of the Apollo 11 mission", "pictures of a nebula". Returns title, description, date, NASA ID, media type, and a thumbnail URL. Keyless.',
|
|
108
|
+
inputSchema: {
|
|
109
|
+
type: 'object',
|
|
110
|
+
properties: {
|
|
111
|
+
query: { type: 'string', description: 'Search terms, e.g. "jupiter", "apollo 11", "crab nebula".' },
|
|
112
|
+
media_type: { type: 'string', description: 'Optional filter: "image", "video", or "audio".' },
|
|
113
|
+
limit: { type: 'number', description: 'Max results to return (default 10, max 50).' },
|
|
114
|
+
},
|
|
115
|
+
required: ['query'],
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
name: 'get_solar_flares',
|
|
120
|
+
description:
|
|
121
|
+
'Get recent solar flare events from NASA DONKI space-weather data. Returns each flare\'s class (e.g. C4.0, M1.8, X1.2), begin/peak/end times, source region, and active region number. Use for "recent solar flares", "is there solar activity / a solar storm", space-weather questions.',
|
|
122
|
+
inputSchema: {
|
|
123
|
+
type: 'object',
|
|
124
|
+
properties: {
|
|
125
|
+
start_date: { type: 'string', description: 'Start date YYYY-MM-DD (optional; default ~30 days ago).' },
|
|
126
|
+
end_date: { type: 'string', description: 'End date YYYY-MM-DD (optional; default today).' },
|
|
127
|
+
_apiKey: { type: 'string', description: 'NASA API key (optional, defaults to DEMO_KEY)' },
|
|
128
|
+
},
|
|
129
|
+
required: [],
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
];
|
|
133
|
+
|
|
134
|
+
async function callTool(name: string, args: Record<string, unknown>): Promise<unknown> {
|
|
135
|
+
const apiKey = (args._apiKey as string) || 'DEMO_KEY';
|
|
136
|
+
delete args._apiKey;
|
|
137
|
+
|
|
138
|
+
switch (name) {
|
|
139
|
+
case 'get_apod':
|
|
140
|
+
return getApod(args.date as string | undefined, apiKey);
|
|
141
|
+
case 'get_asteroids':
|
|
142
|
+
return getAsteroids(args.start_date as string, args.end_date as string, apiKey);
|
|
143
|
+
case 'get_mars_photos':
|
|
144
|
+
return getMarsPhotos(
|
|
145
|
+
(args.sol as number) ?? 1000,
|
|
146
|
+
args.camera as string | undefined,
|
|
147
|
+
apiKey,
|
|
148
|
+
);
|
|
149
|
+
case 'search_nasa_images':
|
|
150
|
+
return searchNasaImages(
|
|
151
|
+
args.query as string,
|
|
152
|
+
args.media_type as string | undefined,
|
|
153
|
+
(args.limit as number) ?? 10,
|
|
154
|
+
);
|
|
155
|
+
case 'get_solar_flares':
|
|
156
|
+
return getSolarFlares(
|
|
157
|
+
args.start_date as string | undefined,
|
|
158
|
+
args.end_date as string | undefined,
|
|
159
|
+
apiKey,
|
|
160
|
+
);
|
|
161
|
+
default:
|
|
162
|
+
throw new Error(`Unknown tool: ${name}`);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
async function getApod(date: string | undefined, apiKey: string) {
|
|
167
|
+
const params = new URLSearchParams({ api_key: apiKey });
|
|
168
|
+
if (date) params.set('date', date);
|
|
169
|
+
|
|
170
|
+
const res = await fetch(`${BASE_URL}/planetary/apod?${params}`);
|
|
171
|
+
if (!res.ok) throw new Error(`NASA APOD error: ${res.status}`);
|
|
172
|
+
|
|
173
|
+
const data = (await res.json()) as {
|
|
174
|
+
date: string; title: string; explanation: string; url: string;
|
|
175
|
+
hdurl?: string; media_type: string; copyright?: string;
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
return {
|
|
179
|
+
date: data.date,
|
|
180
|
+
title: data.title,
|
|
181
|
+
explanation: data.explanation,
|
|
182
|
+
url: data.url,
|
|
183
|
+
hd_url: data.hdurl,
|
|
184
|
+
media_type: data.media_type,
|
|
185
|
+
copyright: data.copyright,
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
async function getAsteroids(startDate: string, endDate: string, apiKey: string) {
|
|
190
|
+
const params = new URLSearchParams({
|
|
191
|
+
start_date: startDate,
|
|
192
|
+
end_date: endDate,
|
|
193
|
+
api_key: apiKey,
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
const res = await fetch(`${BASE_URL}/neo/rest/v1/feed?${params}`);
|
|
197
|
+
if (!res.ok) throw new Error(`NASA NeoWs error: ${res.status}`);
|
|
198
|
+
|
|
199
|
+
const data = (await res.json()) as {
|
|
200
|
+
element_count: number;
|
|
201
|
+
near_earth_objects: Record<string, Array<{
|
|
202
|
+
id: string; name: string; nasa_jpl_url: string;
|
|
203
|
+
is_potentially_hazardous_asteroid: boolean;
|
|
204
|
+
estimated_diameter: {
|
|
205
|
+
meters: { estimated_diameter_min: number; estimated_diameter_max: number };
|
|
206
|
+
};
|
|
207
|
+
close_approach_data: Array<{
|
|
208
|
+
close_approach_date: string;
|
|
209
|
+
relative_velocity: { kilometers_per_hour: string };
|
|
210
|
+
miss_distance: { kilometers: string };
|
|
211
|
+
}>;
|
|
212
|
+
}>>;
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
const asteroids: Array<Record<string, unknown>> = [];
|
|
216
|
+
for (const [date, neos] of Object.entries(data.near_earth_objects)) {
|
|
217
|
+
for (const neo of neos) {
|
|
218
|
+
const approach = neo.close_approach_data[0];
|
|
219
|
+
asteroids.push({
|
|
220
|
+
id: neo.id,
|
|
221
|
+
name: neo.name,
|
|
222
|
+
date,
|
|
223
|
+
hazardous: neo.is_potentially_hazardous_asteroid,
|
|
224
|
+
diameter_min_m: neo.estimated_diameter.meters.estimated_diameter_min,
|
|
225
|
+
diameter_max_m: neo.estimated_diameter.meters.estimated_diameter_max,
|
|
226
|
+
velocity_km_h: approach ? parseFloat(approach.relative_velocity.kilometers_per_hour) : null,
|
|
227
|
+
miss_distance_km: approach ? parseFloat(approach.miss_distance.kilometers) : null,
|
|
228
|
+
jpl_url: neo.nasa_jpl_url,
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
return {
|
|
234
|
+
total_count: data.element_count,
|
|
235
|
+
asteroids: asteroids.slice(0, 30),
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
async function getMarsPhotos(sol: number, camera: string | undefined, apiKey: string) {
|
|
240
|
+
const params = new URLSearchParams({
|
|
241
|
+
sol: String(sol),
|
|
242
|
+
api_key: apiKey,
|
|
243
|
+
});
|
|
244
|
+
if (camera) params.set('camera', camera);
|
|
245
|
+
|
|
246
|
+
const res = await fetch(`${BASE_URL}/mars-photos/api/v1/rovers/curiosity/photos?${params}`);
|
|
247
|
+
if (!res.ok) throw new Error(`NASA Mars Photos error: ${res.status}`);
|
|
248
|
+
|
|
249
|
+
const data = (await res.json()) as {
|
|
250
|
+
photos: Array<{
|
|
251
|
+
id: number; sol: number; camera: { name: string; full_name: string };
|
|
252
|
+
img_src: string; earth_date: string;
|
|
253
|
+
rover: { name: string; status: string };
|
|
254
|
+
}>;
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
return {
|
|
258
|
+
count: data.photos.length,
|
|
259
|
+
photos: data.photos.slice(0, 20).map((p) => ({
|
|
260
|
+
id: p.id,
|
|
261
|
+
sol: p.sol,
|
|
262
|
+
camera: p.camera.name,
|
|
263
|
+
camera_full_name: p.camera.full_name,
|
|
264
|
+
image_url: p.img_src,
|
|
265
|
+
earth_date: p.earth_date,
|
|
266
|
+
rover: p.rover.name,
|
|
267
|
+
rover_status: p.rover.status,
|
|
268
|
+
})),
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
async function searchNasaImages(query: string, mediaType: string | undefined, limit: number) {
|
|
273
|
+
const q = String(query ?? '').trim();
|
|
274
|
+
if (!q) throw new Error('Required argument "query" is missing (e.g. "jupiter").');
|
|
275
|
+
const size = Math.min(50, Math.max(1, limit));
|
|
276
|
+
const params = new URLSearchParams({ q });
|
|
277
|
+
if (mediaType) params.set('media_type', mediaType);
|
|
278
|
+
|
|
279
|
+
const res = await fetch(`${IMAGES_URL}/search?${params}`);
|
|
280
|
+
if (!res.ok) throw new Error(`NASA Images error: ${res.status}`);
|
|
281
|
+
|
|
282
|
+
const data = (await res.json()) as {
|
|
283
|
+
collection?: {
|
|
284
|
+
metadata?: { total_hits?: number };
|
|
285
|
+
items?: Array<{
|
|
286
|
+
data?: Array<{
|
|
287
|
+
title?: string;
|
|
288
|
+
description?: string;
|
|
289
|
+
date_created?: string;
|
|
290
|
+
nasa_id?: string;
|
|
291
|
+
media_type?: string;
|
|
292
|
+
center?: string;
|
|
293
|
+
keywords?: string[];
|
|
294
|
+
}>;
|
|
295
|
+
links?: Array<{ href?: string; rel?: string }>;
|
|
296
|
+
}>;
|
|
297
|
+
};
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
const items = data.collection?.items ?? [];
|
|
301
|
+
return {
|
|
302
|
+
query: q,
|
|
303
|
+
total_hits: data.collection?.metadata?.total_hits ?? items.length,
|
|
304
|
+
count: Math.min(items.length, size),
|
|
305
|
+
results: items.slice(0, size).map((it) => {
|
|
306
|
+
const meta = it.data?.[0] ?? {};
|
|
307
|
+
const desc = meta.description ?? '';
|
|
308
|
+
return {
|
|
309
|
+
title: meta.title ?? null,
|
|
310
|
+
description: desc.length > 500 ? `${desc.slice(0, 500)}…` : desc || null,
|
|
311
|
+
date_created: meta.date_created ?? null,
|
|
312
|
+
nasa_id: meta.nasa_id ?? null,
|
|
313
|
+
media_type: meta.media_type ?? null,
|
|
314
|
+
center: meta.center ?? null,
|
|
315
|
+
keywords: meta.keywords ?? [],
|
|
316
|
+
thumbnail: it.links?.find((l) => l.rel === 'preview')?.href ?? it.links?.[0]?.href ?? null,
|
|
317
|
+
};
|
|
318
|
+
}),
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
async function getSolarFlares(startDate: string | undefined, endDate: string | undefined, apiKey: string) {
|
|
323
|
+
const params = new URLSearchParams({ api_key: apiKey });
|
|
324
|
+
if (startDate) params.set('startDate', startDate);
|
|
325
|
+
if (endDate) params.set('endDate', endDate);
|
|
326
|
+
|
|
327
|
+
const res = await fetch(`${BASE_URL}/DONKI/FLR?${params}`);
|
|
328
|
+
if (!res.ok) throw new Error(`NASA DONKI error: ${res.status}`);
|
|
329
|
+
|
|
330
|
+
const data = (await res.json()) as Array<{
|
|
331
|
+
flrID?: string;
|
|
332
|
+
classType?: string;
|
|
333
|
+
beginTime?: string;
|
|
334
|
+
peakTime?: string;
|
|
335
|
+
endTime?: string;
|
|
336
|
+
sourceLocation?: string;
|
|
337
|
+
activeRegionNum?: number | null;
|
|
338
|
+
link?: string;
|
|
339
|
+
}>;
|
|
340
|
+
|
|
341
|
+
return {
|
|
342
|
+
count: data.length,
|
|
343
|
+
flares: data.map((f) => ({
|
|
344
|
+
id: f.flrID ?? null,
|
|
345
|
+
class: f.classType ?? null,
|
|
346
|
+
begin_time: f.beginTime ?? null,
|
|
347
|
+
peak_time: f.peakTime ?? null,
|
|
348
|
+
end_time: f.endTime ?? null,
|
|
349
|
+
source_location: f.sourceLocation ?? null,
|
|
350
|
+
active_region: f.activeRegionNum ?? null,
|
|
351
|
+
link: f.link ?? null,
|
|
352
|
+
})),
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
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
|
+
}
|