DuckDuckGo MCP Agent

DuckDuckGo MCP Agent

A minimal, production-ready MCP server enabling LLMs to perform web searches via DuckDuckGo without API keys, supporting SSE streaming and LM Studio compatibility.

Category
Visit Server

README

DuckDuckGo MCP Agent

A minimal, production-ready Model Context Protocol (MCP) server enabling LLMs to perform web searches via DuckDuckGo. Built with FastAPI and Server-Sent Events (SSE).

Features:

  • ✅ Single-file implementation (~324 lines)
  • ✅ No API keys required
  • ✅ HTTP + SSE streaming (LM Studio compatible)
  • ✅ Docker-ready
  • ✅ Minimal dependencies (FastAPI, Uvicorn, duckduckgo-search)

Quick Start

Prerequisites

  • Python 3.10+ or Docker
  • LM Studio (optional)

Option 1: Dev Container (Recommended)

  1. Install VS Code and Docker Desktop
  2. Install Dev Containers extension
  3. Open folder in VS Code → "Reopen in Container"

Option 2: Local Development

make install-dev
make run-dev
# Server: http://localhost:8000

Option 3: Docker

make docker-build
make docker-run
# Or: make docker-compose

Usage

HTTP Request

curl -X POST http://localhost:8000/ \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "tools/call",
    "params": {
      "name": "web_search",
      "arguments": {"query": "Python async", "all_results": true, "region": "us-en", "safesearch": "moderate", "timelimit": "w"}
    }
  }'

MCP Protocol

Initialize:

{"method": "initialize", "id": 1}

List Tools:

{"method": "tools/list", "id": 2}

Call Search:

{
  "method": "tools/call",
  "id": 3,
  "params": {
    "name": "web_search",
    "arguments": {"query": "your query", "max_results": 5, "all_results": false, "region": "wt-wt", "safesearch": "moderate"}
  }
}

LM Studio Configuration

Add to mcp-config.json:

{
  "mcpServers": {
    "duckduckgo-search": {
      "type": "http",
      "url": "http://localhost:8000",
      "disabled": false
    }
  }
}

Architecture

Data Flow:

LM Studio → POST / (JSON-RPC) → FastAPI → SSE Events → Client
                                    ↓
                            MCP Handlers (initialize, tools/list, tools/call)
                                    ↓
                            DuckDuckGo Search API

Key Components:

  • mcp_http_sse_server.py - Single FastAPI app with async streaming
  • requirements.txt - Dependencies only
  • Dockerfile - Production & dev stages
  • docker-compose.yml - Orchestration
  • test-mcp-sse.py - Integration tests

Development

Make Commands

make help              # Show all commands
make install-dev      # Install dev dependencies
make run-dev          # Run with auto-reload
make test             # Run tests
make lint             # Ruff + mypy type checking
make format           # Black + ruff auto-format
make clean            # Remove build artifacts
make docker-build     # Build Docker image
make docker-compose   # Run with Docker Compose

Code Quality

make format  # Auto-format code
make lint    # Run linters

Configuration

Environment Variables

Variable Default Purpose
MCP_DEBUG false Verbose logging
MCP_ENVIRONMENT production Dev mode
MCP_LOG_LEVEL INFO Log level
MCP_PORT 8000 Server port

Docker

Set in docker-compose.yml:

environment:
  - MCP_ENVIRONMENT=development
  - MCP_LOG_LEVEL=INFO

Production requires: mcp_http_sse_server.py + requirements.txt


API Reference

Response Format (SSE)

event: message
data: {"jsonrpc": "2.0", "id": 1, "result": {...}}

event: done
data: {}

Search Tool

  • Input:
    • query (string, required)
    • max_results (int, 1-10, default 5). Ignored when all_results is true.
    • all_results (boolean, default false): fetch maximum results (capped at 10)
    • region (string, default wt-wt)
    • safesearch (string enum: off|moderate|strict, default moderate)
    • timelimit (string enum: d|w|m|y, optional)
  • Output: Formatted markdown with title, URL, snippet

Contributing

Keep this project minimal:

  1. Single-file design (avoid modularization)
  2. MCP protocol compliance
  3. Test with real LM Studio
  4. Run make format && make lint before submission

Support


Changelog

  • 1.2.0: Add all_results flag (internal cap 100) to support larger result sets; bump version and docs.
  • 1.1.0: Improved DuckDuckGo search with region/safesearch/timelimit parameters; better markdown formatting; version surfaced in initialize.

License

See LICENSE

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured