Home · Skills · Development · Agent

Brave Search MCP Server

Web, news, image and local search through the Brave Search API.

How to install

How to install

  1. Runs on your computer — needs Node. Works in Claude Code, Claude Desktop and Cursor.
  2. Run the Claude Code line, or paste the JSON into your app's MCP config and fill in the placeholder values.
  3. Restart the app, then ask something that needs the tool.
Claude Code
claude mcp add brave-search -e BRAVE_API_KEY=your_brave_api_key -- npx -y @brave/brave-search-mcp-server --transport stdio
Claude Desktop (claude_desktop_config.json) · Cursor (~/.cursor/mcp.json)
{
  "mcpServers": {
    "brave-search": {
      "command": "npx",
      "args": [
        "-y",
        "@brave/brave-search-mcp-server",
        "--transport",
        "stdio"
      ],
      "env": {
        "BRAVE_API_KEY": "your_brave_api_key"
      }
    }
  }
}

Sign up for a Brave Search API account at brave.com/search/api and generate a key in the developer dashboard.

This one runs on your machine and can reach your files. Read the README below before you connect it.

Not working?
  • Check which app you pasted it into — the steps above name the right one.
  • Some skills need the paid tier of Claude or ChatGPT.
Step-by-step guide with screenshots · Ask in the forum

Paste into Claude, ChatGPT or Cursor.

Show the full text462 lines
brave-search/README.md462 lines21.4 KBpushed 4d agoRawView on GitHub

Brave Search MCP Server

An MCP server implementation that integrates the Brave Search API, providing comprehensive search capabilities including web search, local business search, place search, image search, video search, news search, LLM context, and AI-powered summarization. This project supports both STDIO and HTTP transports, with STDIO as the default mode.

Ask DeepWiki

Migration

1.x to 2.x

Default transport now STDIO

To follow established MCP conventions, the server now defaults to STDIO. If you would like to continue using HTTP, you will need to set the BRAVE_MCP_TRANSPORT environment variable to http, or provide the runtime argument --transport http when launching the server.

Response structure of brave_image_search

Version 1.x of the MCP server would return base64-encoded image data along with image URLs. This dramatically slowed down the response, as well as consumed unnecessarily context in the session. Version 2.x removes the base64-encoded data, and returns a response object that more closely reflects the original Brave Search API response. The updated output schema is defined in src/tools/images/schemas/output.ts.

Tools

Web Search (brave_web_search)

Performs comprehensive web searches with rich result types and advanced filtering options.

Parameters:

  • query (string, required): Search terms (max 400 chars, 50 words)
  • country (string, optional): Country code (default: "US")
  • search_lang (string, optional): Search language (default: "en")
  • ui_lang (string, optional): UI language (default: "en-US")
  • count (number, optional): Results per page (1-20, default: 10)
  • offset (number, optional): Pagination offset (max 9, default: 0)
  • safesearch (string, optional): Content filtering ("off", "moderate", "strict", default: "moderate")
  • freshness (string, optional): Time filter ("pd", "pw", "pm", "py", or date range)
  • text_decorations (boolean, optional): Include highlighting markers (default: true)
  • spellcheck (boolean, optional): Enable spell checking (default: true)
  • result_filter (array, optional): Filter result types (default: ["web", "query"])
  • goggles (array, optional): Custom re-ranking definitions
  • units (string, optional): Measurement units ("metric" or "imperial")
  • extra_snippets (boolean, optional): Get additional excerpts (Pro plans only)
  • summary (boolean, optional): Enable summary key generation for AI summarization

Local Search (brave_local_search)

Searches for local businesses and places with detailed information including ratings, hours, and AI-generated descriptions.

Parameters:

  • Same as brave_web_search with automatic location filtering
  • Automatically includes "web" and "locations" in result_filter

Note: Requires Pro plan for full local search capabilities. Falls back to web search otherwise.

Video Search (brave_video_search)

Searches for videos with comprehensive metadata and thumbnail information.

Parameters:

  • query (string, required): Search terms (max 400 chars, 50 words)
  • country (string, optional): Country code (default: "US")
  • search_lang (string, optional): Search language (default: "en")
  • ui_lang (string, optional): UI language (default: "en-US")
  • count (number, optional): Results per page (1-50, default: 20)
  • offset (number, optional): Pagination offset (max 9, default: 0)
  • spellcheck (boolean, optional): Enable spell checking (default: true)
  • safesearch (string, optional): Content filtering ("off", "moderate", "strict", default: "moderate")
  • freshness (string, optional): Time filter ("pd", "pw", "pm", "py", or date range)

Image Search (brave_image_search)

Searches for images with metadata including URLs, dimensions, and confidence scores.

Parameters:

  • query (string, required): Search terms (max 400 chars, 50 words)
  • country (string, optional): Country code (default: "US")
  • search_lang (string, optional): Search language (default: "en")
  • count (number, optional): Results per page (1-200, default: 50)
  • safesearch (string, optional): Content filtering ("off", "strict", default: "strict")
  • spellcheck (boolean, optional): Enable spell checking (default: true)

News Search (brave_news_search)

Searches for current news articles with freshness controls and breaking news indicators.

Parameters:

  • query (string, required): Search terms (max 400 chars, 50 words)
  • country (string, optional): Country code (default: "US")
  • search_lang (string, optional): Search language (default: "en")
  • ui_lang (string, optional): UI language (default: "en-US")
  • count (number, optional): Results per page (1-50, default: 20)
  • offset (number, optional): Pagination offset (max 9, default: 0)
  • spellcheck (boolean, optional): Enable spell checking (default: true)
  • safesearch (string, optional): Content filtering ("off", "moderate", "strict", default: "moderate")
  • freshness (string, optional): Time filter (default: "pd" for last 24 hours)
  • extra_snippets (boolean, optional): Get additional excerpts (Pro plans only)
  • goggles (array, optional): Custom re-ranking definitions

Summarizer Search (brave_summarizer)

Generates AI-powered summaries from web search results using Brave's summarization API.

Parameters:

  • key (string, required): Summary key from web search results (use summary: true in web search)
  • entity_info (boolean, optional): Include entity information (default: false)
  • inline_references (boolean, optional): Add source URL references (default: false)

Usage: First perform a web search with summary: true, then use the returned summary key with this tool.

Place Search (brave_place_search)

Searches for points of interest (POIs) in a specified geographic area using Brave's Place Search API. Returns rich, structured place data including name, address, opening hours, contact info, ratings, photos, categories, and timezone.

Parameters:

  • query (string, optional): Query string used to refine the POI search (max 400 chars, 50 words). When omitted, returns general points of interest in the supplied area.
  • latitude (number, optional): Latitude of the search center (-90 to 90). Typically paired with longitude.
  • longitude (number, optional): Longitude of the search center (-180 to 180). Typically paired with latitude.
  • location (string, optional): Location string used as an alternative to latitude/longitude. For US locations prefer the form <city> <state> <country name> (e.g., san francisco ca united states); for non-US locations use <city> <country name> (e.g., tokyo japan).
  • radius (number, optional): Search radius around the supplied coordinates, in meters. If omitted, the search is performed globally.
  • count (number, optional): Number of results to return (1-50, default 20).
  • country (string, optional): Two-letter country code (default US).
  • search_lang (string, optional): Search language (default en).
  • ui_lang (string, optional): UI language (default en-US).
  • units (string, optional): Distance units (metric or imperial, default metric).
  • safesearch (string, optional): Safe search level (off, moderate, strict, default strict).
  • spellcheck (boolean, optional): Whether to spellcheck the query (default true).
  • geoloc (string, optional): Optional geolocation token used to refine results.

Optional request headers:

  • api-version (string, optional): Brave API version (YYYY-MM-DD)
  • accept (string, optional): Response media type (application/json or */*)
  • cache-control (string, optional): Use no-cache to request fresh content
  • user-agent (string, optional): User agent originating the request

LLM Context (brave_llm_context)

Retrieves pre-extracted web content optimized for AI agents, LLM grounding, and RAG pipelines.

Parameters:

  • query (string, required): Search query (max 400 chars, 50 words)
  • country (string, optional): Search country code
  • search_lang (string, optional): Search language code
  • count (number, optional): Maximum number of search results considered (1-50)
  • spellcheck (boolean, optional): Enable spell checking
  • maximum_number_of_urls (number, optional): Maximum number of URLs to include (1-50)
  • maximum_number_of_tokens (number, optional): Approximate maximum number of context tokens (1024-32768)
  • maximum_number_of_snippets (number, optional): Maximum number of snippets to include (1-256)
  • context_threshold_mode (string, optional): Threshold mode ("disabled", "strict", "lenient", "balanced")
  • maximum_number_of_tokens_per_url (number, optional): Maximum tokens per URL (512-8192)
  • maximum_number_of_snippets_per_url (number, optional): Maximum snippets per URL (1-100)
  • goggles (string or array, optional): Goggle URL or definition for custom re-ranking
  • freshness (string, optional): Time filter ("pd", "pw", "pm", "py", or date range)
  • enable_local (boolean, optional): Enable local recall
  • enable_source_metadata (boolean, optional): Include source metadata enrichment

Optional request headers:

  • x-loc-lat (number, optional): Client latitude (-90 to 90)
  • x-loc-long (number, optional): Client longitude (-180 to 180)
  • x-loc-city (string, optional): Client city name
  • x-loc-state (string, optional): Client state or region code
  • x-loc-state-name (string, optional): Client state or region name
  • x-loc-country (string, optional): Client country code
  • x-loc-postal-code (string, optional): Client postal code
  • api-version (string, optional): Brave API version (YYYY-MM-DD)
  • accept (string, optional): Response media type ("application/json" or "/")
  • cache-control (string, optional): Use no-cache to request fresh content
  • user-agent (string, optional): User agent originating the request

Configuration

Getting an API Key

  1. Sign up for a Brave Search API account
  2. Choose a plan:
    • Search: The real-time search data your chatbots & agents need to generate answers. Complete search results (URLs, text, news, images, and more), with additional LLM context optimized for AI.
    • Answers: Summarized, completed answers to any question. Answers grounded on a single search or multiple searches for better accuracy & reduced hallucinations.
  3. Generate your API key from the developer dashboard

Environment Variables

The server supports the following environment variables:

  • BRAVE_API_KEY: Your Brave Search API key (required unless BRAVE_API_KEY_FILE is set)
  • BRAVE_API_KEY_FILE: Path to a file containing your Brave Search API key. When set, this takes precedence over BRAVE_API_KEY. Useful for Docker secrets and similar mounted-secret setups.
  • BRAVE_MCP_TRANSPORT: Transport mode ("http" or "stdio", default: "stdio")
  • BRAVE_MCP_PORT: HTTP server port (default: 8080)
  • BRAVE_MCP_HOST: HTTP server host (default: "127.0.0.1"). Binds to loopback only by default; set to "0.0.0.0" to expose the server on all interfaces (required inside containers and on Amazon Bedrock AgentCore). Only do this on a trusted network, since the HTTP endpoint is unauthenticated.
  • BRAVE_MCP_ALLOWED_ORIGINS: Space- or comma-separated list of additional Origin header values permitted for the HTTP transport. Loopback origins are always allowed; browser requests carrying any other Origin are rejected with HTTP 403 to guard against DNS rebinding. Set this when a browser-based client on a real domain needs access.
  • BRAVE_MCP_ALLOWED_HOSTS: Space- or comma-separated list of hostnames permitted in the Host header of the HTTP transport. Matching is on the hostname only and is case-insensitive; a numeric port in an entry (e.g. mcp.example.com:8080) is accepted but ignored for matching. Optional, opt-in defense-in-depth: when unset (default) the Host header is not validated, so reverse-proxy and custom-domain deployments are unaffected. When set, only loopback hosts and the listed hostnames are accepted; any other Host (including malformed/non-numeric ports) is rejected with HTTP 403.
  • BRAVE_MCP_LOG_LEVEL: Desired logging level("debug", "info", "notice", "warning", "error", "critical", "alert", or "emergency", default: "info")
  • BRAVE_MCP_ENABLED_TOOLS: When used, specifies a space-separated whitelist for supported tools
  • BRAVE_MCP_DISABLED_TOOLS: When used, specifies a space-separated blacklist for supported tools
  • BRAVE_MCP_STATELESS: HTTP stateless mode (default: "true"). When running on Amazon Bedrock Agentcore, set to "true".

Command Line Options

node dist/index.js [options]

Options:
  --brave-api-key <string>        Brave API key
  --brave-api-key-file <string>   Path to file containing Brave API key
  --transport <stdio|http>    Transport type (default: stdio)
  --port <number>             HTTP server port (default: 8080)
  --host <string>             HTTP server host (default: 127.0.0.1)
  --allowed-origins <origins...>  Allowed Origin header values for HTTP transport (DNS rebinding protection)
  --allowed-hosts <hosts...>  Allowed Host header values for HTTP transport (opt-in DNS rebinding protection)
  --logging-level <string>    Desired logging level (one of _debug_, _info_, _notice_, _warning_, _error_, _critical_, _alert_, or _emergency_)
  --enabled-tools             Tools whitelist (only the specified tools will be enabled)
  --disabled-tools            Tools blacklist (included tools will be disabled)
  --stateless  <boolean>      HTTP Stateless flag

Installation

Usage with Claude Desktop

Add this to your claude_desktop_config.json:

Docker

{
  "mcpServers": {
    "brave-search": {
      "command": "docker",
      "args": ["run", "-i", "--rm", "-e", "BRAVE_API_KEY", "docker.io/mcp/brave-search"],
      "env": {
        "BRAVE_API_KEY": "YOUR_API_KEY_HERE"
      }
    }
  }
}

NPX

{
  "mcpServers": {
    "brave-search": {
      "command": "npx",
      "args": ["-y", "@brave/brave-search-mcp-server", "--transport", "http"],
      "env": {
        "BRAVE_API_KEY": "YOUR_API_KEY_HERE"
      }
    }
  }
}

Usage with VS Code

For quick installation, use the one-click installation buttons below:

Install with NPX in VS Code Install with NPX in VS Code Insiders
Install with Docker in VS Code Install with Docker in VS Code Insiders

For manual installation, add the following to your User Settings (JSON) or .vscode/mcp.json:

Docker

{
  "inputs": [
    {
      "password": true,
      "id": "brave-api-key",
      "type": "promptString",
      "description": "Brave Search API Key",
    }
  ],
  "servers": {
    "brave-search": {
      "command": "docker",
      "args": ["run", "-i", "--rm", "-e", "BRAVE_API_KEY", "mcp/brave-search"],
      "env": {
        "BRAVE_API_KEY": "${input:brave-api-key}"
      }
    }
  }
}

NPX

{
  "inputs": [
    {
      "password": true,
      "id": "brave-api-key",
      "type": "promptString",
      "description": "Brave Search API Key",
    }
  ],
  "servers": {
    "brave-search-mcp-server": {
      "command": "npx",
      "args": ["-y", "@brave/brave-search-mcp-server", "--transport", "stdio"],
      "env": {
        "BRAVE_API_KEY": "${input:brave-api-key}"
      }
    }
  }
}

Usage with fx

Add this to your ~/.fx/mcp.json, creating the file if it does not exist:

Docker

{
  "mcp": {
    "brave-search": {
      "command": "docker",
      "args": ["run", "-i", "--rm", "-e", "BRAVE_API_KEY", "docker.io/mcp/brave-search"],
      "env": {
        "BRAVE_API_KEY": "YOUR_API_KEY_HERE"
      }
    }
  }
}

NPX

{
  "mcp": {
    "brave-search": {
      "command": "npx",
      "args": ["-y", "@brave/brave-search-mcp-server", "--transport", "stdio"],
      "env": {
        "BRAVE_API_KEY": "YOUR_API_KEY_HERE"
      }
    }
  }
}

Start fx, or type /mcp reload if it is already running. To verify the connection, type /mcp list.

Build

Docker

docker build -t mcp/brave-search:latest .

Local Build

npm install
npm run build

Development

Prerequisites

  • Node.js 22.x or higher
  • npm
  • Brave Search API key

Setup

  1. Clone the repository:
git clone https://github.com/brave/brave-search-mcp-server.git
cd brave-search-mcp-server
  1. Install dependencies:
npm install
  1. Build the project:
npm run build

Testing via Claude Desktop

Add a reference to your local build in claude_desktop_config.json:

{
  "mcpServers": {
    "brave-search-dev": {
      "command": "node",
      "args": ["C:\\GitHub\\brave-search-mcp-server\\dist\\index.js"], // Verify your path
      "env": {
        "BRAVE_API_KEY": "YOUR_API_KEY_HERE"
      }
    }
  }
}

Testing via MCP Inspector

The Inspector requires Node 22.19 or newer.

STDIO — the Inspector launches the server itself, so one terminal is enough:

npm run build
npx @modelcontextprotocol/inspector node dist/index.js

HTTP — the Inspector connects to a URL, so the server must already be listening:

# terminal 1
npm run serve:http

# terminal 2
npm run inspector:http

serve:http builds, binds 127.0.0.1:8080, and reads BRAVE_API_KEY from .env.

Available Scripts

  • npm run build: Build the TypeScript project

  • npm run watch: Watch for changes and rebuild

  • npm test: Run the test suite

  • npm run format: Format code with Prettier

  • npm run format:check: Check code formatting

  • npm run prepare: Format and build (runs automatically on npm install)

  • npm run serve:http: Build, then serve over HTTP at http://127.0.0.1:8080/mcp

  • npm run inspector: Launch an instance of MCP Inspector

  • npm run inspector:http: Launch MCP Inspector against http://127.0.0.1:8080/mcp

Docker Compose

For local development with Docker:

docker-compose up --build

Set BRAVE_API_KEY (or BRAVE_API_KEY_FILE) in your shell or a .env file before starting the stack. The default docker-compose.yml also accepts BRAVE_API_KEY_FILE when the path is valid inside the container (for example, from a bind mount or Docker secret).

Docker Compose secrets (optional)

To avoid putting the API key in an environment variable, you can use Docker Compose secrets. The server reads the key from the path in BRAVE_API_KEY_FILE, which must exist inside the container.

  1. Copy the example secret file and add your key:
cp secrets/brave_api_key.txt.example secrets/brave_api_key.txt
  1. Start the stack with the optional secrets override:
docker compose -f docker-compose.yml -f docker-compose.secrets.example.yml up --build

The override mounts the secret at /run/secrets/brave_api_key and sets BRAVE_API_KEY_FILE accordingly. See docker-compose.secrets.example.yml for the full configuration.

License

This MCP server is licensed under the MIT License. This means you are free to use, modify, and distribute the software, subject to the terms and conditions of the MIT License. For more details, please see the LICENSE file in the project repository.

1# Brave Search MCP Server
2 
3An MCP server implementation that integrates the Brave Search API, providing comprehensive search capabilities including web search, local business search, place search, image search, video search, news search, LLM context, and AI-powered summarization. This project supports both STDIO and HTTP transports, with STDIO as the default mode.
4 
5[![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/brave/brave-search-mcp-server)
6 
7## Migration
8 
9### 1.x to 2.x
10 
11#### Default transport now STDIO
12 
13To follow established MCP conventions, the server now defaults to STDIO. If you would like to continue using HTTP, you will need to set the `BRAVE_MCP_TRANSPORT` environment variable to `http`, or provide the runtime argument `--transport http` when launching the server.
14 
15#### Response structure of `brave_image_search`
16 
17Version 1.x of the MCP server would return base64-encoded image data along with image URLs. This dramatically slowed down the response, as well as consumed unnecessarily context in the session. Version 2.x removes the base64-encoded data, and returns a response object that more closely reflects the original Brave Search API response. The updated output schema is defined in [`src/tools/images/schemas/output.ts`](https://github.com/brave/brave-search-mcp-server/blob/main/src/tools/images/schemas/output.ts).
18 
19## Tools
20 
21### Web Search (`brave_web_search`)
22Performs comprehensive web searches with rich result types and advanced filtering options.
23 
24**Parameters:**
25- `query` (string, required): Search terms (max 400 chars, 50 words)
26- `country` (string, optional): Country code (default: "US")
27- `search_lang` (string, optional): Search language (default: "en")
28- `ui_lang` (string, optional): UI language (default: "en-US")
29- `count` (number, optional): Results per page (1-20, default: 10)
30- `offset` (number, optional): Pagination offset (max 9, default: 0)
31- `safesearch` (string, optional): Content filtering ("off", "moderate", "strict", default: "moderate")
32- `freshness` (string, optional): Time filter ("pd", "pw", "pm", "py", or date range)
33- `text_decorations` (boolean, optional): Include highlighting markers (default: true)
34- `spellcheck` (boolean, optional): Enable spell checking (default: true)
35- `result_filter` (array, optional): Filter result types (default: ["web", "query"])
36- `goggles` (array, optional): Custom re-ranking definitions
37- `units` (string, optional): Measurement units ("metric" or "imperial")
38- `extra_snippets` (boolean, optional): Get additional excerpts (Pro plans only)
39- `summary` (boolean, optional): Enable summary key generation for AI summarization
40 
41### Local Search (`brave_local_search`)
42Searches for local businesses and places with detailed information including ratings, hours, and AI-generated descriptions.
43 
44**Parameters:**
45- Same as `brave_web_search` with automatic location filtering
46- Automatically includes "web" and "locations" in result_filter
47 
48**Note:** Requires Pro plan for full local search capabilities. Falls back to web search otherwise.
49 
50### Video Search (`brave_video_search`)
51Searches for videos with comprehensive metadata and thumbnail information.
52 
53**Parameters:**
54- `query` (string, required): Search terms (max 400 chars, 50 words)
55- `country` (string, optional): Country code (default: "US")
56- `search_lang` (string, optional): Search language (default: "en")
57- `ui_lang` (string, optional): UI language (default: "en-US")
58- `count` (number, optional): Results per page (1-50, default: 20)
59- `offset` (number, optional): Pagination offset (max 9, default: 0)
60- `spellcheck` (boolean, optional): Enable spell checking (default: true)
61- `safesearch` (string, optional): Content filtering ("off", "moderate", "strict", default: "moderate")
62- `freshness` (string, optional): Time filter ("pd", "pw", "pm", "py", or date range)
63 
64### Image Search (`brave_image_search`)
65Searches for images with metadata including URLs, dimensions, and confidence scores.
66 
67**Parameters:**
68- `query` (string, required): Search terms (max 400 chars, 50 words)
69- `country` (string, optional): Country code (default: "US")
70- `search_lang` (string, optional): Search language (default: "en")
71- `count` (number, optional): Results per page (1-200, default: 50)
72- `safesearch` (string, optional): Content filtering ("off", "strict", default: "strict")
73- `spellcheck` (boolean, optional): Enable spell checking (default: true)
74 
75### News Search (`brave_news_search`)
76Searches for current news articles with freshness controls and breaking news indicators.
77 
78**Parameters:**
79- `query` (string, required): Search terms (max 400 chars, 50 words)
80- `country` (string, optional): Country code (default: "US")
81- `search_lang` (string, optional): Search language (default: "en")
82- `ui_lang` (string, optional): UI language (default: "en-US")
83- `count` (number, optional): Results per page (1-50, default: 20)
84- `offset` (number, optional): Pagination offset (max 9, default: 0)
85- `spellcheck` (boolean, optional): Enable spell checking (default: true)
86- `safesearch` (string, optional): Content filtering ("off", "moderate", "strict", default: "moderate")
87- `freshness` (string, optional): Time filter (default: "pd" for last 24 hours)
88- `extra_snippets` (boolean, optional): Get additional excerpts (Pro plans only)
89- `goggles` (array, optional): Custom re-ranking definitions
90 
91### Summarizer Search (`brave_summarizer`)
92Generates AI-powered summaries from web search results using Brave's summarization API.
93 
94**Parameters:**
95- `key` (string, required): Summary key from web search results (use `summary: true` in web search)
96- `entity_info` (boolean, optional): Include entity information (default: false)
97- `inline_references` (boolean, optional): Add source URL references (default: false)
98 
99**Usage:** First perform a web search with `summary: true`, then use the returned summary key with this tool.
100 
101### Place Search (`brave_place_search`)
102Searches for points of interest (POIs) in a specified geographic area using Brave's Place Search API. Returns rich, structured place data including name, address, opening hours, contact info, ratings, photos, categories, and timezone.
103 
104**Parameters:**
105- `query` (string, optional): Query string used to refine the POI search (max 400 chars, 50 words). When omitted, returns general points of interest in the supplied area.
106- `latitude` (number, optional): Latitude of the search center (-90 to 90). Typically paired with `longitude`.
107- `longitude` (number, optional): Longitude of the search center (-180 to 180). Typically paired with `latitude`.
108- `location` (string, optional): Location string used as an alternative to `latitude`/`longitude`. For US locations prefer the form `<city> <state> <country name>` (e.g., `san francisco ca united states`); for non-US locations use `<city> <country name>` (e.g., `tokyo japan`).
109- `radius` (number, optional): Search radius around the supplied coordinates, in meters. If omitted, the search is performed globally.
110- `count` (number, optional): Number of results to return (1-50, default 20).
111- `country` (string, optional): Two-letter country code (default `US`).
112- `search_lang` (string, optional): Search language (default `en`).
113- `ui_lang` (string, optional): UI language (default `en-US`).
114- `units` (string, optional): Distance units (`metric` or `imperial`, default `metric`).
115- `safesearch` (string, optional): Safe search level (`off`, `moderate`, `strict`, default `strict`).
116- `spellcheck` (boolean, optional): Whether to spellcheck the query (default `true`).
117- `geoloc` (string, optional): Optional geolocation token used to refine results.
118 
119**Optional request headers:**
120- `api-version` (string, optional): Brave API version (`YYYY-MM-DD`)
121- `accept` (string, optional): Response media type (`application/json` or `*/*`)
122- `cache-control` (string, optional): Use `no-cache` to request fresh content
123- `user-agent` (string, optional): User agent originating the request
124 
125### LLM Context (`brave_llm_context`)
126Retrieves pre-extracted web content optimized for AI agents, LLM grounding, and RAG pipelines.
127 
128**Parameters:**
129- `query` (string, required): Search query (max 400 chars, 50 words)
130- `country` (string, optional): Search country code
131- `search_lang` (string, optional): Search language code
132- `count` (number, optional): Maximum number of search results considered (1-50)
133- `spellcheck` (boolean, optional): Enable spell checking
134- `maximum_number_of_urls` (number, optional): Maximum number of URLs to include (1-50)
135- `maximum_number_of_tokens` (number, optional): Approximate maximum number of context tokens (1024-32768)
136- `maximum_number_of_snippets` (number, optional): Maximum number of snippets to include (1-256)
137- `context_threshold_mode` (string, optional): Threshold mode ("disabled", "strict", "lenient", "balanced")
138- `maximum_number_of_tokens_per_url` (number, optional): Maximum tokens per URL (512-8192)
139- `maximum_number_of_snippets_per_url` (number, optional): Maximum snippets per URL (1-100)
140- `goggles` (string or array, optional): Goggle URL or definition for custom re-ranking
141- `freshness` (string, optional): Time filter ("pd", "pw", "pm", "py", or date range)
142- `enable_local` (boolean, optional): Enable local recall
143- `enable_source_metadata` (boolean, optional): Include source metadata enrichment
144 
145**Optional request headers:**
146- `x-loc-lat` (number, optional): Client latitude (-90 to 90)
147- `x-loc-long` (number, optional): Client longitude (-180 to 180)
148- `x-loc-city` (string, optional): Client city name
149- `x-loc-state` (string, optional): Client state or region code
150- `x-loc-state-name` (string, optional): Client state or region name
151- `x-loc-country` (string, optional): Client country code
152- `x-loc-postal-code` (string, optional): Client postal code
153- `api-version` (string, optional): Brave API version (`YYYY-MM-DD`)
154- `accept` (string, optional): Response media type ("application/json" or "*/*")
155- `cache-control` (string, optional): Use `no-cache` to request fresh content
156- `user-agent` (string, optional): User agent originating the request
157 
158## Configuration
159 
160### Getting an API Key
161 
1621. Sign up for a [Brave Search API account](https://brave.com/search/api/)
1632. Choose a plan:
164 - **Search**: The real-time search data your chatbots & agents need to generate answers. Complete search results (URLs, text, news, images, and more), with additional LLM context optimized for AI.
165 - **Answers**: Summarized, completed answers to any question. Answers grounded on a single search or multiple searches for better accuracy & reduced hallucinations.
1663. Generate your API key from the [developer dashboard](https://api-dashboard.search.brave.com/app/keys)
167 
168### Environment Variables
169 
170The server supports the following environment variables:
171 
172- `BRAVE_API_KEY`: Your Brave Search API key (required unless `BRAVE_API_KEY_FILE` is set)
173- `BRAVE_API_KEY_FILE`: Path to a file containing your Brave Search API key. When set, this takes precedence over `BRAVE_API_KEY`. Useful for Docker secrets and similar mounted-secret setups.
174- `BRAVE_MCP_TRANSPORT`: Transport mode ("http" or "stdio", default: "stdio")
175- `BRAVE_MCP_PORT`: HTTP server port (default: 8080)
176- `BRAVE_MCP_HOST`: HTTP server host (default: "127.0.0.1"). Binds to loopback only by default; set to "0.0.0.0" to expose the server on all interfaces (required inside containers and on Amazon Bedrock AgentCore). Only do this on a trusted network, since the HTTP endpoint is unauthenticated.
177- `BRAVE_MCP_ALLOWED_ORIGINS`: Space- or comma-separated list of additional `Origin` header values permitted for the HTTP transport. Loopback origins are always allowed; browser requests carrying any other `Origin` are rejected with HTTP 403 to guard against DNS rebinding. Set this when a browser-based client on a real domain needs access.
178- `BRAVE_MCP_ALLOWED_HOSTS`: Space- or comma-separated list of hostnames permitted in the `Host` header of the HTTP transport. Matching is on the hostname only and is case-insensitive; a numeric port in an entry (e.g. `mcp.example.com:8080`) is accepted but ignored for matching. Optional, opt-in defense-in-depth: when unset (default) the `Host` header is not validated, so reverse-proxy and custom-domain deployments are unaffected. When set, only loopback hosts and the listed hostnames are accepted; any other `Host` (including malformed/non-numeric ports) is rejected with HTTP 403.
179- `BRAVE_MCP_LOG_LEVEL`: Desired logging level("debug", "info", "notice", "warning", "error", "critical", "alert", or "emergency", default: "info")
180- `BRAVE_MCP_ENABLED_TOOLS`: When used, specifies a space-separated whitelist for supported tools
181- `BRAVE_MCP_DISABLED_TOOLS`: When used, specifies a space-separated blacklist for supported tools
182- `BRAVE_MCP_STATELESS`: HTTP stateless mode (default: "true"). When running on Amazon Bedrock Agentcore, set to "true".
183 
184### Command Line Options
185 
186```bash
187node dist/index.js [options]
188 
189Options:
190 --brave-api-key <string> Brave API key
191 --brave-api-key-file <string> Path to file containing Brave API key
192 --transport <stdio|http> Transport type (default: stdio)
193 --port <number> HTTP server port (default: 8080)
194 --host <string> HTTP server host (default: 127.0.0.1)
195 --allowed-origins <origins...> Allowed Origin header values for HTTP transport (DNS rebinding protection)
196 --allowed-hosts <hosts...> Allowed Host header values for HTTP transport (opt-in DNS rebinding protection)
197 --logging-level <string> Desired logging level (one of _debug_, _info_, _notice_, _warning_, _error_, _critical_, _alert_, or _emergency_)
198 --enabled-tools Tools whitelist (only the specified tools will be enabled)
199 --disabled-tools Tools blacklist (included tools will be disabled)
200 --stateless <boolean> HTTP Stateless flag
201```
202 
203## Installation
204 
205### Usage with Claude Desktop
206 
207Add this to your `claude_desktop_config.json`:
208 
209#### Docker
210 
211```json
212{
213 "mcpServers": {
214 "brave-search": {
215 "command": "docker",
216 "args": ["run", "-i", "--rm", "-e", "BRAVE_API_KEY", "docker.io/mcp/brave-search"],
217 "env": {
218 "BRAVE_API_KEY": "YOUR_API_KEY_HERE"
219 }
220 }
221 }
222}
223```
224 
225#### NPX
226 
227```json
228{
229 "mcpServers": {
230 "brave-search": {
231 "command": "npx",
232 "args": ["-y", "@brave/brave-search-mcp-server", "--transport", "http"],
233 "env": {
234 "BRAVE_API_KEY": "YOUR_API_KEY_HERE"
235 }
236 }
237 }
238}
239```
240 
241### Usage with VS Code
242 
243For quick installation, use the one-click installation buttons below:
244 
245[![Install with NPX in VS Code](https://img.shields.io/badge/VS_Code-NPM-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://insiders.vscode.dev/redirect/mcp/install?name=brave-search&inputs=%5B%7B%22password%22%3Atrue%2C%22id%22%3A%22brave-api-key%22%2C%22type%22%3A%22promptString%22%2C%22description%22%3A%22Brave+Search+API+Key%22%7D%5D&config=%7B%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40brave%2Fbrave-search-mcp-server%22%2C%22--transport%22%2C%22stdio%22%5D%2C%22env%22%3A%7B%22BRAVE_API_KEY%22%3A%22%24%7Binput%3Abrave-api-key%7D%22%7D%7D) [![Install with NPX in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-NPM-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://insiders.vscode.dev/redirect/mcp/install?name=brave-search&inputs=%5B%7B%22password%22%3Atrue%2C%22id%22%3A%22brave-api-key%22%2C%22type%22%3A%22promptString%22%2C%22description%22%3A%22Brave+Search+API+Key%22%7D%5D&config=%7B%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40brave%2Fbrave-search-mcp-server%22%2C%22--transport%22%2C%22stdio%22%5D%2C%22env%22%3A%7B%22BRAVE_API_KEY%22%3A%22%24%7Binput%3Abrave-api-key%7D%22%7D%7D&quality=insiders)
246[![Install with Docker in VS Code](https://img.shields.io/badge/VS_Code-Docker-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://insiders.vscode.dev/redirect/mcp/install?name=brave-search&inputs=%5B%7B%22password%22%3Atrue%2C%22id%22%3A%22brave-api-key%22%2C%22type%22%3A%22promptString%22%2C%22description%22%3A%22Brave+Search+API+Key%22%7D%5D&config=%7B%22command%22%3A%22docker%22%2C%22args%22%3A%5B%22run%22%2C%22-i%22%2C%22--rm%22%2C%22-e%22%2C%22BRAVE_API_KEY%22%2C%22mcp%2Fbrave-search%22%5D%2C%22env%22%3A%7B%22BRAVE_API_KEY%22%3A%22%24%7Binput%3Abrave-api-key%7D%22%7D%7D) [![Install with Docker in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Docker-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://insiders.vscode.dev/redirect/mcp/install?name=brave-search&inputs=%5B%7B%22password%22%3Atrue%2C%22id%22%3A%22brave-api-key%22%2C%22type%22%3A%22promptString%22%2C%22description%22%3A%22Brave+Search+API+Key%22%7D%5D&config=%7B%22command%22%3A%22docker%22%2C%22args%22%3A%5B%22run%22%2C%22-i%22%2C%22--rm%22%2C%22-e%22%2C%22BRAVE_API_KEY%22%2C%22mcp%2Fbrave-search%22%5D%2C%22env%22%3A%7B%22BRAVE_API_KEY%22%3A%22%24%7Binput%3Abrave-api-key%7D%22%7D%7D&quality=insiders)
247 
248For manual installation, add the following to your User Settings (JSON) or `.vscode/mcp.json`:
249 
250#### Docker
251 
252```json
253{
254 "inputs": [
255 {
256 "password": true,
257 "id": "brave-api-key",
258 "type": "promptString",
259 "description": "Brave Search API Key",
260 }
261 ],
262 "servers": {
263 "brave-search": {
264 "command": "docker",
265 "args": ["run", "-i", "--rm", "-e", "BRAVE_API_KEY", "mcp/brave-search"],
266 "env": {
267 "BRAVE_API_KEY": "${input:brave-api-key}"
268 }
269 }
270 }
271}
272```
273 
274#### NPX
275 
276```json
277{
278 "inputs": [
279 {
280 "password": true,
281 "id": "brave-api-key",
282 "type": "promptString",
283 "description": "Brave Search API Key",
284 }
285 ],
286 "servers": {
287 "brave-search-mcp-server": {
288 "command": "npx",
289 "args": ["-y", "@brave/brave-search-mcp-server", "--transport", "stdio"],
290 "env": {
291 "BRAVE_API_KEY": "${input:brave-api-key}"
292 }
293 }
294 }
295}
296```
297 
298### Usage with fx
299 
300Add this to your `~/.fx/mcp.json`, creating the file if it does not exist:
301 
302#### Docker
303 
304```json
305{
306 "mcp": {
307 "brave-search": {
308 "command": "docker",
309 "args": ["run", "-i", "--rm", "-e", "BRAVE_API_KEY", "docker.io/mcp/brave-search"],
310 "env": {
311 "BRAVE_API_KEY": "YOUR_API_KEY_HERE"
312 }
313 }
314 }
315}
316```
317 
318#### NPX
319 
320```json
321{
322 "mcp": {
323 "brave-search": {
324 "command": "npx",
325 "args": ["-y", "@brave/brave-search-mcp-server", "--transport", "stdio"],
326 "env": {
327 "BRAVE_API_KEY": "YOUR_API_KEY_HERE"
328 }
329 }
330 }
331}
332```
333 
334Start fx, or type `/mcp reload` if it is already running. To verify the connection, type `/mcp list`.
335 
336## Build
337 
338### Docker
339 
340```bash
341docker build -t mcp/brave-search:latest .
342```
343 
344### Local Build
345 
346```bash
347npm install
348npm run build
349```
350 
351## Development
352 
353### Prerequisites
354 
355- Node.js 22.x or higher
356- npm
357- Brave Search API key
358 
359### Setup
360 
3611. Clone the repository:
362```bash
363git clone https://github.com/brave/brave-search-mcp-server.git
364cd brave-search-mcp-server
365```
366 
3672. Install dependencies:
368```bash
369npm install
370```
371 
3723. Build the project:
373```bash
374npm run build
375```
376 
377### Testing via Claude Desktop
378 
379Add a reference to your local build in `claude_desktop_config.json`:
380 
381```json
382{
383 "mcpServers": {
384 "brave-search-dev": {
385 "command": "node",
386 "args": ["C:\\GitHub\\brave-search-mcp-server\\dist\\index.js"], // Verify your path
387 "env": {
388 "BRAVE_API_KEY": "YOUR_API_KEY_HERE"
389 }
390 }
391 }
392}
393```
394 
395### Testing via MCP Inspector
396 
397The Inspector requires Node 22.19 or newer.
398 
399**STDIO** — the Inspector launches the server itself, so one terminal is enough:
400 
401```bash
402npm run build
403npx @modelcontextprotocol/inspector node dist/index.js
404```
405 
406**HTTP** — the Inspector connects to a URL, so the server must already be listening:
407 
408```bash
409# terminal 1
410npm run serve:http
411 
412# terminal 2
413npm run inspector:http
414```
415 
416`serve:http` builds, binds `127.0.0.1:8080`, and reads `BRAVE_API_KEY` from `.env`.
417 
418### Available Scripts
419 
420- `npm run build`: Build the TypeScript project
421- `npm run watch`: Watch for changes and rebuild
422- `npm test`: Run the test suite
423- `npm run format`: Format code with Prettier
424- `npm run format:check`: Check code formatting
425- `npm run prepare`: Format and build (runs automatically on npm install)
426 
427- `npm run serve:http`: Build, then serve over HTTP at `http://127.0.0.1:8080/mcp`
428- `npm run inspector`: Launch an instance of MCP Inspector
429- `npm run inspector:http`: Launch MCP Inspector against `http://127.0.0.1:8080/mcp`
430 
431### Docker Compose
432 
433For local development with Docker:
434 
435```bash
436docker-compose up --build
437```
438 
439Set `BRAVE_API_KEY` (or `BRAVE_API_KEY_FILE`) in your shell or a `.env` file before starting the stack. The default `docker-compose.yml` also accepts `BRAVE_API_KEY_FILE` when the path is valid inside the container (for example, from a bind mount or Docker secret).
440 
441#### Docker Compose secrets (optional)
442 
443To avoid putting the API key in an environment variable, you can use [Docker Compose secrets](https://docs.docker.com/compose/how-tos/use-secrets/). The server reads the key from the path in `BRAVE_API_KEY_FILE`, which must exist inside the container.
444 
4451. Copy the example secret file and add your key:
446 
447```bash
448cp secrets/brave_api_key.txt.example secrets/brave_api_key.txt
449```
450 
4512. Start the stack with the optional secrets override:
452 
453```bash
454docker compose -f docker-compose.yml -f docker-compose.secrets.example.yml up --build
455```
456 
457The override mounts the secret at `/run/secrets/brave_api_key` and sets `BRAVE_API_KEY_FILE` accordingly. See `docker-compose.secrets.example.yml` for the full configuration.
458 
459## License
460 
461This MCP server is licensed under the MIT License. This means you are free to use, modify, and distribute the software, subject to the terms and conditions of the MIT License. For more details, please see the LICENSE file in the project repository.
462 

Discussion

Alternatives

Also in Agents & MCP