ddg-search-mcp

ddg-search-mcp

DuckDuckGo Search MCP Server. Scrapes DuckDuckGo Lite directly — no API key required, no rate limits, robust anti-bot protection.

Category
访问服务器

README

ddg-search-mcp

PyPI version Python versions License

DuckDuckGo Search MCP Server. Scrapes DuckDuckGo Lite directly — no API key required, no rate limits, robust anti-bot protection.

Quick Start

pip install ddg-search-mcp-Albertous007
# or
uvx ddg-search-mcp-Albertous007

From source (before PyPI release)

git clone https://github.com/Albertous007/ddg-search-mcp.git
cd ddg-search-mcp
pip install -e .

Add to your MCP client:

{
    "mcpServers": {
        "ddg-search": {
            "command": "uvx",
            "args": ["ddg-search-mcp-Albertous007"]
        }
    }
}

Features

  • Advanced Anti-bot Protection: Uses curl_cffi to mimic a real Chrome 131 TLS fingerprint (JA3), seamlessly bypassing most bot detection and CAPTCHA systems.
  • Dual Parser Engine: Primary parser for DuckDuckGo Lite HTML, with automatic legacy fallback if the structure changes.
  • Parser Health Warning: If the primary parser fails and no results are found, a warning is included in the output with a link to report the issue.
  • Full Content Extraction: Deep extraction of page content via trafilatura (with automatic snippet fallback on fetch failure).
  • Concurrent Processing: Page content is fetched in parallel to minimize latency.
  • Full Region Support: Regional searches (e.g., es-es for Spain, mx-es for Mexico) using the native DuckDuckGo kl parameter.
  • Zero Configuration: No API keys, accounts, or complex setup required.
  • Structured Logging: All server activity logs to stderr with configurable verbosity.
  • Environment Configuration: All constants tunable via environment variables (see .env.example).

No SafeSearch filter

This server does not implement SafeSearch filtering. All search results are returned as-is from DuckDuckGo. If you need content filtering, consider nickclyde/duckduckgo-mcp-server which supports DDG_SAFE_SEARCH=STRICT | MODERATE | OFF.

This is a deliberate design choice — keeping the server simple, fast, and without feature creep.

Installation

From PyPI (recommended)

pip install ddg-search-mcp-Albertous007

From source

git clone https://github.com/Albertous007/ddg-search-mcp.git
cd ddg-search-mcp
pip install -e .

Usage with opencode

After pip install, the installed console script is the simplest option:

{
    "mcp": {
        "ddg-search": {
            "type": "local",
            "command": ["ddg-search-mcp"],
            "enabled": true
        }
    }
}

With python -m

{
    "mcp": {
        "ddg-search": {
            "type": "local",
            "command": ["python", "-m", "ddg_search_mcp"],
            "enabled": true
        }
    }
}

With uvx

{
    "mcp": {
        "ddg-search": {
            "type": "local",
            "command": ["uvx", "ddg-search-mcp-Albertous007"],
            "enabled": true
        }
    }
}

Tool: search

Parameter Required Default Description
query Yes Search terms
count No 10 Max results (1–10, configurable via DDG_MAX_RESULTS)
region No wt-wt Region: wt-wt (global), us-en (USA), es-es (Spain), etc.

Environment Variables

All settings are optional — defaults are shown below.

Variable Default Description
DDG_LOG_LEVEL INFO Log level: DEBUG, INFO, WARNING, ERROR
DDG_SEARCH_DELAY 3.0 Min seconds between search requests
DDG_MAX_CONTENT_CHARS 6000 Max chars of page content per result
DDG_MAX_SNIPPET_CHARS 400 Max chars of snippet fallback
DDG_PAGE_FETCH_TIMEOUT 8.0 Timeout (s) for fetching result pages
DDG_SEARCH_TIMEOUT 12.0 Timeout (s) for the search request itself
DDG_MAX_RESULTS 10 Max results returned per search (1–10)

Copy .env.example to .env and customize, or set them directly in your environment.

Cross-platform

Works on Windows, Linux, and macOS. Requires Python 3.10+.

Known Issues

Rate limiting (CAPTCHA)

DuckDuckGo aggressively rate-limits requests from a single IP. This MCP uses DuckDuckGo Lite, browser impersonation, and an integrated 3.0s delay with auto-retries to be as robust as possible.

Symptoms: The tool returns No results found for all queries.

Fix: If blocked, wait a few minutes. The rate limit expires automatically.

HTML structure changes

This MCP scrapes DuckDuckGo's HTML directly. If DDG changes their HTML structure, the parsing logic may need to be updated.

When a search returns no results and the parser structure is suspected to have changed, the output includes a warning:

⚠️  DuckDuckGo may have changed their HTML structure.
    If searches fail consistently, report at:
    https://github.com/Albertous007/ddg-search-mcp/issues

This warning only appears when both the primary and fallback parsers fail to extract results.

Development

git clone https://github.com/Albertous007/ddg-search-mcp.git
cd ddg-search-mcp
pip install -e .
cp .env.example .env   # optional: tweak settings
python -m ddg_search_mcp

Test with MCP Inspector:

pip install mcp[cli]
mcp dev src/ddg_search_mcp/server.py

Run unit tests:

pip install pytest
pytest

Requirements

  • Python 3.10+
  • curl_cffi (HTTP client with TLS fingerprinting)
  • beautifulsoup4 (HTML parsing)
  • trafilatura (content extraction)
  • mcp (MCP Python SDK)

Contributing

See CONTRIBUTING.md.

This is a personal project maintained by @Albertous007. If the repository becomes unmaintained, anyone is welcome to fork it.

License

MIT

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选