get-weather
Retrieve weather forecast data for a specified city to check current conditions and upcoming weather patterns.
Instructions
Get weather forecast for a city
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| city | Yes | The city name |
Implementation Reference
- src/tools.ts:26-37 (handler)The handler function that executes the get-weather tool logic, generating a mock weather forecast for the given city.handler: async ({ city }: { city: string }) => { // Mock implementation const weather = ["Sunny", "Cloudy", "Rainy"][Math.floor(Math.random() * 3)]; return { content: [ { type: "text" as const, text: `The weather in ${city} is ${weather}`, }, ], }; },
- src/tools.ts:23-25 (schema)The Zod input schema defining the 'city' parameter for the get-weather tool.inputSchema: z.object({ city: z.string().describe("The city name"), }),
- src/tools.ts:21-38 (registration)The get-weather tool is registered in the TOOLS object exported from tools.ts, which is used by the MCP server for listing and calling tools."get-weather": { description: "Get weather forecast for a city", inputSchema: z.object({ city: z.string().describe("The city name"), }), handler: async ({ city }: { city: string }) => { // Mock implementation const weather = ["Sunny", "Cloudy", "Rainy"][Math.floor(Math.random() * 3)]; return { content: [ { type: "text" as const, text: `The weather in ${city} is ${weather}`, }, ], }; }, },