DuckDuckGo Search MCP server

Integrates with DuckDuckGo to enable web search functionality, returning results as structured data for easy incorporation into AI workflows.
Back to servers
Provider
lowlyocean
Release date
Feb 19, 2025
Language
Python

The MCP (Model Context Protocol) server enables search capabilities using Duck Duck Go as the backend search engine. It leverages SSE (Server-Sent Events) transport and is based on Open-WebUI's web search functionality.

Installation

Prerequisites

  • Python 3.10 or higher
  • pip (Python package manager)

Setup

  1. Clone the repository and navigate to the project directory:
git clone https://github.com/username/mcp-server.git
cd mcp-server
  1. Create and activate a virtual environment (recommended):
python -m venv venv
# On Windows
venv\Scripts\activate
# On macOS/Linux
source venv/bin/activate
  1. Install the required dependencies:
pip install -r requirements.txt

Running the Server

To start the MCP server with default settings:

python server.py

By default, the server runs on port 8000. You can specify a different port using the -p or --port flag:

python server.py --port 8080

Configuration

Environment Variables

You can configure the server using the following environment variables:

  • MCP_PORT: The port on which the server will listen (default: 8000)
  • MCP_HOST: The host address to bind the server (default: 0.0.0.0)
  • SEARCH_LIMIT: Maximum number of search results to return (default: 5)

Example:

export MCP_PORT=8080
export SEARCH_LIMIT=10
python server.py

Using the MCP Server

Basic Search Query

To perform a search, send a POST request to the /search endpoint:

curl -X POST http://localhost:8000/search \
  -H "Content-Type: application/json" \
  -d '{"query": "climate change solutions"}'

Advanced Usage

Streaming Results

The server supports SSE (Server-Sent Events) for streaming search results. You can connect to the streaming endpoint using compatible clients:

// JavaScript example
const eventSource = new EventSource('http://localhost:8000/search/stream?query=climate+change');
eventSource.onmessage = function(event) {
  const data = JSON.parse(event.data);
  console.log(data);
};

Search Parameters

You can customize your search with additional parameters:

curl -X POST http://localhost:8000/search \
  -H "Content-Type: application/json" \
  -d '{
    "query": "renewable energy",
    "limit": 3,
    "region": "us-en",
    "time_range": "d" 
  }'

Supported parameters:

  • limit: Number of results to return
  • region: Search region code
  • time_range: Time filter (d=day, w=week, m=month)

Troubleshooting

Common Issues

  • Connection refused errors: Ensure the server is running and the port is not blocked by a firewall
  • No search results: Verify your query is not empty and check your internet connection
  • Timeout errors: The search backend might be temporarily unavailable

Server Logs

The server outputs logs to the console that can help diagnose issues. Run with higher verbosity for more detailed logs:

python server.py --debug

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