chore: update dependencies and refactor tool registration

- Updated devDependencies:
  - @types/node from ^22.10.0 to ^22.19.2
  - typescript from ^5.7.2 to ^5.9.3
- Updated @modelcontextprotocol/sdk from ^1.4.0 to ^1.24.3
- Refactored tool registration to use registerTool method instead of tool
- Enhanced tool definitions with title, description, and inputSchema for better clarity
This commit is contained in:
云游君 2025-12-12 07:52:08 +00:00
commit 880fa08865
3 changed files with 897 additions and 72 deletions

File diff suppressed because it is too large Load diff

View file

@ -17,10 +17,10 @@
"license": "ISC", "license": "ISC",
"description": "", "description": "",
"devDependencies": { "devDependencies": {
"@types/node": "^22.10.0", "@types/node": "^22.19.2",
"typescript": "^5.7.2" "typescript": "^5.9.3"
}, },
"dependencies": { "dependencies": {
"@modelcontextprotocol/sdk": "^1.4.0" "@modelcontextprotocol/sdk": "^1.24.3"
} }
} }

View file

@ -79,12 +79,15 @@ const server = new McpServer({
}); });
// Register weather tools // Register weather tools
server.tool( server.registerTool(
"get-alerts", "get-alerts",
"Get weather alerts for a state",
{ {
title: "Get Weather Alerts",
description: "Get weather alerts for a state",
inputSchema: {
state: z.string().length(2).describe("Two-letter state code (e.g. CA, NY)"), state: z.string().length(2).describe("Two-letter state code (e.g. CA, NY)"),
}, },
},
async ({ state }) => { async ({ state }) => {
const stateCode = state.toUpperCase(); const stateCode = state.toUpperCase();
const alertsUrl = `${NWS_API_BASE}/alerts?area=${stateCode}`; const alertsUrl = `${NWS_API_BASE}/alerts?area=${stateCode}`;
@ -127,10 +130,12 @@ server.tool(
}, },
); );
server.tool( server.registerTool(
"get-forecast", "get-forecast",
"Get weather forecast for a location",
{ {
title: "Get Weather Forecast",
description: "Get weather forecast for a location",
inputSchema: {
latitude: z.number().min(-90).max(90).describe("Latitude of the location"), latitude: z.number().min(-90).max(90).describe("Latitude of the location"),
longitude: z longitude: z
.number() .number()
@ -138,6 +143,7 @@ server.tool(
.max(180) .max(180)
.describe("Longitude of the location"), .describe("Longitude of the location"),
}, },
},
async ({ latitude, longitude }) => { async ({ latitude, longitude }) => {
// Get grid point data // Get grid point data
const pointsUrl = `${NWS_API_BASE}/points/${latitude.toFixed(4)},${longitude.toFixed(4)}`; const pointsUrl = `${NWS_API_BASE}/points/${latitude.toFixed(4)},${longitude.toFixed(4)}`;