Skip to content

Commit 55eb348

Browse files
use underscore for parameters and transform where needed
1 parent 6ace883 commit 55eb348

File tree

13 files changed

+83
-32
lines changed

13 files changed

+83
-32
lines changed

docs/inspector-test-examples.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ Get fireball data:
301301
{
302302
"method": "jpl/fireball",
303303
"params": {
304-
"date-min": "2022-01-01",
304+
"date_min": "2022-01-01",
305305
"limit": 5
306306
}
307307
}

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@programcomputer/nasa-mcp-server",
3-
"version": "1.0.11",
3+
"version": "1.0.12",
44
"description": "Model Context Protocol (MCP) server for NASA APIs",
55
"main": "dist/index.js",
66
"files": [

src/handlers/jpl/cad.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import axios from 'axios';
22
import { addResource } from '../../resources';
3+
import { transformParamsToHyphenated } from '../../utils/param-transformer';
34

45
/**
56
* Handler for JPL SB Close Approach (CAD) API
@@ -18,8 +19,11 @@ export async function cadHandler(args: Record<string, any>) {
1819
// Validate parameters if needed
1920
// Parameters are fairly flexible in this API, so minimal validation is needed
2021

22+
// Transform parameter names from underscore to hyphenated format
23+
const transformedParams = transformParamsToHyphenated(args);
24+
2125
// Make the API request
22-
const response = await axios.get(baseUrl, { params: args });
26+
const response = await axios.get(baseUrl, { params: transformedParams });
2327
const data = response.data;
2428

2529
// Create a resource URI that represents this query
@@ -43,8 +47,8 @@ export async function cadHandler(args: Record<string, any>) {
4347
resourceUri = `jpl://cad/list${constraints ? '?' + constraints : ''}`;
4448

4549
// Create a readable name based on date range and body
46-
const dateMin = args['date-min'] || 'now';
47-
const dateMax = args['date-max'] || '+60';
50+
const dateMin = args['date_min'] || 'now';
51+
const dateMax = args['date_max'] || '+60';
4852
const body = args.body || 'Earth';
4953

5054
resourceName = `Close approaches to ${body} from ${dateMin} to ${dateMax}`;

src/handlers/jpl/fireball.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { z } from 'zod';
22
import axios from 'axios';
3+
import { transformParamsToHyphenated } from '../../utils/param-transformer';
34

45
// Schema for validating JPL Fireball request parameters
56
export const fireballParamsSchema = z.object({
@@ -33,8 +34,11 @@ export async function jplFireballHandler(params: FireballParams) {
3334
// Construct the Fireball API URL
3435
const url = 'https://ssd-api.jpl.nasa.gov/fireball.api';
3536

37+
// Transform parameter names from underscore to hyphenated format
38+
const transformedParams = transformParamsToHyphenated(params);
39+
3640
// Make the request to the Fireball API
37-
const response = await axios.get(url, { params });
41+
const response = await axios.get(url, { params: transformedParams });
3842

3943
return {
4044
content: [

src/handlers/jpl/jd_cal.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import axios from 'axios';
22
import { addResource } from '../../resources';
3+
import { transformParamsToHyphenated } from '../../utils/param-transformer';
34

45
/**
56
* Handler for JPL Julian Date Calendar Conversion API
@@ -25,8 +26,11 @@ export async function jdCalHandler(args: Record<string, any>) {
2526
};
2627
}
2728

29+
// Transform parameter names from underscore to hyphenated format
30+
const transformedParams = transformParamsToHyphenated(args);
31+
2832
// Make the API request
29-
const response = await axios.get(baseUrl, { params: args });
33+
const response = await axios.get(baseUrl, { params: transformedParams });
3034
const data = response.data;
3135

3236
// Add response to resources

src/handlers/jpl/nhats.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import axios from 'axios';
22
import { addResource } from '../../resources';
3+
import { transformParamsToHyphenated } from '../../utils/param-transformer';
34

45
/**
56
* Handler for JPL NHATS API (Human-accessible NEOs data)
@@ -18,8 +19,11 @@ export async function nhatsHandler(args: Record<string, any>) {
1819
// Validate parameters if needed
1920
// Parameters are fairly flexible in this API, so minimal validation is needed
2021

22+
// Transform parameter names from underscore to hyphenated format
23+
const transformedParams = transformParamsToHyphenated(args);
24+
2125
// Make the API request
22-
const response = await axios.get(baseUrl, { params: args });
26+
const response = await axios.get(baseUrl, { params: transformedParams });
2327
const data = response.data;
2428

2529
// Create a resource URI that represents this query

src/handlers/jpl/periodic_orbits.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import axios from 'axios';
22
import { addResource } from '../../resources';
3+
import { transformParamsToHyphenated } from '../../utils/param-transformer';
34

45
// Define expected parameters based on documentation
56
// Required: sys, family
@@ -36,8 +37,11 @@ export async function periodicOrbitsHandler(args: PeriodicOrbitParams) {
3637
// Base URL for the Periodic Orbits API
3738
const baseUrl = 'https://ssd-api.jpl.nasa.gov/periodic_orbits.api';
3839

40+
// Transform parameter names from underscore to hyphenated format
41+
const transformedParams = transformParamsToHyphenated(args);
42+
3943
// Make the API request using GET with parameters
40-
const response = await axios.get(baseUrl, { params: args });
44+
const response = await axios.get(baseUrl, { params: transformedParams });
4145
const data = response.data;
4246

4347
// Create a resource URI

src/handlers/jpl/sbdb.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { z } from 'zod';
22
import axios from 'axios';
3+
import { transformParamsToHyphenated } from '../../utils/param-transformer';
34

45
// Schema for validating JPL Small-Body Database request parameters
56
export const sbdbParamsSchema = z.object({
@@ -58,8 +59,11 @@ export async function jplSbdbHandler(params: SbdbParams) {
5859
if (ca_tbl !== 'approach') queryParams.ca_tbl = ca_tbl;
5960
if (format !== 'json') queryParams.format = format;
6061

62+
// Transform parameter names from underscore to hyphenated format
63+
const transformedParams = transformParamsToHyphenated(queryParams);
64+
6165
// Make the request to SBDB API
62-
const response = await axios.get(url, { params: queryParams });
66+
const response = await axios.get(url, { params: transformedParams });
6367

6468
// Return the response
6569
return {

src/handlers/jpl/sentry.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import axios from 'axios';
22
import { addResource } from '../../resources';
3+
import { transformParamsToHyphenated } from '../../utils/param-transformer';
34

45
/**
56
* Handler for JPL Sentry API
@@ -14,8 +15,11 @@ export async function sentryHandler(args: Record<string, any>) {
1415
// Base URL for the Sentry API
1516
const baseUrl = 'https://ssd-api.jpl.nasa.gov/sentry.api';
1617

18+
// Transform parameter names from underscore to hyphenated format
19+
const transformedParams = transformParamsToHyphenated(args);
20+
1721
// Make the API request
18-
const response = await axios.get(baseUrl, { params: args });
22+
const response = await axios.get(baseUrl, { params: transformedParams });
1923
const data = response.data;
2024

2125
// Create a resource URI that represents this query

0 commit comments

Comments
 (0)