Skip to main content
Glama
kwp-lab

Brave Search With Proxy

brave_local_search

Find local businesses and places with detailed information including addresses, ratings, hours, and contact details. Use for location-based queries like 'restaurants near me' or specific area searches.

Instructions

Searches for local businesses and places using Brave's Local Search API. Best for queries related to physical locations, businesses, restaurants, services, etc. Returns detailed information including:

  • Business names and addresses

  • Ratings and review counts

  • Phone numbers and opening hours Use this when the query implies 'near me' or mentions specific locations. Automatically falls back to web search if no local results are found.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesLocal search query (e.g. 'pizza near Central Park')
countNoNumber of results (1-20, default 5)

Implementation Reference

  • Core handler function that executes the brave_local_search tool logic: performs API calls to Brave for local locations, retrieves POI and description data, formats results with fallback to web search.
    async function performLocalSearch(query: string, count: number = 5) {
      checkRateLimit();
      // Initial search to get location IDs
      const webUrl = new URL('https://api.search.brave.com/res/v1/web/search');
      webUrl.searchParams.set('q', query);
      webUrl.searchParams.set('search_lang', 'en');
      webUrl.searchParams.set('result_filter', 'locations');
      webUrl.searchParams.set('count', Math.min(count, 20).toString());
    
      const webResponse = await fetch(webUrl, {
        headers: {
          'Accept': 'application/json',
          'Accept-Encoding': 'gzip',
          'X-Subscription-Token': BRAVE_API_KEY
        }
      });
    
      if (!webResponse.ok) {
        throw new Error(`Brave API error: ${webResponse.status} ${webResponse.statusText}\n${await webResponse.text()}`);
      }
    
      const webData = await webResponse.json() as BraveWeb;
      const locationIds = webData.locations?.results?.filter((r): r is {id: string; title?: string} => r.id != null).map(r => r.id) || [];
    
      if (locationIds.length === 0) {
        return performWebSearch(query, count); // Fallback to web search
      }
    
      // Get POI details and descriptions in parallel
      const [poisData, descriptionsData] = await Promise.all([
        getPoisData(locationIds),
        getDescriptionsData(locationIds)
      ]);
    
      return formatLocalResults(poisData, descriptionsData);
    }
  • index.ts:47-73 (registration)
    Tool registration definition including name, description, and input schema for brave_local_search.
    const LOCAL_SEARCH_TOOL: Tool = {
      name: "brave_local_search",
      description:
        "Searches for local businesses and places using Brave's Local Search API. " +
        "Best for queries related to physical locations, businesses, restaurants, services, etc. " +
        "Returns detailed information including:\n" +
        "- Business names and addresses\n" +
        "- Ratings and review counts\n" +
        "- Phone numbers and opening hours\n" +
        "Use this when the query implies 'near me' or mentions specific locations. " +
        "Automatically falls back to web search if no local results are found.",
      inputSchema: {
        type: "object",
        properties: {
          query: {
            type: "string",
            description: "Local search query (e.g. 'pizza near Central Park')"
          },
          count: {
            type: "number",
            description: "Number of results (1-20, default 5)",
            default: 5
          },
        },
        required: ["query"]
      }
    };
  • Schema validation type guard for brave_local_search arguments.
    function isBraveLocalSearchArgs(args: unknown): args is { query: string; count?: number } {
      return (
        typeof args === "object" &&
        args !== null &&
        "query" in args &&
        typeof (args as { query: string }).query === "string"
      );
    }
  • Dispatch handler case in CallToolRequestHandler for executing brave_local_search.
    case "brave_local_search": {
      if (!isBraveLocalSearchArgs(args)) {
        throw new Error("Invalid arguments for brave_local_search");
      }
      const { query, count = 5 } = args;
      const results = await performLocalSearch(query, count);
      return {
        content: [{ type: "text", text: results }],
        isError: false,
      };
    }
  • index.ts:318-320 (registration)
    Registers LOCAL_SEARCH_TOOL (brave_local_search) in the list of available tools.
    server.setRequestHandler(ListToolsRequestSchema, async () => ({
      tools: [WEB_SEARCH_TOOL, LOCAL_SEARCH_TOOL],
    }));

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.4/5.0
Behavior4/5

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

No annotations provided, so the description carries full burden. It discloses automatic fallback to web search and lists returned information (names, ratings, hours). It lacks details on rate limits or authorization, but the key behavior is transparent.

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 concise paragraph with bullet points. It front-loads the purpose, then gives usage context, return info, and a fallback note. No unnecessary words, well-organized.

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

Completeness4/5

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

No output schema, but description explains return details (business names, addresses, ratings, etc.) and fallback behavior. It misses error handling or pagination, but for a local search tool with two simple params, it is sufficiently complete.

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

Parameters4/5

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

Schema coverage is 100% (both params described), baseline 3. The description adds meaning by specifying query examples ('pizza near Central Park') and default count behavior, plus clarifies what the return values include. This goes beyond schema.

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

Purpose5/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 local businesses and places using Brave's Local Search API. It distinguishes from siblings like brave_web_search by specifying physical locations and business entities, and notes a fallback to web search.

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

Usage Guidelines4/5

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

The description explicitly says 'Best for queries related to physical locations' and 'Use this when the query implies "near me" or mentions specific locations,' providing clear when-to-use guidance. It does not explicitly state when not to use, but the context is strong.

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