MCP DuckDuckGo Search Plugin
MCP DuckDuckGo 搜索插件
DuckDuckGo 的模型上下文协议 (MCP) 搜索插件,兼容 Claude Code。提供网页搜索功能,并具备高级导航和内容探索功能。
描述
该项目实现了一个模型上下文协议 (MCP) 服务器,该服务器使用 DuckDuckGo 提供网页搜索功能。该插件旨在与 Claude Code 或任何其他支持 MCP 的客户端无缝协作,不仅提供基本的搜索功能,还提供高级导航和结果探索功能。
Related MCP server: MCP DuckDuckGo
特征
网络搜索工具:使用 DuckDuckGo 执行网络搜索
详细结果:获取有关特定搜索结果的详细信息
相关搜索:根据原始搜索发现相关的搜索查询
分页支持:浏览多页搜索结果
域名提取:查看每个搜索结果的域名信息
高级过滤:按站点和时间段过滤结果
增强内容提取:从网页中提取丰富的内容,包括元数据、结构和片段
基本网络蜘蛛:跟踪搜索结果中的链接以探索相关内容(可配置深度)
元数据提取:提取标题、作者、关键词、出版日期等
社交媒体检测:从网页中识别并提取社交媒体链接
内容结构分析:提取标题和章节以了解网页结构
搜索文档:访问有关搜索功能的综合文档
搜索助手:获取帮助制定有效的搜索查询
参数化资源:检索特定查询的格式化搜索结果
要求
Python 3.9 或更高版本
pip(Python 包管理器)
pyproject.toml中列出的 Python 包
安装
来自 PyPI
注意:此软件包尚未发布到 PyPI。请从下方源代码安装。
将来,一旦发布,您将能够使用以下方式安装:
pip install mcp-duckduckgo来自源
克隆此存储库:
git clone https://github.com/gianlucamazza/mcp-duckduckgo.git cd mcp-duckduckgo以开发模式安装包:
pip install -e .或者使用提供的脚本:
./scripts/install_dev.sh或者使用 Make:
make install
用法
手动启动服务器
要启动 MCP 服务器:
mcp-duckduckgo或者使用自定义参数:
mcp-duckduckgo --host 127.0.0.1 --port 8000或者使用提供的脚本进行开发:
./scripts/run.sh或者使用 Make:
make run与 Claude 代码一起使用
按照上述说明从源安装包。
配置 Claude Code 以使用插件:
claude mcp add duckduckgo-search -- mcp-duckduckgo对于全局配置(所有项目可用):
claude mcp add duckduckgo-search --scope global -- mcp-duckduckgo启动克劳德代码:
claude现在您可以在 Claude Code 中使用 DuckDuckGo 搜索功能。
可用端点
该插件提供以下端点:
工具: duckduckgo_web_search
使用 DuckDuckGo 执行网络搜索,参数如下:
query(必填):搜索查询(最多 400 个字符,50 个字)count(可选,默认值:10):每页结果数(1-20)page(可选,默认值:1):分页的页码site(可选):将结果限制在特定网站(例如“example.com”)time_period(可选):按时间段过滤结果(‘天’、‘周’、‘月’、‘年’)
Claude Code 中的示例用法:
Search for "artificial intelligence latest developments"工具: duckduckgo_get_details
检索有关特定搜索结果的详细信息:
url(必填):获取结果详细信息的 URL
Claude Code 中的示例用法:
Get details for "https://example.com/article"工具: duckduckgo_related_searches
根据原始查询建议相关的搜索查询:
query(必填):原始搜索查询(最多 400 个字符)count(可选,默认值:5):返回的相关搜索数量(1-10)
Claude Code 中的示例用法:
Find related searches for "renewable energy"资源: docs://search
提供有关搜索功能的全面文档。
Claude Code 中的示例用法:
Show me the documentation for the DuckDuckGo search提示: search_assistant
帮助制定有效的搜索查询。
Claude Code 中的示例用法:
Help me formulate a search query about climate change solutions资源: search://{query}
检索特定查询的格式化搜索结果。
Claude Code 中的示例用法:
Get search results for "quantum computing breakthroughs"使用导航功能
该插件提供了多种功能来帮助导航和探索搜索结果:
分页
要浏览多页搜索结果:
Search for "climate change solutions" with 5 results per page, page 2筛选结果
要按特定站点过滤结果:
Search for "machine learning tutorials" on "tensorflow.org"按时间段过滤结果:
Search for "latest news" from the past week探索结果详情
要获取有关特定搜索结果的更多信息:
Get details for "https://example.com/article-found-in-search"查找相关搜索
要发现相关的搜索查询:
Find related searches for "electric vehicles"这些导航功能可以与 Claude 的自然语言能力相结合,打造强大的搜索和探索体验。例如:
Search for "python machine learning libraries", then get details on the top result, and finally show me related search terms实施说明
此实现使用 DuckDuckGo 的公共 Web 界面,并解析 HTML 响应以提取结果。此方法仅用于演示,因为 DuckDuckGo 不提供官方搜索 API。在生产环境中,建议使用带有官方 API 的搜索服务。
增强内容提取
DuckDuckGo 插件包含超越简单搜索结果的高级内容提取功能:
内容提取功能
完整网页分析:从搜索结果 URL 中提取并解析 HTML 内容
智能内容定位:从不同类型的网站中识别并提取主要内容区域
丰富的元数据提取:提取标题、描述、作者、关键词和出版日期
图像检测:识别并提取网页中的主要图像和媒体
社交媒体整合:检测并提取社交媒体资料的链接
内容结构分析:提取标题和章节以了解网页组织
官方来源检测:根据域名和内容信号识别来源是否为官方
网络爬取功能
该插件包括基本的网络蜘蛛功能:
可配置深度:跟随距离原始 URL 0 到 3 级深度的链接
链接限制:控制每页可关注的最大链接数(1-5)
域限制:仅跟踪同一域内的链接的选项
相关内容发现:查找并分析与原始搜索相关的内容
使用增强内容提取
要使用增强的内容提取功能:
Get details for "https://example.com/article" with spider depth 1要控制蜘蛛行为:
Get details for "https://example.com/article" with spider depth 2, max links 3, same domain only发展
该项目在scripts目录中包含几个实用程序脚本以帮助开发:
install_dev.sh:设置开发环境run.sh:使用开发设置运行 MCP 服务器test.sh:运行测试并报告覆盖率lint.sh:运行 linting 和代码格式化publish.sh:构建包并将其发布到 PyPI
为了方便起见,还提供了具有以下目标的 Makefile:
make install # Install the package in development mode
make test # Run tests with coverage
make lint # Run linting and code formatting
make run # Run the MCP server
make publish # Build and publish the package to PyPI
make clean # Clean build artifacts
make all # Run install, lint, and test (default)
make help # Show help message测试
该项目包含一个涵盖所有主要功能的全面测试套件。测试位于tests/目录中。
安装测试依赖项
在运行测试之前,安装测试依赖项:
pip install -e ".[test]"运行测试
您可以使用以下方式运行所有测试:
pytest要运行带有覆盖率报告的测试:
pytest --cov=mcp_duckduckgo要运行特定的测试文件:
pytest tests/test_models.py要运行具有详细输出的测试:
pytest -v或者使用提供的脚本:
./scripts/test.sh或者使用 Make:
make test测试结构
测试套件的组织如下:
conftest.py- 用于测试的共享装置和配置test_models.py- 数据模型测试test_search.py- 测试搜索功能test_tools.py- MCP 工具测试test_resources.py- MCP 资源测试test_integration.py- 端到端集成测试test_server.py- 服务器生命周期测试
有关测试的更多详细信息,请参阅tests/README.md文件。
代码格式化和 Linting
black mcp_duckduckgo
isort mcp_duckduckgo
mypy mcp_duckduckgo或者使用提供的脚本:
./scripts/lint.sh或者使用 Make:
make lint发布到 PyPI
如果您想将包发布到 PyPI:
更新
pyproject.toml中的版本确保您拥有必要的凭证和工具:
pip install build twine构建并发布:
python -m build twine upload dist/*
或者使用提供的脚本(如果可用):
./scripts/publish.sh或者使用 Make:
make publish贡献
欢迎贡献代码!欢迎提交 Pull 请求。
执照
存储库
Available Tools
3 toolsget_page_contentC
Fetch and extract content from a web page.
Returns the page title, description, and main content.
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | URL to fetch content from |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries full burden for behavioral disclosure. It mentions what the tool returns ('page title, description, and main content'), which is helpful, but lacks critical details like error handling, rate limits, authentication needs, or performance characteristics. For a web-fetching tool, this leaves significant gaps in understanding its behavior.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is appropriately concise with two sentences that directly address purpose and return values. It's front-loaded with the core functionality. However, the second sentence could be more integrated with the first for better flow, and there's some whitespace formatting that slightly affects structure.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool has an output schema (which handles return value documentation) and 100% schema coverage for the single parameter, the description provides adequate context for basic understanding. However, for a web content extraction tool with no annotations, it should ideally mention common constraints like URL validation, content type limitations, or network timeout behavior to be more complete.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The input schema has 100% description coverage, with the 'url' parameter clearly documented. The description adds no additional parameter semantics beyond what's in the schema. According to scoring rules, when schema_description_coverage is high (>80%), the baseline is 3 even with no param info in the description.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool's purpose with specific verbs ('fetch and extract content from a web page') and identifies the resource ('web page'). It distinguishes from sibling tools like 'suggest_related_searches' and 'web_search' by focusing on content extraction rather than search or suggestions. However, it doesn't explicitly differentiate itself from potential similar tools not in the sibling list.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides no guidance on when to use this tool versus alternatives like 'web_search' or 'suggest_related_searches'. There's no mention of prerequisites, constraints, or typical use cases. The agent must infer usage from the purpose alone, which is insufficient for optimal tool selection.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
web_searchB
Search the web using DuckDuckGo.
Returns a list of search results with titles, URLs, descriptions, and domains.
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Search query | |
| max_results | No | Maximum number of results to return (1-20) |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions the search engine (DuckDuckGo) and return format, but lacks critical details like rate limits, authentication needs, privacy implications, or error handling. For a tool with no annotation coverage, this leaves significant gaps in understanding its operational behavior.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is extremely concise and front-loaded: two sentences that directly state the tool's function and output. Every sentence earns its place with no wasted words, making it easy to parse quickly.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool's moderate complexity (web search with two parameters), no annotations, and an output schema (implied by context signals), the description is minimally adequate. It covers the basic purpose and output format, but lacks usage guidelines and behavioral details that would be helpful for an AI agent, especially without annotations.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, so the schema fully documents both parameters (query and max_results). The description adds no additional parameter semantics beyond what's in the schema, such as query formatting tips or result ordering. This meets the baseline for high schema coverage but doesn't enhance understanding.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool's purpose: 'Search the web using DuckDuckGo' specifies the action (search) and resource (web via DuckDuckGo). It distinguishes from sibling tools like 'get_page_content' (which fetches specific page content) and 'suggest_related_searches' (which suggests queries), but could be more explicit about this differentiation.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides no guidance on when to use this tool versus alternatives. It doesn't mention when to choose web_search over get_page_content (e.g., for broad queries vs. specific URLs) or suggest_related_searches (e.g., for refining searches). There's no context about use cases or exclusions.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
3 tool updates
v1.0.0- Added
get_page_content - Added
suggest_related_searches - Added
web_search
TDQS
Scored across 3 tools
Each tool has a clearly distinct purpose: get_page_content extracts content from a specific URL, web_search performs general web searches, and suggest_related_searches provides autocomplete suggestions. There is no overlap in functionality, making tool selection straightforward for an agent.
All tool names follow a consistent verb_noun pattern (get_page_content, suggest_related_searches, web_search) using snake_case. The naming is predictable and readable, with no deviations in style or convention.
With 3 tools, the server is well-scoped for a DuckDuckGo search plugin. Each tool serves a distinct and essential function in the search workflow, from performing searches to extracting content and getting suggestions, with no unnecessary redundancy.
The tool surface covers core search operations effectively, including searching, content extraction, and related suggestions. A minor gap exists in advanced search features like filtering by date or region, but agents can work around this with the provided tools for most use cases.
Maintenance
Related MCP Connectors
Web MCP: scrape/crawl sites, web search, brand assets, app stores, YouTube, Reddit, Hacker News.
Scrape, crawl and search the web for AI agents via MCP.
Web search, scraping, RAG answers with citations, and translation as MCP tools.
Search the agentic web. 4,100+ sites, 11 tools incl. check_url + verify_mcp for probe-before-use.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceEnables AI assistants to perform real-time web searches, fetch webpage content, and get search suggestions using DuckDuckGo's privacy-focused search engine.-
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to search the internet using DuckDuckGo and extract clean, formatted content from web pages.144 npmGPL 3.0
- FlicenseNot gradedqualityDmaintenanceProvides fast, self-hosted web search and reliable web scraping using SearXNG and Crawl4AI, integrated as MCP tools for Claude Code.47-
- AlicenseAqualityDmaintenanceProvides DuckDuckGo web search and site fetching tools for Claude Desktop, enabling up to 10 search results and text content extraction from URLs.2MIT