Skip to main content
Glama
bobbyyng

Weather MCP Server

by bobbyyng

get_current_weather

Retrieve real-time weather data for any specified location using the Weather MCP Server. Input a location name to fetch current conditions instantly.

Instructions

Get current weather information for a specified location

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
locationYesLocation name (e.g., Hong Kong, Tokyo, London)

Implementation Reference

  • Core handler function that implements the get_current_weather tool logic: normalizes the input location, fetches mock weather data if available, or generates random data, and adds a current timestamp.
    async getCurrentWeather(location: string): Promise<WeatherData> {
      // Normalize location name using location mapping
      const normalizedLocation = this.normalizeLocation(location);
      
      if (mockWeatherData[normalizedLocation]) {
        return {
          ...mockWeatherData[normalizedLocation],
          timestamp: new Date().toISOString()
        };
      }
      
      // If location not found, return random weather data
      const randomData = getRandomWeatherData();
      return {
        ...randomData,
        location: location,
        timestamp: new Date().toISOString()
      };
    }
  • TypeScript interface defining the structure of the WeatherData returned by the get_current_weather tool.
    export interface WeatherData {
      location: string;
      temperature: number;
      humidity: number;
      windSpeed: number;
      windDirection: string;
      condition: string;
      description: string;
      pressure: number;
      visibility: number;
      uvIndex: number;
      timestamp: string;
    }
  • src/index.ts:38-51 (registration)
    Tool registration in the stdio MCP server (index.ts): defines name, description, and input schema for list tools response.
    {
      name: 'get_current_weather',
      description: 'Get current weather information for a specified location',
      inputSchema: {
        type: 'object',
        properties: {
          location: {
            type: 'string',
            description: 'Location name (e.g., Hong Kong, Tokyo, London)',
          },
        },
        required: ['location'],
      },
    },
  • src/index.ts:117-128 (registration)
    Tool call handler dispatch in stdio MCP server: handles 'get_current_weather' case by calling the weather service and formatting response.
    case 'get_current_weather': {
      const { location } = args as { location: string };
      const weather = await this.weatherService.getCurrentWeather(location);
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(weather, null, 2),
          },
        ],
      };
    }
  • Helper method used by the handler to normalize location strings for lookup in mock data.
    private normalizeLocation(location: string): string {
      const lowerLocation = location.toLowerCase().trim();
      
      // Check if location exists in mapping
      if (locationMapping[lowerLocation]) {
        return locationMapping[lowerLocation];
      }
      
      // Fallback to original normalization
      return lowerLocation
        .replace(/\s+/g, '-')
        .replace(/[^a-z0-9-]/g, '');
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions nothing about rate limits, authentication needs, data freshness, error conditions, or response format. 'Get current weather information' implies a read-only operation, but this isn't explicitly stated.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is perfectly concise - a single sentence that communicates the core functionality without any wasted words. It's front-loaded with the essential information and earns its place efficiently.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with no annotations and no output schema, the description is insufficiently complete. It doesn't explain what 'current weather information' includes, how recent the data is, potential limitations, or what format the response takes. Given the lack of structured metadata, the description should provide more operational context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds minimal value beyond the input schema, which already has 100% coverage with a clear parameter description. The description mentions 'for a specified location' which aligns with the schema's 'location' parameter, but provides no additional semantic context about location formats or constraints.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Get current weather information') and target resource ('for a specified location'), making the purpose immediately understandable. It doesn't explicitly differentiate from sibling tools like get_weather_forecast or get_weather_alerts, which prevents a perfect score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like get_weather_forecast or get_weather_alerts. It simply states what the tool does without context about appropriate use cases or exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related 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/bobbyyng/weather-mcp-ts'

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