使用说明
ddg-mcp-mcp服务器
DuckDuckGo搜索API MCP-通过模型上下文协议提供DuckDuck Go搜索功能的服务器。
组件
提示
服务器提供以下提示:
- 搜索结果摘要:创建DuckDuckGo搜索结果摘要
- 搜索词的必填“query”参数
- 可选的“style”参数,用于控制详细程度(简短/详细)
工具
服务器实现了以下DuckDuckGo搜索工具:
-
ddg文本搜索:使用DuckDuckGo在网上搜索文本结果
- 必填项:“关键字”-搜索查询关键字
- 可选:“区域”、“安全搜索”、“时间限制”、“max_results”
-
ddg图像搜索:使用DuckDuckGo在网上搜索图像
- 必填项:“关键字”-搜索查询关键字
- 可选:“区域”、“安全搜索”、“时间限制”、“大小”、“颜色”、“类型_图像”、“布局”、“许可证_图像”和“max_results”
-
ddg新闻搜索:使用DuckDuckGo搜索新闻文章
- 必填项:“关键字”-搜索查询关键字
- 可选:“区域”、“安全搜索”、“时间限制”、“max_results”
-
ddg视频搜索:使用DuckDuckGo搜索视频
- 必填项:“关键字”-搜索查询关键字
- 可选:“区域”、“安全搜索”、“时间限制”、“分辨率”、“持续时间”、“license_videos”、“max_results”
-
ddg-ai聊天:与DuckDuckGo AI聊天
- 必填:“关键字”-要发送给AI的消息或问题
- 可选:“模型”-要使用的AI模型(选项:“gpt-4o-mini”、“llama-3.3-70b”、“claude-3-haiku”、“o3-mini”、“mistral-small-3”)
安装
先决条件
- Python 3.9或更高版本
- 紫外线 (推荐)或pip
从PyPI安装
# Using uv
uv install ddg-mcp
# Using pip
pip install ddg-mcp
从源代码安装
- 克隆存储库:
git clone https://github.com/misanthropic-ai/ddg-mcp.git
cd ddg-mcp
- 安装软件包:
# Using uv
uv install -e .
# Using pip
pip install -e .
配置
所需依赖关系
服务器需要 duckduckgo-search 软件包,安装时会自动安装 ddg-mcp.
如果需要手动安装:
uv install duckduckgo-search
# or
pip install duckduckgo-search
DuckDuckGo搜索参数
公共参数
这些参数适用于大多数搜索类型:
-
区域:本地化结果的区域代码(默认值:“wt wt”)
- 示例:“us en”(美国英语)、“uk en”(英国英语)和“ru ru”(俄语)
- 看 DuckDuckGo地区 更多选项
-
安全搜索:内容过滤级别(默认:“中等”)
- “on”:严格筛选
- “中等”:中等过滤
- “关闭”:无过滤
-
时间限制:结果的时间范围
- “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.comintitle:dogs:页面标题包含单词“狗”inurl:cats:页面URL包含单词“cats”
图像搜索特定参数
- 尺寸:“小”、“中”、“大”、“壁纸”
- 颜色:“彩色”、“单色”、“红色”、“橙色”、“黄色”、“绿色”、“蓝色”、“紫色”、“粉色”、“棕色”、“黑色”、“灰色”、“青色”、“白色”
- 类型_图像:“照片”、“剪贴画”、“gif”、“透明”、“线条”
- 布局:“方形”、“高”、“宽”
- license_image:“任何”、“公开”、“股份”、“商业性共享”、“修改”、“以商业方式修改”
视频搜索特定参数
- 决心:“高”、“标准”
- 持续时间:“短”、“中”、“长”
- 许可证_视频:“creativeCommon”、“youtube”
AI聊天模型
- gpt-4o-mini:OpenAI的GPT-4o迷你模型
- 骆驼-3.3-70b:Meta的Llama 3.3 70B型号
- claude-3-俳句:Anthropic的Claude 3 Haiku模型
- o3迷你:OpenAI的O3迷你模型
- mistral-small-3:Mistral AI的小型模型
快速启动
运行服务器
您可以直接运行服务器:
ddg-mcp
默认情况下,它使用可流式传输的http。要使用stdio传输,请执行以下操作:
ddg-mcp --transport stdio
要使用流式http传输,请执行以下操作:
ddg-mcp --transport streamable-http
您还可以为SSE和可流式传输的http指定主机和端口:
ddg-mcp --host 0.0.0.0 --port 3001
安装
克劳德桌面
在MacOS上: ~/Library/Application\ Support/Claude/claude_desktop_config.json
在Windows上: %APPDATA%/Claude/claude_desktop_config.json
Development/Unpublished Servers Configuration
``` "mcpServers": { "ddg-mcp": { "command": "uv", "args": [ "--directory", "/Users/shannon/Workspace/artivus/ddg-mcp", "run", "ddg-mcp", "--transport", "stdio" ] } } ```Published Servers Configuration
``` "mcpServers": { "ddg-mcp": { "command": "uvx", "args": [ "ddg-mcp", "--transport", "stdio" ] } } ```使用示例
文本搜索
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
AI聊天
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”:[ “--目录”, “/PATH/TO/YOUR/INSTALLATION/ddg-mcp”, “运行”, “ddg-mcp”, “--运输”, “stdio” ] },
发展
建筑与出版
准备分发包裹:
- 同步依赖关系并更新锁文件:
uv sync
- 构建包分发:
uv build
这将在 dist/ 目录。
- 发布到PyPI:
uv publish
注意:您需要通过环境变量或命令标志设置PyPI凭据:
- 令牌:
--token或UV_PUBLISH_TOKEN - 或用户名/密码:
--username/UV_PUBLISH_USERNAME和--password/UV_PUBLISH_PASSWORD
使用GitHub操作自动发布
此存储库包含一个GitHub Actions工作流,用于自动发布到PyPI。工作流在以下情况下触发:
- 创建了一个新的GitHub版本
- 工作流通过GitHub Actions界面手动触发
要设置自动发布,请执行以下操作:
-
生成PyPI API令牌:
- 首选https://pypi.org/manage/account/token/
- 创建一个范围仅限于的新令牌
ddg-mcp项目 - 复制令牌值(您只会看到一次)
-
将令牌添加到您的GitHub存储库机密中:
- 转到GitHub上的存储库
- 导航到“设置”>“秘密和变量”>“操作”
- 点击“新建存储库密钥”
- 姓名:
PYPI_API_TOKEN - 值:粘贴您的PyPI令牌
- 点击“添加秘密”
-
要发布新版本,请执行以下操作:
- 更新中的版本号
pyproject.toml - 在GitHub上创建新版本或手动触发工作流
- 更新中的版本号
调试
由于MCP服务器在stdio上运行,调试可能具有挑战性。为了达到最佳调试效果 经验,我们强烈建议使用 MCP检查员.
您可以通过以下方式启动MCP检查器 npm 使用此命令:
npx @modelcontextprotocol/inspector uv --directory /path/to/your/ddg-mcp run ddg-mcp --transport stdio
启动后,检查器将显示一个URL,您可以在浏览器中访问该URL以开始调试。