Skip to main content
Glama
bobbyyng

Weather MCP Server

by bobbyyng

search_locations

Find supported locations by entering keywords to access weather data. This tool, part of the Weather MCP Server, enables precise location lookup for current conditions and forecasts.

Instructions

Search supported locations

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSearch keyword

Implementation Reference

  • Core implementation of location search: normalizes query, searches locationMapping keys and mockWeatherData location names for matches, returns unique matching location names.
    export function searchLocationsByQuery(query: string): string[] {
      const normalizedQuery = query.toLowerCase();
      const matchingLocations: string[] = [];
      
      // Search in location mapping
      Object.keys(locationMapping).forEach(key => {
        if (key.includes(normalizedQuery)) {
          const location = mockWeatherData[locationMapping[key]]?.location;
          if (location && !matchingLocations.includes(location)) {
            matchingLocations.push(location);
          }
        }
      });
      
      // Search in actual location names
      Object.values(mockWeatherData).forEach(data => {
        if (data.location.toLowerCase().includes(normalizedQuery) && 
            !matchingLocations.includes(data.location)) {
          matchingLocations.push(data.location);
        }
      });
      
      return matchingLocations;
    } 
  • WeatherService method that delegates search_locations tool execution to the core searchLocationsByQuery helper.
    async searchLocations(query: string): Promise<string[]> {
      // Use the enhanced search function from mock-data
      return searchLocationsByQuery(query);
    }
  • Primary MCP server handler for search_locations tool call: extracts query from args, invokes WeatherService.searchLocations, returns JSON stringified result.
    case 'search_locations': {
      const { query } = args as { query: string };
      const locations = await this.weatherService.searchLocations(query);
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(locations, null, 2),
          },
        ],
      };
    }
  • Tool schema and registration in listTools response: defines name, description, and input schema requiring a 'query' string parameter.
    {
      name: 'search_locations',
      description: 'Search supported locations',
      inputSchema: {
        type: 'object',
        properties: {
          query: {
            type: 'string',
            description: 'Search keyword',
          },
        },
        required: ['query'],
      },
    },
  • src/index.ts:35-109 (registration)
    Registration of tools list handler that includes the search_locations tool definition.
    this.server.setRequestHandler(ListToolsRequestSchema, async () => {
      return {
        tools: [
          {
            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'],
            },
          },
          {
            name: 'get_weather_forecast',
            description: 'Get weather forecast for a specified location',
            inputSchema: {
              type: 'object',
              properties: {
                location: {
                  type: 'string',
                  description: 'Location name',
                },
                days: {
                  type: 'number',
                  description: 'Forecast days (1-7 days, default is 3 days)',
                  minimum: 1,
                  maximum: 7,
                },
              },
              required: ['location'],
            },
          },
          {
            name: 'get_weather_alerts',
            description: 'Get weather alert information',
            inputSchema: {
              type: 'object',
              properties: {
                location: {
                  type: 'string',
                  description: 'Location name (optional, if not provided, get all alerts)',
                },
              },
            },
          },
          {
            name: 'search_locations',
            description: 'Search supported locations',
            inputSchema: {
              type: 'object',
              properties: {
                query: {
                  type: 'string',
                  description: 'Search keyword',
                },
              },
              required: ['query'],
            },
          },
          {
            name: 'get_weather_stats',
            description: 'Get weather statistics information',
            inputSchema: {
              type: 'object',
              properties: {},
            },
          },
        ] as Tool[],
      };
    });
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It only states the action ('search') without disclosing behavioral traits like what 'supported locations' means, whether results are paginated, if authentication is needed, or any rate limits. This is inadequate for a tool with zero annotation coverage.

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 a single, efficient sentence with zero waste. It's appropriately sized and front-loaded, making it easy to parse quickly without unnecessary elaboration.

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?

Given no annotations, no output schema, and a simple but vague purpose, the description is incomplete. It doesn't explain what 'supported locations' are, what the search returns, or how it fits into the server context with sibling weather tools, leaving significant gaps for agent understanding.

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?

Schema description coverage is 100%, with the parameter 'query' documented as 'Search keyword'. The description adds no additional meaning beyond this, as it doesn't elaborate on query syntax, examples, or constraints. Baseline 3 is appropriate since the schema does the heavy lifting.

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

Purpose3/5

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

The description 'Search supported locations' states a clear verb ('search') and resource ('locations'), but it's vague about what type of locations and lacks specificity about the search scope. It doesn't distinguish from sibling weather tools, which are unrelated but share the same server context.

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?

No guidance is provided on when to use this tool versus alternatives. The description doesn't mention any context, prerequisites, or exclusions, leaving the agent to infer usage based on the tool name alone.

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