Skip to main content
Glama
modelcontextprotocol

MCP-Brave-Search

brave_local_search

Find local businesses and places with detailed information including addresses, ratings, hours, and contact details using location-based search queries.

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: queries Brave web API for local locations, fetches POI details and descriptions if found, formats results, falls back to web search otherwise.
    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);
    }
  • Dispatch handler in CallToolRequestSchema that validates arguments and invokes performLocalSearch for the brave_local_search tool.
    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,
      };
    }
  • Tool 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"]
      }
    };
  • Type guard function for validating input arguments to brave_local_search.
    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"
      );
    }
  • Registers the available tools list including brave_local_search via ListToolsRequestSchema handler.
    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 of behavioral disclosure. It effectively describes key behaviors: it's a search operation (implied read-only), specifies the data source (Brave's Local Search API), lists the type of information returned (business details, ratings, etc.), and mentions the fallback to web search. However, it doesn't cover potential limitations like rate limits, authentication needs, or error handling, leaving some 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 well-structured and concise. It starts with the core purpose, followed by usage guidelines, return details in a bulleted list, and ends with behavioral notes. Every sentence adds value without redundancy, making it easy to parse and front-loaded with essential information.

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 (search with fallback), no annotations, and no output schema, the description does a good job of covering key aspects: purpose, usage, returned data, and behavior. However, it lacks details on output structure (e.g., format of returned results) and error cases, which would be helpful for an agent to handle responses appropriately. This is a minor gap in an otherwise comprehensive description.

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 schema description coverage is 100%, so the schema already documents both parameters ('query' and 'count') with their types, descriptions, and defaults. The description adds no additional parameter semantics beyond what's in the schema, such as examples or constraints not already covered. This meets the baseline for high schema coverage.

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's purpose: 'Searches for local businesses and places using Brave's Local Search API.' It specifies the resource (local businesses/places) and distinguishes it from its sibling 'brave_web_search' by focusing on physical locations. The description is specific and avoids tautology.

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: 'Best for queries related to physical locations, businesses, restaurants, services, etc.' and 'Use this when the query implies 'near me' or mentions specific locations.' It also mentions an alternative behavior ('Automatically falls back to web search if no local results are found'), though not explicitly naming the sibling tool. This gives clear context for selection.

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/modelcontextprotocol/servers-archived'

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