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.
Create a .env
file with your Brave API key:
BRAVE_API_KEY=your_api_key_here
PORT=3001
Install dependencies:
npm install
Start the development server:
npm run dev
Build and run using docker-compose:
docker-compose up --build
npm run build
npm start
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();
};
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
}
The server provides a Brave web search MCP tool with these parameters:
query
: String containing the search querycount
: Optional number of results (1-20, default: 10)The server broadcasts errors to all connected SSE clients in this format:
{
"type": "error",
"error": "error message"
}
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.
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"
]
}
}
}
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.
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.