DuckDuckGo Search MCP Server
Enables web search and content fetching via DuckDuckGo without requiring an API key.
README
DuckDuckGo Search MCP Server
A Model Context Protocol (MCP) server that provides web search and content fetching via DuckDuckGo. No API key required.
Features
- Web Search — Multi-page results (supports 10 ~ 100+ results via automatic pagination)
- Content Fetching — Fetch and parse any webpage to clean text
- Bot Detection & Retry — Automatically retries up to 3 times on DDG bot challenges
- Session Cookie Jar — Persists DDG session cookies in-memory across requests
- Advanced Query Syntax — Full support for DDG/Google-style operators (
site:,OR,intitle:, etc.) - Zero-Click Results — Instant answer cards (e.g. search
ip,weather) - Zero Dependencies at Runtime — Only
cheerio+@modelcontextprotocol/sdk - Node.js & Bun — Works with both runtimes (Node ≥ 18)
Installation
As MCP Server (global CLI)
npm install -g duckduckgo-websearch
# or
npx duckduckgo-websearch
As npm Library
npm install duckduckgo-websearch
MCP Server Usage
Claude Desktop
Edit your Claude Desktop config:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"ddg-search": {
"command": "npx",
"args": ["duckduckgo-websearch"]
}
}
}
Or with a local build:
{
"mcpServers": {
"ddg-search": {
"command": "node",
"args": ["/path/to/duckduckgo-mcp-server/build/index.js"]
}
}
}
Other MCP Clients
Any MCP-compatible client (Cursor, Cline, Continue, etc.) can connect via stdio transport using the same command above.
MCP Tools
search
Search DuckDuckGo and return paginated results.
| Parameter | Type | Default | Description |
|---|---|---|---|
query |
string |
required | Search query. Supports advanced syntax (see below) |
max_results |
integer |
25 |
Number of results to return. Triggers automatic pagination when > 10 |
Advanced Query Syntax (DDG supports Google-style operators):
| Syntax | Example | Effect |
|---|---|---|
site:domain |
site:github.com python |
Restrict to a domain |
site:a.com OR site:b.com |
site:docs.python.org OR site:stackoverflow.com |
Multiple domains |
"exact phrase" |
"model context protocol" |
Exact match |
-word |
python -snake |
Exclude keyword |
intitle:word |
intitle:tutorial python |
Match in page title |
filetype:ext |
filetype:pdf machine learning |
Filter by file type |
OR / AND |
python OR javascript async |
Boolean operators |
Response format:
Found 25 search results:
1. Page Title
URL: https://example.com/page
Summary: Brief description of the page content...
2. ...
fetch_content
Fetch and parse a webpage to clean, LLM-readable text.
| Parameter | Type | Default | Description |
|---|---|---|---|
url |
string |
required | Webpage URL to fetch |
max_content_length |
integer |
8000 |
Maximum characters to return |
Library Usage (Node.js / Bun)
import { WebSearch, WebFetcher } from 'duckduckgo-websearch';
// Search
const searcher = new WebSearch();
// Basic search — returns up to 10 results (1 page)
const results = await searcher.search('claude anthropic');
// Request more results — auto-paginates across multiple DDG pages
const results = await searcher.search('python tutorial', { maxResults: 50 });
// Advanced query syntax works natively in the query string
const results = await searcher.search('site:github.com mcp server typescript');
const results = await searcher.search('site:docs.python.org OR site:realpython.com async await');
// Format for LLM consumption
console.log(searcher.formatResultsForLLM(results));
// Fetch webpage content
const fetcher = new WebFetcher();
const content = await fetcher.fetchAndParse('https://example.com', 8000);
SearchResult type
interface SearchResult {
title: string;
link: string;
snippet: string;
position: number;
}
Error handling
import { WebSearch, SearchError } from 'duckduckgo-websearch';
try {
const results = await searcher.search('query');
} catch (err) {
if (err instanceof SearchError) {
console.error(err.code); // 'BOT_DETECTED' | 'HTTP_ERROR' | 'TIMEOUT' | 'UNKNOWN'
console.error(err.message);
}
}
SearchError codes:
| Code | Meaning |
|---|---|
BOT_DETECTED |
DDG bot challenge triggered after 3 retry attempts |
HTTP_ERROR |
Non-2xx HTTP response |
TIMEOUT |
Request timed out (30s limit) |
UNKNOWN |
Unexpected failure |
Development
git clone https://github.com/HeiSir2014/duckduckgo-mcp-server
cd duckduckgo-mcp-server
npm install
npm run build # compile TypeScript → build/
# Run example test (Bun)
bun example/test.ts
# Run with Node
node -e "require('./build/index.js')"
Architecture
src/
├── index.ts # MCP server entry, tool definitions
├── duckduckgoSearcher.ts # Search logic: fetch, bot detection, retry, pagination
├── cookieJar.ts # In-memory cookie jar for DDG session persistence
├── webContentFetcher.ts # Webpage fetch + text extraction
├── rateLimiter.ts # Token-bucket rate limiter
└── types.ts # Shared types (SearchResult, SearchOptions, SearchError)
Pagination mechanism — DDG HTML endpoint returns 10 results per page with a vqd session token embedded in the "Next" form. When maxResults > 10, the searcher chains page requests using vqd and the form parameters (s, dc) extracted from each page's nav-link.
Bot detection — On each page fetch the searcher checks for missing result containers (.serp__results) and known challenge keywords. On detection it awaits the report ping (/t/sl_h) which warms the session, then retries. After 3 failures it throws SearchError('BOT_DETECTED').
Rate Limits
| Operation | Limit |
|---|---|
| Search | 30 requests / minute |
| Content Fetch | 20 requests / minute |
License
MIT
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。