Brave Search SSE MCP server

Delivers real-time Brave Search results via Server-Sent Events (SSE), maintaining persistent connections for immediate display without polling requirements.
Back to servers
Provider
Isaac Gounton
Release date
Mar 20, 2025
Language
TypeScript

This MCP server integrates with Brave Search API to provide real-time search results through Server-Sent Events (SSE). It's designed for easy deployment and offers a seamless way to implement search functionality with real-time updates in your applications.

Installation Options

Local Setup

  1. Create a .env file with your Brave API key:

    BRAVE_API_KEY=your_api_key_here
    PORT=3001
    
  2. Install dependencies:

    npm install
    
  3. Start the development server:

    npm run dev
    

Docker Deployment

Build and run using docker-compose:

docker-compose up --build

Coolify Deployment

  1. In your Coolify dashboard, create a new service
  2. Choose "Deploy from Source"
  3. Configure with these settings:
    • Repository URL: Your repository URL
    • Branch: main
    • Build Command: npm run build
    • Start Command: npm start
    • Port: 3001
    • Environment Variables:
      • BRAVE_API_KEY=your_api_key_here
      • PORT=3001

Using the Server

SSE Integration

The SSE endpoint provides real-time search results to connected clients:

GET http://your-server:3001/sse

Connect to it using the EventSource API in your frontend code:

const eventSource = new EventSource('http://your-server:3001/sse');

eventSource.onmessage = (event) => {
  const data = JSON.parse(event.data);
  // Handle the search results
  console.log(data);
};

eventSource.onerror = (error) => {
  console.error('SSE Error:', error);
  eventSource.close();
};

Triggering Searches

To trigger searches that will be broadcast to all connected SSE clients:

POST http://your-server:3001/messages
Content-Type: application/json

{
  "query": "your search query",
  "count": 10  // optional, default: 10, max: 20
}

Using the MCP Tool

The server provides a Brave web search MCP tool with these parameters:

  • query: String containing the search query
  • count: Optional number of results (1-20, default: 10)

Error Handling

The server broadcasts errors to all connected SSE clients in this format:

{
  "type": "error",
  "error": "error message"
}

Important Notes

  • SSE connections remain open until explicitly closed by the client
  • Search results are broadcast to all connected clients
  • The server handles disconnections and cleanup automatically
  • Consider implementing authentication for the messages endpoint in production

How to add this MCP server to Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later