Skip to main content
Glama
v4lheru

generic-mcp-server

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
NameRequiredDescriptionDefault
cityYesThe city name

Implementation Reference

  • 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}`,
                },
            ],
        };
    },
  • 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}`,
                    },
                ],
            };
        },
    },
Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/v4lheru/generic-mcp-template'

If you have feedback or need assistance with the MCP directory API, please join our Discord server