DuckDuckGo MCP Server

Integrations

  • Provides search capabilities through tools for text, image, news, and video searches using DuckDuckGo's API, plus access to DuckDuckGo's AI chat with multiple model options.

  • Provides access to Meta's Llama 3.3 70B model through the DuckDuckGo AI chat tool.

  • Enables interaction with OpenAI's models (GPT-4o-mini and O3-mini) through the DuckDuckGo AI chat tool.

ddg-mcp MCP 服务器

DuckDuckGo 搜索 API MCP - 通过模型上下文协议提供 DuckDuckGo 搜索功能的服务器。

成分

提示

服务器给出如下提示:

  • search-results-summary :创建 DuckDuckGo 搜索结果的摘要
    • 搜索词的必需“查询”参数
    • 可选的“样式”参数用于控制详细程度(简要/详细)

工具

服务器实现了以下 DuckDuckGo 搜索工具:

  • ddg-text-search :使用 DuckDuckGo 在网络上搜索文本结果
    • 必需:“关键词” - 搜索查询关键词
    • 可选:“region”、“safesearch”、“timelimit”、“max_results”
  • ddg-image-search :使用 DuckDuckGo 在网络上搜索图片
    • 必需:“关键词” - 搜索查询关键词
    • 可选:“区域”、“安全搜索”、“时间限制”、“大小”、“颜色”、“类型图像”、“布局”、“许可证图像”、“最大结果”
  • ddg-news-search :使用 DuckDuckGo 搜索新闻文章
    • 必需:“关键词” - 搜索查询关键词
    • 可选:“region”、“safesearch”、“timelimit”、“max_results”
  • ddg-video-search :使用 DuckDuckGo 搜索视频
    • 必需:“关键词” - 搜索查询关键词
    • 可选:“区域”、“安全搜索”、“时间限制”、“分辨率”、“持续时间”、“license_videos”、“max_results”
  • ddg-ai-chat :与 DuckDuckGo AI 聊天
    • 必填:“关键词” - 发送给 AI 的消息或问题
    • 可选:“模型”- 要使用的 AI 模型(选项:“gpt-4o-mini”、“llama-3.3-70b”、“claude-3-haiku”、“o3-mini”、“mistral-small-3”)

安装

先决条件

  • Python 3.9 或更高版本
  • uv (推荐)或 pip

从 PyPI 安装

# Using uv uv install ddg-mcp # Using pip pip install ddg-mcp

从源安装

  1. 克隆存储库:
git clone https://github.com/misanthropic-ai/ddg-mcp.git cd ddg-mcp
  1. 安装软件包:
# Using uv uv install -e . # Using pip pip install -e .

配置

必需的依赖项

服务器需要duckduckgo-search包,当您安装ddg-mcp时它将自动安装。

如果需要手动安装:

uv install duckduckgo-search # or pip install duckduckgo-search

DuckDuckGo 搜索参数

通用参数

这些参数适用于大多数搜索类型:

  • region :本地化结果的区域代码(默认值:“wt-wt”)
    • 例如:“us-en”(美式英语)、“uk-en”(英式英语)、“ru-ru”(俄语)
    • 查看DuckDuckGo 区域以了解更多选项
  • safesearch :内容过滤级别(默认值:“中等”)
    • "on": 严格过滤
    • “moderate”:中等过滤
    • “off”:不过滤
  • timelimit :结果的时间范围
    • “d”:最后一天
    • “w”:上周
    • “m”:上个月
    • “y”:去年(不适用于新闻/视频)
  • max_results :返回的最大结果数(默认值:10)

搜索运算符

您可以在搜索关键字中使用这些运算符:

  • cats dogs :关于猫或狗的搜索结果
  • "cats and dogs" :精确搜索“猫和狗”的结果
  • cats -dogs :搜索结果中狗的数量较少
  • cats +dogs :搜索结果中狗更多
  • cats filetype:pdf :关于猫的 PDF(支持:pdf、doc(x)、xls(x)、ppt(x)、html)
  • dogs site:example.com :来自 example.com 的关于狗的页面
  • cats -site:example.com :关于猫的页面,不包括 example.com
  • intitle:dogs :页面标题包含单词“dogs”
  • inurl:cats :页面 URL 包含单词“cats”

图像搜索特定参数

  • 尺寸:“小”、“中”、“大”、“壁纸”
  • 颜色:“颜色”、“单色”、“红色”、“橙色”、“黄色”、“绿色”、“蓝色”、“紫色”、“粉色”、“棕色”、“黑色”、“灰色”、“青色”、“白色”
  • type_image :“照片”、“剪贴画”、“gif”、“透明”、“线条”
  • 布局:“方形”、“高”、“宽”
  • license_image :“任何”、“公开”、“共享”、“商业共享”、“修改”、“商业修改”

视频搜索特定参数

  • 分辨率:“高”,“标准”
  • 持续时间:“短”、“中”、“长”
  • license_videos :“creativeCommon”,“youtube”

AI聊天模型

  • gpt-4o-mini :OpenAI 的 GPT-4o 迷你模型
  • llama-3.3-70b : Meta 的 Llama 3.3 70B 型号
  • claude-3-haiku :Anthropic 的 Claude 3 Haiku 模型
  • o3-mini :OpenAI 的 O3 迷你模型
  • mistral-small-3 :Mistral AI 的小型模型

快速入门

安装

克劳德桌面

在 MacOS 上: ~/Library/Application\ Support/Claude/claude_desktop_config.json在 Windows 上: %APPDATA%/Claude/claude_desktop_config.json

使用示例

文本搜索

Use the ddg-text-search tool to search for "climate change solutions"

高级示例:

Use the ddg-text-search tool to search for "renewable energy filetype:pdf site:edu" with region "us-en", safesearch "off", timelimit "y", and max_results 20

图像搜索

Use the ddg-image-search tool to find images of "renewable energy" with color set to "Green"

高级示例:

Use the ddg-image-search tool to find images of "mountain landscape" with size "Large", color "Blue", type_image "photo", layout "Wide", and license_image "Public"

新闻搜索

Use the ddg-news-search tool to find recent news about "artificial intelligence" from the last day

高级示例:

Use the ddg-news-search tool to search for "space exploration" with region "uk-en", timelimit "w", and max_results 15

视频搜索

Use the ddg-video-search tool to find videos about "machine learning tutorials" with duration set to "medium"

高级示例:

Use the ddg-video-search tool to search for "cooking recipes" with resolution "high", duration "short", license_videos "creativeCommon", and max_results 10

人工智能聊天

Use the ddg-ai-chat tool to ask "What are the latest developments in quantum computing?" using the claude-3-haiku model

搜索结果摘要

Use the search-results-summary prompt with query "space exploration" and style "detailed"

克劳德配置

"ddg-mcp": { "command": "uv", "args": [ "--directory", "/PATH/TO/YOUR/INSTALLATION/ddg-mcp", "run", "ddg-mcp" ] },

发展

构建和发布

准备分发包:

  1. 同步依赖项并更新锁文件:
uv sync
  1. 构建软件包分发版:
uv build

这将在dist/目录中创建源和轮子分布。

  1. 发布到 PyPI:
uv publish

注意:您需要通过环境变量或命令标志设置 PyPI 凭据:

  • 令牌: --tokenUV_PUBLISH_TOKEN
  • 或用户名/密码: --username / UV_PUBLISH_USERNAME--password / UV_PUBLISH_PASSWORD

使用 GitHub Actions 自动发布

此仓库包含一个 GitHub Actions 工作流,用于自动发布到 PyPI。以下情况会触发该工作流:

  1. 创建了一个新的 GitHub 版本
  2. 该工作流程通过 GitHub Actions 界面手动触发

要设置自动发布:

  1. 生成 PyPI API 令牌:
  2. 将令牌添加到您的 GitHub 存储库机密中:
    • 前往 GitHub 上的存储库
    • 导航至“设置”>“机密和变量”>“操作”
    • 点击“新建存储库秘密”
    • 名称: PYPI_API_TOKEN
    • 值:粘贴您的 PyPI 令牌
    • 点击“添加秘密”
  3. 要发布新版本:
    • 更新pyproject.toml中的版本号
    • 在 GitHub 上创建新版本或手动触发工作流程

调试

由于 MCP 服务器通过 stdio 运行,调试起来可能比较困难。为了获得最佳调试体验,我们强烈建议使用MCP Inspector

您可以使用以下命令通过npm启动 MCP Inspector:

npx @modelcontextprotocol/inspector uv --directory /path/to/your/ddg-mcp run ddg-mcp

启动后,检查器将显示一个 URL,您可以在浏览器中访问该 URL 以开始调试。

-
security - not tested
F
license - not found
-
quality - not tested

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

通过模型上下文协议提供DuckDuckGo搜索功能(文本、图片、新闻、视频搜索和AI聊天)的服务器。

  1. Components
    1. Prompts
    2. Tools
  2. Installation
    1. Prerequisites
    2. Install from PyPI
    3. Install from Source
  3. Configuration
    1. Required Dependencies
  4. DuckDuckGo Search Parameters
    1. Common Parameters
    2. Search Operators
    3. Image Search Specific Parameters
    4. Video Search Specific Parameters
    5. AI Chat Models
  5. Quickstart
    1. Install
  6. Usage Examples
    1. Text Search
    2. Image Search
    3. News Search
    4. Video Search
    5. AI Chat
    6. Search Results Summary
  7. Claude config
    1. Development
      1. Building and Publishing
      2. Automated Publishing with GitHub Actions
      3. Debugging
    ID: 6u224dm69g