Skip to main content
Glama
samwang0723

Restaurant Booking MCP Server

search_restaurants

Find top 3 AI-recommended restaurants within 3km radius based on location, cuisine type, mood, event, or specific food keywords. Simplify your dining choices with tailored suggestions.

Instructions

Search for restaurants based on location, cuisine types, mood, and event type. Returns top 3 AI-recommended restaurants within 3km radius. You can also search for specific food types using keywords.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cuisineTypesNoArray of preferred cuisine types (e.g., ["Italian", "Japanese", "Mexican"])
eventYesType of event or occasion
keywordNoSearch for specific food types or dishes (e.g., "hotpot", "sushi", "pizza", "ramen", "dim sum", "barbecue")
latitudeNoLatitude of the search location (default: 24.1501164 - Taiwan)
localeNoLocale for search results and Google API responses (e.g., "en" for English, "zh-TW" for Traditional Chinese, "ja" for Japanese, "ko" for Korean, "th" for Thai). Affects restaurant names, reviews, and other text content.en
longitudeNoLongitude of the search location (default: 120.6692299 - Taiwan)
moodYesDesired mood/atmosphere (e.g., "romantic", "casual", "upscale", "fun", "quiet")
placeNameNoPlace name to search near (e.g., "New York", "Tokyo", "London"). Alternative to providing latitude/longitude coordinates.
priceLevelNoPrice level preference (1=inexpensive, 4=very expensive)
radiusNoSearch radius in meters (default: 3000 = 3km)

Implementation Reference

  • src/index.ts:57-135 (registration)
    Registers the 'search_restaurants' MCP tool, defining its name, title, description, detailed Zod input schema for parameters like location, cuisine, mood, etc., and the handler callback.
    server.registerTool(
      'search_restaurants',
      {
        title: 'Search for restaurants',
        description:
          'Search for restaurants based on location, cuisine, keyword, mood, event, radius, price level, and locale',
        inputSchema: {
          latitude: z
            .number()
            .optional()
            .describe(
              `Latitude of the search location (default: ${DEFAULT_LATITUDE} - Taiwan)`
            ),
          longitude: z
            .number()
            .optional()
            .describe(
              `Longitude of the search location (default: ${DEFAULT_LONGITUDE} - Taiwan)`
            ),
          placeName: z
            .string()
            .optional()
            .describe(
              'Place name to search near (e.g., "New York", "Tokyo", "London"). Alternative to providing latitude/longitude coordinates.'
            ),
          cuisineTypes: z
            .array(z.string())
            .optional()
            .describe(
              'Array of preferred cuisine types (e.g., ["Italian", "Japanese", "Mexican"])'
            ),
          keyword: z
            .string()
            .optional()
            .describe(
              'Search for specific food types or dishes (e.g., "hotpot", "sushi", "pizza", "ramen", "dim sum", "barbecue")'
            ),
          mood: z
            .string()
            .describe(
              'Desired mood/atmosphere (e.g., "romantic", "casual", "upscale", "fun", "quiet")'
            ),
          event: z
            .string()
            .describe(
              "Type of event or occasion (e.g., 'dating', 'gathering', 'business', 'casual', 'celebration')"
            ),
          radius: z
            .number()
            .optional()
            .describe(
              `Search radius in meters (default: ${DEFAULT_SEARCH_RADIUS} = ${DEFAULT_SEARCH_RADIUS / 1000}km)`
            ),
          priceLevel: z
            .number()
            .min(1)
            .max(4)
            .optional()
            .describe(
              'Price level preference (1=inexpensive, 4=very expensive)'
            ),
          locale: z
            .string()
            .optional()
            .describe(
              'Locale for search results and Google API responses (e.g., "en" for English, "zh-TW" for Traditional Chinese, "ja" for Japanese, "ko" for Korean, "th" for Thai). Affects restaurant names, reviews, and other text content.'
            ),
          strictCuisineFiltering: z
            .boolean()
            .optional()
            .describe(
              'If true, only restaurants that match the specified cuisine types will be returned. If false (default), all restaurants will be returned but cuisine matches will be scored higher.'
            ),
        },
      },
      async args => {
        return await this.handleSearchRestaurants(args);
      }
    );
  • Main execution handler for the tool. Parses arguments into RestaurantSearchParams, performs restaurant search via GoogleMapsService, generates ranked recommendations using RestaurantRecommendationService, and returns formatted JSON output with search criteria, total found, and top recommendations.
    private async handleSearchRestaurants(args: any) {
      const searchParams: RestaurantSearchParams = {
        // Only include location if placeName is not provided
        ...(args.placeName
          ? { placeName: args.placeName }
          : {
              location: {
                latitude: args.latitude || DEFAULT_LATITUDE,
                longitude: args.longitude || DEFAULT_LONGITUDE,
              },
            }),
        cuisineTypes: args.cuisineTypes || [],
        keyword: args.keyword,
        mood: args.mood,
        event: args.event,
        radius: args.radius || DEFAULT_SEARCH_RADIUS,
        priceLevel: args.priceLevel,
        locale: args.locale || 'en',
        strictCuisineFiltering: args.strictCuisineFiltering || false,
      };
    
      // Search for restaurants
      const restaurants =
        await this.googleMapsService.searchRestaurants(searchParams);
    
      if (restaurants.length === 0) {
        return {
          content: [
            {
              type: 'text' as const,
              text: 'No restaurants found matching your criteria. Try expanding your search radius or adjusting your preferences.',
            },
          ],
        };
      }
    
      // Get AI recommendations
      const recommendations = await this.recommendationService.getRecommendations(
        restaurants,
        searchParams
      );
    
      const result = {
        searchCriteria: searchParams,
        totalFound: restaurants.length,
        recommendations: recommendations.map(rec => ({
          restaurant: {
            placeId: rec.restaurant.placeId,
            name: rec.restaurant.name,
            address: rec.restaurant.address,
            rating: rec.restaurant.rating,
            userRatingsTotal: rec.restaurant.userRatingsTotal,
            priceLevel: rec.restaurant.priceLevel,
            cuisineTypes: rec.restaurant.cuisineTypes,
            phoneNumber: rec.restaurant.phoneNumber,
            website: rec.restaurant.website,
            googleMapsUrl: rec.restaurant.googleMapsUrl,
            openingHours: rec.restaurant.openingHours,
            distance: rec.restaurant.distance,
            bookingInfo: rec.restaurant.bookingInfo,
            reservable: rec.restaurant.reservable,
            curbsidePickup: rec.restaurant.curbsidePickup,
            delivery: rec.restaurant.delivery,
            dineIn: rec.restaurant.dineIn,
            takeout: rec.restaurant.takeout,
            servesBreakfast: rec.restaurant.servesBreakfast,
            servesLunch: rec.restaurant.servesLunch,
            servesDinner: rec.restaurant.servesDinner,
            servesBrunch: rec.restaurant.servesBrunch,
            servesBeer: rec.restaurant.servesBeer,
            servesWine: rec.restaurant.servesWine,
            servesVegetarianFood: rec.restaurant.servesVegetarianFood,
          },
          score: Math.round(rec.score * 10) / 10,
          reasoning: rec.reasoning,
          suitabilityForEvent: rec.suitabilityForEvent,
          moodMatch: rec.moodMatch,
        })),
      };
    
      return {
        content: [
          {
            type: 'text' as const,
            text: JSON.stringify(result, null, 2),
          },
        ],
      };
    }
  • Key helper function implementing the restaurant search logic using Google Places API Text Search or Nearby Search, handling various parameter combinations, API field selection for restaurant data, result conversion including cuisine extraction, distance calculation, and booking info analysis.
    async searchRestaurants(
      params: RestaurantSearchParams
    ): Promise<Restaurant[]> {
      try {
        const {
          location,
          placeName,
          cuisineTypes,
          keyword,
          radius = 2000,
          locale = 'en',
        } = params;
    
        // Build search query for Text Search API
        let textQuery = '';
    
        // If keyword is provided, prioritize it
        if (keyword) {
          textQuery = keyword;
          // Add location context
          if (placeName) {
            textQuery += ` in ${placeName}`;
          }
          // If cuisine types are also provided, combine them
          if (cuisineTypes && cuisineTypes.length > 0) {
            textQuery += ` ${cuisineTypes.join(' OR ')}`;
          }
        } else {
          // Build query from cuisine types and location
          const cuisineQuery =
            cuisineTypes && cuisineTypes.length > 0
              ? cuisineTypes.join(' OR ') + ' restaurant'
              : 'good restaurant';
    
          if (placeName) {
            textQuery = `${cuisineQuery} in ${placeName}`;
          } else {
            textQuery = cuisineQuery;
          }
        }
    
        // Prepare field mask based on required fields
        const fieldMask = this.getSearchFieldMask();
    
        // Build request for Text Search API
        let request;
        let response;
    
        // Use searchNearby only when we have coordinates AND no specific cuisine is requested
        if (
          location &&
          (!cuisineTypes || cuisineTypes.length === 0) &&
          !placeName
        ) {
          request = {
            includedTypes: ['restaurant'],
            locationRestriction: {
              circle: {
                center: {
                  latitude: location.latitude,
                  longitude: location.longitude,
                },
                radius: radius,
              },
            },
            maxResultCount: 20,
            languageCode: locale,
          };
          console.info('request', request);
          response = await this.client.searchNearby(request, {
            otherArgs: {
              headers: {
                'X-Goog-FieldMask': fieldMask,
              },
            },
          });
        } else {
          // Use searchText for:
          // 1. Place name searches (with or without cuisine)
          // 2. Coordinate searches with specific cuisine
          // 3. Keyword searches
          if (location && !placeName) {
            // Coordinate-based search with cuisine - add location bias
            request = {
              textQuery,
              locationBias: {
                circle: {
                  center: {
                    latitude: location.latitude,
                    longitude: location.longitude,
                  },
                  radius: radius,
                },
              },
              maxResultCount: 20,
              languageCode: locale,
            };
          } else {
            // Place name search or no location provided
            request = {
              textQuery,
              maxResultCount: 20,
              languageCode: locale,
            };
          }
          console.info('request', request);
          response = await this.client.searchText(request, {
            otherArgs: {
              headers: {
                'X-Goog-FieldMask': fieldMask,
              },
            },
          });
        }
    
        if (!response?.[0]?.places) {
          return [];
        }
    
        const places = response[0].places;
    
        // Convert API response to Restaurant objects
        const restaurants: Restaurant[] = [];
    
        for (const place of places) {
          try {
            const restaurant = this.convertPlaceToRestaurant(place, location);
            if (restaurant) {
              restaurants.push(restaurant);
            }
          } catch (error) {
            console.error('Error converting place to restaurant:', error);
          }
        }
    
        // Sort restaurants by distance if location provided
        if (location) {
          restaurants.sort((a, b) => {
            const distanceA = a.distance || 0;
            const distanceB = b.distance || 0;
            return distanceA - distanceB;
          });
        }
    
        return restaurants;
      } catch (error) {
        console.error('Error searching restaurants:', error);
        throw new Error(
          `Failed to search restaurants: ${
            error instanceof Error ? error.message : 'Unknown error'
          }`
        );
      }
    }
  • TypeScript interface defining the structure of search parameters used throughout the tool handler and services for type safety.
    export interface RestaurantSearchParams {
      location?: Location; // Made optional when placeName is provided
      placeName?: string; // 🆕 NEW: Alternative to location - place name to geocode
      cuisineTypes: string[];
      mood: string;
      event: string;
      radius?: number; // in meters, default 20km
      priceLevel?: 1 | 2 | 3 | 4; // 1 = inexpensive, 4 = very expensive
      keyword?: string; // 🆕 NEW: Search for specific food types like "hotpot", "sushi", "pizza", etc.
      locale?: string; // 🆕 NEW: Locale for search results (e.g., "en", "zh-TW", "ja", "ko")
      strictCuisineFiltering?: boolean; // 🆕 NEW: If true, exclude restaurants that don't match cuisine criteria
    }
Behavior3/5

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

With no annotations provided, the description carries full burden. It discloses key behavioral traits: returns top 3 AI-recommended restaurants, operates within 3km radius (implied default), and uses Google API for locale-specific results. However, it doesn't mention rate limits, authentication needs, error conditions, or whether this is a read-only operation (though 'search' implies it).

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

Conciseness4/5

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

Two sentences that efficiently cover purpose and additional capability (keyword search). The first sentence front-loads core functionality with key parameters and output details. No wasted words, though it could be slightly more structured by separating constraints from capabilities.

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

Completeness3/5

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

For a 10-parameter search tool with no annotations and no output schema, the description provides adequate but incomplete context. It covers what the tool does and key constraints (top 3, 3km radius), but lacks details about return format, error handling, or how AI recommendations work. The schema compensates for parameter documentation, but behavioral aspects remain partially uncovered.

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%, so the schema already documents all 10 parameters thoroughly. The description adds marginal value by mentioning location, cuisine types, mood, event type, and keywords as search criteria, but doesn't provide additional syntax or format details beyond what's in the schema descriptions. Baseline 3 is appropriate when schema does heavy lifting.

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 tool searches for restaurants based on multiple criteria (location, cuisine types, mood, event type, keywords) and returns top 3 AI-recommended results within a 3km radius. It specifies the verb 'search' and resource 'restaurants' with scope details, though it doesn't explicitly differentiate from sibling tools like 'get_restaurant_details'.

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

Usage Guidelines3/5

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

The description implies usage for finding restaurants with various filters, but doesn't explicitly state when to use this tool versus alternatives like 'get_restaurant_details' or 'check_availability'. It mentions 'you can also search for specific food types using keywords', which provides some context but lacks clear exclusions or comparisons to sibling tools.

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/samwang0723/mcp-booking'

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