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],
    }));
Behavior4/5

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

With no annotations provided, the description carries the full burden and does well by disclosing key behavioral traits: it describes the fallback mechanism to web search, specifies the types of information returned (business names, addresses, ratings, etc.), and implies it's a read-only search operation. However, it doesn't mention rate limits, authentication needs, or error handling, which are minor gaps.

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 appropriately sized and front-loaded, starting with the core purpose, followed by usage guidelines and return details in a bulleted list for clarity. Every sentence earns its place by adding value without redundancy, making it efficient and well-structured.

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?

Given the tool's moderate complexity (2 parameters, no output schema, no annotations), the description is largely complete: it covers purpose, usage, behavior, and return information. However, without an output schema, it could benefit from more detail on the exact structure of returned data (e.g., JSON format), but the bulleted list provides sufficient context for most use cases.

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 both parameters thoroughly. The description adds minimal value beyond the schema by implying the 'query' parameter should be location-focused (e.g., 'near me'), but doesn't provide additional syntax or format details. This meets the baseline of 3 when schema coverage is high.

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 specific action ('Searches for local businesses and places') and resource ('using Brave's Local Search API'), distinguishing it from the sibling tool 'brave_web_search' by focusing on physical locations and businesses. It explicitly mentions what it's best for (queries related to physical locations, businesses, restaurants, services).

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

Usage Guidelines5/5

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

The description provides explicit guidance on when to use this tool ('when the query implies 'near me' or mentions specific locations') and distinguishes it from alternatives by mentioning it 'Automatically falls back to web search if no local results are found,' implying the sibling tool might be for non-local queries. It also specifies what it's best for versus general cases.

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

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/kwp-lab/mcp-brave-search'

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