# Brave Search MCP Server An MCP server implementation that integrates the Brave Search API, providing both web and local search capabilities. This project supports both HTTP and STDIO transports. By default the project will launch into HTTP Streaming mode. For STDIO support, pass `--transport stdio` via the CLI. ## Features - **Web Search**: General queries, news, articles, with pagination and freshness controls - **Local Search**: Find businesses, restaurants, and services with detailed information - **Flexible Filtering**: Control result types, safety levels, and content freshness - **Smart Fallbacks**: Local search automatically falls back to web when no results are found ## Tools - **brave_web_search** - Execute web searches with pagination and filtering - Inputs: - `query` (string): Search terms - `count` (number, optional): Results per page (max 20) - `offset` (number, optional): Pagination offset (max 9) - **brave_local_search** - Search for local businesses and services - Inputs: - `query` (string): Local search terms - `count` (number, optional): Number of results (max 20) - Automatically falls back to web search if no local results found ## Configuration ### Getting an API Key 1. Sign up for a [Brave Search API account](https://brave.com/search/api/) 2. Choose a plan (Free tier available with 2,000 queries/month) 3. Generate your API key [from the developer dashboard](https://api-dashboard.search.brave.com/app/keys) ### Usage with Claude Desktop Add this to your `claude_desktop_config.json`: ### Docker ```json { "mcpServers": { "brave-search": { "command": "docker", "args": ["run", "-i", "--rm", "-e", "BRAVE_API_KEY", "mcp/brave-search"], "env": { "BRAVE_API_KEY": "YOUR_API_KEY_HERE" } } } } ``` ### NPX ```json { "mcpServers": { "brave-search": { "command": "npx", "args": ["-y", "@brave/brave-search-mcp-server"], "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](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&inputs=%5B%7B%22type%22%3A%22promptString%22%2C%22id%22%3A%22apiKey%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%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&inputs=%5B%7B%22type%22%3A%22promptString%22%2C%22id%22%3A%22apiKey%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%5D%2C%22env%22%3A%7B%22BRAVE_API_KEY%22%3A%22%24%7Binput%3Abrave_api_key%7D%22%7D%7D&quality=insiders) [![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&inputs=%5B%7B%22type%22%3A%22promptString%22%2C%22id%22%3A%22apiKey%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&inputs=%5B%7B%22type%22%3A%22promptString%22%2C%22id%22%3A%22apiKey%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) For manual installation, add the following JSON block to your User Settings (JSON) file in VS Code. You can do this by pressing `Ctrl + Shift + P` and typing `Preferences: Open User Settings (JSON)`. Optionally, you can add it to a file called `.vscode/mcp.json` in your workspace. This will allow you to share the configuration with others. > Note that the `mcp` key is not needed in the `.vscode/mcp.json` file. #### Docker ```json { "mcp": { "inputs": [ { "type": "promptString", "id": "brave_api_key", "description": "Brave Search API Key", "password": true } ], "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 ```json { "mcp": { "inputs": [ { "type": "promptString", "id": "brave_api_key", "description": "Brave Search API Key", "password": true } ], "servers": { "brave-search": { "command": "npx", "args": ["-y", "@brave/brave-search-mcp-server"], "env": { "BRAVE_API_KEY": "${input:brave_api_key}" } } } } } ``` ## Build Docker build: ```bash docker build -t mcp/brave-search:latest . ``` ## Development ### Testing via Claude Desktop Clone this repo to your machine, then add a reference to your `claude_desktop_config.json`: ```json { "mcpServers": { "brave-search-dev": { "command": "node", "args": ["C:\\GitHub\\brave-search-mcp-server\\dist\\index.js"], "env": { "BRAVE_API_KEY": "YOUR_API_KEY_HERE" } } } } ``` ### Testing via MCP Inspector To test within the MCP Inspector, you'll need to build the project, launch the HTTP server (if you intend to test the HTTP endpoint), and initialize MCP Inspector: ```bash npm install npm run build node dist/index.js # defaults to http-mode, use `node dist/index.js --transport stdio` for stdio-mode ``` From another terminal (within the `dist/` directory): ```bash npx @modelcontextprotocol/inspector node dist/index.js ``` In order to test STDIO via MCP Inspector, you will need to add `--transport stdio` to the arguments via the Inspector UI. ## 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.