DuckDuckGo MCP Server
Provides DuckDuckGo web search via its HTML endpoint, returning formatted results with titles, links, and snippets; supports SafeSearch, region/language, and result limits.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@DuckDuckGo MCP Server search for the latest Python 3.13 release notes"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
ChatMooc DuckDuckGo Search MCP Server
项目简介
这是一个基于 Model Context Protocol (MCP) 的 DuckDuckGo 搜索服务,提供 网页搜索 与 网页内容抓取 两个工具,并内置速率限制与安全过滤配置。项目使用 FastMCP 框架构建,适用于 Claude Desktop、Claude Code 或其他 MCP 客户端。
本仓库基于 nickclyde/duckduckgo-mcp-server 派生,增加了 LangGraph Client 适配以及 HTTP 传输支持的示例与说明。
Related MCP server: Oxylabs Web API MCP Server
Docker 部署(推荐)
docker compose up --build -d
# 或使用原生 Docker
docker build -t duckduckgo-mcp-server .
docker run -d -p 8000:8000 \
-e DDG_SAFE_SEARCH=MODERATE \
-e DDG_REGION= \
duckduckgo-mcp-serverHTTP 端点:http://localhost:8000/mcp
功能特性
DuckDuckGo 网页搜索(解析 HTML 结果)
网页正文抓取(移除脚本/样式/导航等非正文元素)
速率限制:搜索 30 次/分钟,抓取 20 次/分钟
SafeSearch 与地区/语言配置
适配 LangGraph 客户端(支持 stdio 与 HTTP 连接)
架构概览
核心实现位于 src/duckduckgo_mcp_server/server.py:
DuckDuckGoSearcher:向https://html.duckduckgo.com/html发送 POST 请求并解析结果WebContentFetcher:抓取网页并提取纯文本内容(默认最大 8000 字符)RateLimiter:滑动窗口限流
对外暴露两个 MCP 工具:search 与 fetch_content。
快速开始
uvx duckduckgo-mcp-server安装
uv pip install duckduckgo-mcp-server使用方式
Claude Desktop
配置文件路径:
macOS:
~/Library/Application Support/Claude/claude_desktop_config.jsonWindows:
%APPDATA%\Claude\claude_desktop_config.json
基础配置:
{
"mcpServers": {
"ddg-search": {
"command": "uvx",
"args": ["duckduckgo-mcp-server"]
}
}
}带 SafeSearch 和地区配置:
{
"mcpServers": {
"ddg-search": {
"command": "uvx",
"args": ["duckduckgo-mcp-server"],
"env": {
"DDG_SAFE_SEARCH": "STRICT",
"DDG_REGION": "cn-zh"
}
}
}
}修改配置后请重启 Claude Desktop。
Claude Code
claude mcp add ddg-search uvx duckduckgo-mcp-server传输方式(Transport)
默认使用 stdio。如需 HTTP 传输,可选择 SSE 或 Streamable HTTP。
# SSE
uvx duckduckgo-mcp-server --transport sse
# Streamable HTTP(适合 Docker/远程)
uvx duckduckgo-mcp-server --transport streamable-http --host 0.0.0.0 --port 8000HTTP 端点为:http://localhost:8000/mcp。
LangGraph Client 适配
通过 langchain-mcp-adapters 的 MultiServerMCPClient 即可接入 LangGraph。
注意命名差异:
服务端 CLI 传输参数:
--transport streamable-http客户端 transport 键:
streamable_http
stdio 示例
from langchain_mcp_adapters.client import MultiServerMCPClient
client = MultiServerMCPClient(
connections={
"duckduckgo": {
"command": "uvx",
"args": ["duckduckgo-mcp-server"],
"transport": "stdio",
}
}
)HTTP 示例
from langchain_mcp_adapters.client import MultiServerMCPClient
client = MultiServerMCPClient(
connections={
"duckduckgo": {
"transport": "streamable_http",
"url": "http://localhost:8000/mcp",
}
}
)可参考示例文件:
tests/example_langgraph_direct.pytests/example_langgraph_http.pytests/test_langgraph_integration.py
MCP 工具说明
1) search
async def search(query: str, max_results: int = 10, region: str = "") -> str参数说明:
query:搜索关键词max_results:最多返回结果数(默认 10,建议 1-20)region:地区/语言代码(可覆盖默认值)
返回值为格式化文本,包含标题、链接与摘要。
2) fetch_content
async def fetch_content(url: str, start_index: int = 0, max_length: int = 8000) -> str参数说明:
url:网页 URL(需以 http/https 开头)start_index:内容起始字符位置(分页使用)max_length:最大返回字符数(默认 8000)
返回值为清洗后的正文文本,并附带分页元信息。
配置项(启动时读取)
DDG_SAFE_SEARCH:STRICT/MODERATE(默认)/OFFDDG_REGION:默认地区/语言代码,例如us-en、cn-zh、jp-ja、wt-wt
开发与测试
# 安装依赖
uv sync
# 本地运行
uv run duckduckgo-mcp-server
# MCP Inspector
mcp dev src/duckduckgo_mcp_server/server.py
# 全部测试
uv run python -m pytest src/duckduckgo_mcp_server/ -v
# 单元测试
uv run python -m pytest src/duckduckgo_mcp_server/test_server.py -v
# E2E 测试
uv run python -m pytest src/duckduckgo_mcp_server/test_e2e.py -v
# LangGraph 集成测试(需要 OPENAI_API_KEY)
python tests/test_langgraph_integration.py常见问题
LangGraph 代理测试需要设置
OPENAI_API_KEY,否则只会运行工具加载测试。如果使用 HTTP 传输,请确保服务端以
streamable-http启动,并访问/mcp端点。
致谢
DuckDuckGo 搜索服务
MCP 与 FastMCP 框架
httpx、beautifulsoup4等关键依赖LangGraph 与
langchain-mcp-adapters
Available Tools
2 toolsfetch_contentA
Fetch and extract the main text content from a webpage. Strips out navigation, headers, footers, scripts, and styles to return clean readable text. Use this after searching to read the full content of a specific result. Supports pagination for long pages via start_index and max_length.
Args: url: The full URL of the webpage to fetch (must start with http:// or https://). start_index: Character offset to start reading from (default: 0). Use this to paginate through long content. max_length: Maximum number of characters to return (default: 8000). Increase for more content per request or decrease for quicker responses. ctx: MCP context for logging.
Inputs: url (required), max_length, start_index. Returns: result
searchA
Search the web using DuckDuckGo. Returns a list of results with titles, URLs, and snippets. Use this to find current information, research topics, or locate specific websites. For best results, use specific and descriptive search queries.
Args: query: The search query string. Be specific for better results (e.g., 'Python asyncio tutorial' rather than 'Python'). max_results: Maximum number of results to return, between 1 and 20 (default: 10). region: Optional region/language code to localize results. Examples: 'us-en' (USA/English), 'uk-en' (UK/English), 'de-de' (Germany/German), 'fr-fr' (France/French), 'jp-ja' (Japan/Japanese), 'cn-zh' (China/Chinese), 'wt-wt' (no region). Leave empty to use the server default. ctx: MCP context for logging.
Inputs: query (required), region, max_results. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 2 tools
The two tools serve clearly different stages of a workflow: search discovers URLs and fetch_content reads a chosen URL. There is no overlap in inputs or outputs, and the descriptions explicitly state the sequencing ('Use this after searching').
Both names are lowercase snake_case verbs, so the convention is coherent. However, 'search' is a bare verb while 'fetch_content' is verb_noun, a minor asymmetry.
Two tools is thin even for a focused search server; the search-and-read loop is minimal but nothing else (news, instant answers, site-scoped search) is exposed as a distinct capability. Each tool does earn its place, so it is not an extreme mismatch.
The core discover-then-read lifecycle is fully covered, including pagination parameters for long pages and region/max_results controls on search. Some expected search variants (news, images) are absent, but agents can work around this with query phrasing.
Maintenance
Related MCP Connectors
Scrape, crawl and search the web for AI agents via MCP.
Web search API and MCP server for developers building AI agents.
Search, read, and act on the web. The Stophy MCP server for agents.
Web search and page reading for AI agents, including JSON APIs, RSS feeds and YouTube.
Related MCP Servers
- FlicenseNot gradedqualityCmaintenanceMCP server that exposes web_search and web_fetch tools, allowing LLM applications to search the web via DuckDuckGo and fetch page content as cleaned markdown.1-
- AlicenseAqualityCmaintenanceGives MCP-capable agents live web access: search the web, scrape pages into Markdown (including JavaScript-heavy and bot-protected sites), and extract named fields as JSON, with job polling, token-aware content offloading, and built-in research guidance. Ships as a self-hostable stdio or HTTP service with spend caps and per-request key support.7MIT
- FlicenseNot gradedqualityAmaintenanceEnables AI agents to search the web through configured providers and crawl individual pages or entire sites into clean Markdown or JSON, including authenticated browsing and deduplicated output. It can run locally over STDIO or HTTP and integrates with MCP clients and command-line workflows.-
- FlicenseNot gradedqualityAmaintenanceEnables AI agents to search the web in parallel through SearXNG and/or You.com and to crawl single pages or entire sites into clean, deduplicated Markdown or JSON. It also supports authenticated crawls and both STDIO and HTTP MCP transports.-