npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@gongrzhe/server-brave-search-mcp

v0.0.1

Published

Brave Search MCP server with stateless architecture and Bearer token authentication

Readme

Brave Search MCP Server

A stateless Model Context Protocol (MCP) server for Brave Search API integration with Bearer token authentication.

Features

  • Stateless Architecture: Complete request isolation with no session management
  • Bearer Token Authentication: Standard Authorization header support
  • Web Search: General queries, news, articles, with pagination and freshness controls
  • Local Search: Find businesses, restaurants, and services with detailed information
  • Token Validation: Built-in API key validation

Quick Start

Start the Server

# Install dependencies
npm install

# Build the project
npm run build

# Start the stateless server
npm start

The server will start on port 30000 by default. You can also set a custom port:

PORT=8080 npm start

Authentication

The server uses standard Bearer token authentication. Include your Brave Search API key in the Authorization header:

Authorization: Bearer YOUR_BRAVE_API_KEY_HERE

Get your API key from the Brave Search API Dashboard.

Tools and CURL Examples

1. List Available Tools

curl -X POST http://localhost:30000/mcp \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -H "Authorization: Bearer YOUR_BRAVE_API_KEY" \
  -d '{
    "jsonrpc": "2.0",
    "id": "test",
    "method": "tools/list",
    "params": {}
  }'

2. Validate Token

Validate your Brave Search API key:

curl -X POST http://localhost:30000/mcp \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{
    "jsonrpc": "2.0",
    "id": "validate",
    "method": "tools/call",
    "params": {
      "name": "validate_token",
      "arguments": {
        "BRAVE_API_KEY": "YOUR_BRAVE_API_KEY"
      }
    }
  }'

3. Web Search

Perform a general web search:

curl -X POST http://localhost:30000/mcp \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -H "Authorization: Bearer YOUR_BRAVE_API_KEY" \
  -d '{
    "jsonrpc": "2.0",
    "id": "web-search",
    "method": "tools/call",
    "params": {
      "name": "brave_web_search",
      "arguments": {
        "query": "artificial intelligence news",
        "count": 10,
        "offset": 0
      }
    }
  }'

4. Web Search with Pagination

Search with pagination (get next page):

curl -X POST http://localhost:30000/mcp \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -H "Authorization: Bearer YOUR_BRAVE_API_KEY" \
  -d '{
    "jsonrpc": "2.0",
    "id": "web-search-page2",
    "method": "tools/call",
    "params": {
      "name": "brave_web_search",
      "arguments": {
        "query": "machine learning tutorials",
        "count": 20,
        "offset": 1
      }
    }
  }'

5. Local Business Search

Search for local businesses and services:

curl -X POST http://localhost:30000/mcp \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -H "Authorization: Bearer YOUR_BRAVE_API_KEY" \
  -d '{
    "jsonrpc": "2.0",
    "id": "local-search",
    "method": "tools/call",
    "params": {
      "name": "brave_local_search",
      "arguments": {
        "query": "pizza restaurants near Central Park NYC",
        "count": 5
      }
    }
  }'

6. Local Search with More Results

Get more local search results:

curl -X POST http://localhost:30000/mcp \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -H "Authorization: Bearer YOUR_BRAVE_API_KEY" \
  -d '{
    "jsonrpc": "2.0",
    "id": "local-search-more",
    "method": "tools/call",
    "params": {
      "name": "brave_local_search",
      "arguments": {
        "query": "coffee shops San Francisco",
        "count": 15
      }
    }
  }'

Error Handling Examples

No Authentication Token

curl -X POST http://localhost:30000/mcp \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{
    "jsonrpc": "2.0",
    "id": "no-auth",
    "method": "tools/call",
    "params": {
      "name": "brave_web_search",
      "arguments": {"query": "test"}
    }
  }'

Invalid Token Format

curl -X POST http://localhost:30000/mcp \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -H "Authorization: Invalid token_format" \
  -d '{
    "jsonrpc": "2.0",
    "id": "invalid-format",
    "method": "tools/call",
    "params": {
      "name": "brave_web_search",
      "arguments": {"query": "test"}
    }
  }'

Invalid API Key

curl -X POST http://localhost:30000/mcp \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -H "Authorization: Bearer invalid_api_key_here" \
  -d '{
    "jsonrpc": "2.0",
    "id": "invalid-key",
    "method": "tools/call",
    "params": {
      "name": "brave_web_search",
      "arguments": {"query": "test"}
    }
  }'

Tool Parameters

brave_web_search

  • query (required): Search query (max 400 chars, 50 words)
  • count (optional): Number of results (1-20, default 10)
  • offset (optional): Pagination offset (max 9, default 0)

brave_local_search

  • query (required): Local search query (e.g., 'pizza near Central Park')
  • count (optional): Number of results (1-20, default 5)

validate_token

  • BRAVE_API_KEY (required): Brave Search API key to validate

Notes

  • The server runs in stateless mode only
  • Each request gets a fresh server instance for complete isolation
  • No session management or token caching
  • Rate limiting is applied per request
  • Local search automatically falls back to web search if no local results are found
  • Server listens on port 30000 by default