duckduckgo-mcp

duckduckgo-mcp

Search the web using DuckDuckGo and fetch/convert web content using Jina Reader. Privacy-focused search with no API key required.

Category
访问服务器

README

DuckDuckGo MCP Server

PyPI Python Version License: MIT Downloads Smithery

A Model Context Protocol (MCP) server that provides two capabilities:

  1. Search the web using DuckDuckGo
  2. Fetch and convert web content using Jina Reader

Features

  • DuckDuckGo web search with safe search controls
  • Fetch and convert URLs to markdown or JSON using Jina Reader
  • LLM-friendly output format option for search results
  • CLI for search, fetch, serve, and version commands
  • MCP tools for LLM integration
  • Docker support for containerized deployment

Installation

Prerequisites

  • Python 3.10 or higher
  • uv (recommended) or pip

Install from PyPI (recommended)

# Using uv (recommended)
uv pip install duckduckgo-mcp

# Or using pip
pip install duckduckgo-mcp

Install with UVX (for Claude Desktop)

# Install UVX if you haven't already
pip install uvx

# Install the DuckDuckGo MCP package
uvx install duckduckgo-mcp

Install via Smithery

To install DuckDuckGo MCP Server for Claude Desktop automatically via Smithery:

npx -y @smithery/cli install @cyranob/duckduckgo-mcp --client claude

Install from source

For development or to get the latest changes:

# Clone the repository
git clone https://github.com/CyranoB/duckduckgo-mcp.git
cd duckduckgo-mcp

# Install with uv (recommended)
uv pip install -e .

# Or with pip
pip install -e .

Docker

Build and run with Docker:

# Build the image (uses version from latest git tag)
docker build --build-arg VERSION=$(git describe --tags --abbrev=0 | sed 's/^v//') -t duckduckgo-mcp .

# Or specify a version manually
docker build --build-arg VERSION=2.0.2 -t duckduckgo-mcp .

# Run the server (MCP servers use STDIO, so typically run within an MCP client)
docker run -i duckduckgo-mcp

Usage

Starting the Server (STDIO Mode)

# Start the server in STDIO mode (for use with MCP clients like Claude)
duckduckgo-mcp serve

# Enable debug logging
duckduckgo-mcp serve --debug

Testing the Search Tool

# Search DuckDuckGo (JSON output, default)
duckduckgo-mcp search "your search query" --max-results 5 --safesearch moderate

# Search with LLM-friendly text output
duckduckgo-mcp search "your search query" --output-format text

Testing the Fetch Tool

# Fetch a URL and return markdown
duckduckgo-mcp fetch "https://example.com" --format markdown

# Fetch a URL and return JSON
duckduckgo-mcp fetch "https://example.com" --format json

# Limit output length

duckduckgo-mcp fetch "https://example.com" --max-length 2000

# Include generated image alt text
duckduckgo-mcp fetch "https://example.com" --with-images

Version Information

# Show version
duckduckgo-mcp version

# Show detailed version info
duckduckgo-mcp version --debug

MCP Client Setup

This MCP server works with any MCP-compatible client. Use one of the setups below.

Python 3.10-3.13 is supported (3.14 not yet). Use --python ">=3.10,<3.14" with uvx to enforce. Verified with Python 3.12 and 3.13.

Claude Desktop

  1. Open Claude Desktop > Settings > Developer > Edit Config.
  2. Edit the config file:
    • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
    • Windows: %APPDATA%\Claude\claude_desktop_config.json
  3. Add the server config under mcpServers:
     {
       "mcpServers": {
         "duckduckgo": {
           "command": "uvx",
           "args": ["--python", ">=3.10,<3.14", "duckduckgo-mcp", "serve"]
         }
       }
     }
    
    
  4. Restart Claude Desktop.

Claude Code

Add a local stdio server:

claude mcp add --transport stdio duckduckgo -- uvx --python ">=3.10,<3.14" duckduckgo-mcp serve

Optional: claude mcp list to verify, or claude mcp add-from-claude-desktop to import.

Codex (CLI + IDE)

Add via CLI:

codex mcp add duckduckgo -- uvx --python ">=3.10,<3.14" duckduckgo-mcp serve

Or configure ~/.codex/config.toml:

[mcp_servers.duckduckgo]
command = "uvx"
args = ["--python", ">=3.10,<3.14", "duckduckgo-mcp", "serve"]

OpenCode

Add to your OpenCode config (~/.config/opencode/opencode.json or project opencode.json):

{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "duckduckgo": {
      "type": "local",
      "command": ["uvx", "--python", ">=3.10,<3.14", "duckduckgo-mcp", "serve"],
      "enabled": true
    }
  }
}

Or run opencode mcp add and follow the prompts.

Cursor

Add to ~/.cursor/mcp.json (global) or .cursor/mcp.json (project):

{
  "mcpServers": {
    "duckduckgo": {
      "command": "uvx",
      "args": ["--python", ">=3.10,<3.14", "duckduckgo-mcp", "serve"]
    }
  }
}

Verify with:

cursor-agent mcp list

MCP Tools

The server exposes these tools to MCP clients:

@mcp.tool()
def duckduckgo_search(
    query: str,
    max_results: int = 5,
    safesearch: str = "moderate",
    output_format: str = "json"
) -> list | str:
    """Search DuckDuckGo for the given query."""
@mcp.tool()
def jina_fetch(url: str, format: str = "markdown", max_length: int | None = None, with_images: bool = False) -> str | dict:
    """Fetch a URL and convert it using Jina Reader."""

Example usage in an MCP client:

# This is handled automatically by the MCP client
results = duckduckgo_search("Python programming", max_results=3)
content = jina_fetch("https://example.com", format="markdown")

# Get LLM-friendly text output
text_results = duckduckgo_search("Python programming", output_format="text")

API

Tool 1: Search

  • Tool Name: duckduckgo_search
  • Description: Search the web using DuckDuckGo (powered by the ddgs library)

Parameters

  • query (string, required): The search query
  • max_results (integer, optional, default: 5): Maximum number of search results to return
  • safesearch (string, optional, default: "moderate"): Safe search setting ("on", "moderate", or "off")
  • output_format (string, optional, default: "json"): Output format - "json" for structured data, "text" for LLM-friendly formatted string

Response

JSON format (default): A list of dictionaries:

[
  {
    "title": "Result title",
    "url": "https://example.com",
    "snippet": "Text snippet from the search result"
  }
]

Text format: An LLM-friendly formatted string:

Found 3 search results:

1. Result title
   URL: https://example.com
   Summary: Text snippet from the search result

2. Another result
   URL: https://example2.com
   Summary: Another snippet

Tool 2: Fetch

  • Tool Name: jina_fetch
  • Description: Fetch a URL and convert it to markdown or JSON using Jina Reader

Parameters

  • url (string, required): The URL to fetch and convert
  • format (string, optional, default: "markdown"): Output format ("markdown" or "json")
  • max_length (integer, optional): Maximum content length to return (None for no limit)
  • with_images (boolean, optional, default: false): Whether to include image alt text generation

Response

For markdown format: a string containing markdown content

For JSON format: a dictionary with the structure:

{
  "url": "https://example.com",
  "title": "Page title",
  "content": "Markdown content"
}

Notes

  • Search uses the ddgs package (renamed from duckduckgo-search).
  • Fetch uses the Jina Reader API at https://r.jina.ai/.

Contributing

Contributions are welcome! Here's how you can contribute:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Support

If you encounter any issues or have questions, please open an issue.

License

This project is licensed under the MIT License - see the LICENSE file for details.

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选