Skip to main content
Glama
mikechao

Brave Search MCP

brave_web_search

Search the web using Brave Search API to gather diverse results, track recent events, or explore broad topics. Supports up to 20 results per query with pagination options.

Instructions

Performs a web search using the Brave Search API, ideal for general queries, and online content. Use this for broad information gathering, recent events, or when you need diverse web sources. Maximum 20 results per request

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
countNoThe number of results to return, minimum 1, maximum 20
offsetNoThe offset for pagination, minimum 0
queryYesThe term to search the internet for

Implementation Reference

  • The executeCore method implements the core logic of the brave_web_search tool, performing the web search via BraveSearch API, processing results, and returning formatted text content.
    public async executeCore(input: z.infer<typeof webSearchInputSchema>) {
      const { query, count, offset, freshness } = input;
      const results = await this.braveSearch.webSearch(query, {
        count,
        offset,
        safesearch: SafeSearchLevel.Strict,
        ...(freshness ? { freshness } : {}),
      });
      if (!results.web || results.web?.results.length === 0) {
        this.braveMcpServer.log(`No results found for "${query}"`);
        const text = `No results found for "${query}"`;
        return { content: [{ type: 'text' as const, text }] };
      }
      const text = results.web.results.map(result => `Title: ${result.title}\nURL: ${result.url}\nDescription: ${result.description}`).join('\n\n');
      return { content: [{ type: 'text' as const, text }] };
    }
  • Zod input schema defining parameters for the brave_web_search tool: query, count, offset, and freshness.
    const webSearchInputSchema = z.object({
      query: z.string().describe('The term to search the internet for'),
      count: z.number().min(1).max(20).default(10).optional().describe('The number of results to return, minimum 1, maximum 20'),
      offset: z.number().min(0).default(0).optional().describe('The offset for pagination, minimum 0'),
      freshness: z.union([
        z.enum(['pd', 'pw', 'pm', 'py']),
        z.string().regex(/^\d{4}-\d{2}-\d{2}to\d{4}-\d{2}-\d{2}$/, 'Date range must be in format YYYY-MM-DDtoYYYY-MM-DD')
      ])
        .optional()
        .describe(
          `Filters search results by when they were discovered.
    The following values are supported:
    - pd: Discovered within the last 24 hours.
    - pw: Discovered within the last 7 Days.
    - pm: Discovered within the last 31 Days.
    - py: Discovered within the last 365 Days.
    - YYYY-MM-DDtoYYYY-MM-DD: Custom date range (e.g., 2022-04-01to2022-07-30)`,
        ),
    });
  • src/server.ts:52-57 (registration)
    Registration of the brave_web_search tool with the MCP server using server.tool(), binding the tool's name, description, input schema, and execute method.
    this.server.tool(
      this.webSearchTool.name,
      this.webSearchTool.description,
      this.webSearchTool.inputSchema.shape,
      this.webSearchTool.execute.bind(this.webSearchTool),
    );
  • src/server.ts:37-37 (registration)
    Instantiation of the BraveWebSearchTool instance used for the brave_web_search tool.
    this.webSearchTool = new BraveWebSearchTool(this, this.braveSearch);
  • The BraveWebSearchTool class definition, including name 'brave_web_search', description, inputSchema, constructor, and executeCore handler method.
    export class BraveWebSearchTool extends BaseTool<typeof webSearchInputSchema, any> {
      public readonly name = 'brave_web_search';
      public readonly description = 'Performs a web search using the Brave Search API, ideal for general queries, and online content. '
        + 'Use this for broad information gathering, recent events, or when you need diverse web sources. '
        + 'Maximum 20 results per request ';
    
      public readonly inputSchema = webSearchInputSchema;
    
      constructor(private braveMcpServer: BraveMcpServer, private braveSearch: BraveSearch) {
        super();
      }
    
      public async executeCore(input: z.infer<typeof webSearchInputSchema>) {
        const { query, count, offset, freshness } = input;
        const results = await this.braveSearch.webSearch(query, {
          count,
          offset,
          safesearch: SafeSearchLevel.Strict,
          ...(freshness ? { freshness } : {}),
        });
        if (!results.web || results.web?.results.length === 0) {
          this.braveMcpServer.log(`No results found for "${query}"`);
          const text = `No results found for "${query}"`;
          return { content: [{ type: 'text' as const, text }] };
        }
        const text = results.web.results.map(result => `Title: ${result.title}\nURL: ${result.url}\nDescription: ${result.description}`).join('\n\n');
        return { content: [{ type: 'text' as const, text }] };
      }
Behavior3/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 adds useful context about the maximum results per request (20) and ideal use cases, but doesn't cover other behavioral aspects like rate limits, authentication needs, error handling, or response format details.

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 efficiently structured in two sentences with zero waste - the first establishes purpose and ideal use cases, the second provides a key behavioral constraint (maximum results). Every element earns its place without redundancy.

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 search tool with no annotations and no output schema, the description provides adequate purpose and usage guidance but lacks details about response format, error conditions, or authentication requirements that would be helpful for an AI agent to use it effectively.

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 fully documents all three parameters (query, count, offset). The description doesn't add any parameter-specific meaning beyond what's in the schema, maintaining the baseline score of 3 for good 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 specific action ('performs a web search') and resource ('using the Brave Search API'), distinguishing it from siblings like image, local, news, and video search by specifying it's for 'general queries' and 'online content' rather than specialized media types.

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 provides clear context for when to use this tool ('broad information gathering, recent events, or when you need diverse web sources'), but it doesn't explicitly state when NOT to use it or name specific alternatives among its siblings (e.g., use brave_news_search for news-specific results).

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

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