Provides web search functionality via DuckDuckGo for Claude Code and MCP-compatible clients, featuring advanced content exploration, navigation across search results, and detailed webpage analysis.
A DuckDuckGo search plugin for Model Context Protocol (MCP), compatible with Claude Code. Provides web search functionality with advanced navigation and content exploration features.
This project implements a Model Context Protocol (MCP) server that provides web search functionality using DuckDuckGo. The plugin is designed to work seamlessly with Claude Code or any other client that supports MCP, offering not just basic search capabilities but also advanced navigation and result exploration features.
pyproject.toml
Note: This package is not yet published to PyPI. Please install from source below.
In the future, once published, you'll be able to install with:
pip install mcp-duckduckgo
Clone this repository:
git clone https://github.com/gianlucamazza/mcp-duckduckgo.git cd mcp-duckduckgo
Install the package in development mode:
pip install -e .
Or use the provided script:
./scripts/install_dev.sh
Or use Make:
make install
To start the MCP server:
mcp-duckduckgo
Or with custom parameters:
mcp-duckduckgo --host 127.0.0.1 --port 8000
Or use the provided script for development:
./scripts/run.sh
Or use Make:
make run
Install the package from source as described above.
Configure Claude Code to use the plugin:
claude mcp add duckduckgo-search -- mcp-duckduckgo
For global configuration (available in all projects):
claude mcp add duckduckgo-search --scope global -- mcp-duckduckgo
Start Claude Code:
claude
Now you can use the DuckDuckGo search functionality within Claude Code.
The plugin provides the following endpoints:
duckduckgo_web_search
Performs a web search using DuckDuckGo with the following parameters:
query
(required): The search query (max 400 characters, 50 words)count
(optional, default: 10): Number of results per page (1-20)page
(optional, default: 1): Page number for paginationsite
(optional): Limit results to a specific site (e.g., 'example.com')time_period
(optional): Filter results by time period ('day', 'week', 'month', 'year')Example usage in Claude Code:
Search for "artificial intelligence latest developments"
duckduckgo_get_details
Retrieves detailed information about a specific search result:
url
(required): URL of the result to get details forExample usage in Claude Code:
Get details for "https://example.com/article"
duckduckgo_related_searches
Suggests related search queries based on the original query:
query
(required): Original search query (max 400 characters)count
(optional, default: 5): Number of related searches to return (1-10)Example usage in Claude Code:
Find related searches for "renewable energy"
docs://search
Provides comprehensive documentation about the search functionality.
Example usage in Claude Code:
Show me the documentation for the DuckDuckGo search
search_assistant
Helps formulate effective search queries.
Example usage in Claude Code:
Help me formulate a search query about climate change solutions
search://{query}
Retrieves formatted search results for a specific query.
Example usage in Claude Code:
Get search results for "quantum computing breakthroughs"
The plugin provides several features to help navigate and explore search results:
To navigate through multiple pages of search results:
Search for "climate change solutions" with 5 results per page, page 2
To filter results by specific site:
Search for "machine learning tutorials" on "tensorflow.org"
To filter results by time period:
Search for "latest news" from the past week
To get more information about a specific search result:
Get details for "https://example.com/article-found-in-search"
To discover related search queries:
Find related searches for "electric vehicles"
These navigation features can be combined with Claude's natural language capabilities to create a powerful search and exploration experience. For example:
Search for "python machine learning libraries", then get details on the top result, and finally show me related search terms
This implementation uses DuckDuckGo's public web interface and parses the HTML response to extract results. This approach is used for demonstration purposes, as DuckDuckGo does not offer an official search API. In a production environment, it's recommended to use a search service with an official API.
The DuckDuckGo plugin includes advanced content extraction capabilities that go beyond simple search results:
The plugin includes basic web spidering functionality:
To use the enhanced content extraction features:
Get details for "https://example.com/article" with spider depth 1
To control spidering behavior:
Get details for "https://example.com/article" with spider depth 2, max links 3, same domain only
The project includes several utility scripts in the scripts
directory to help with development:
install_dev.sh
: Sets up the development environmentrun.sh
: Runs the MCP server with development settingstest.sh
: Runs tests with coverage reportinglint.sh
: Runs linting and code formattingpublish.sh
: Builds and publishes the package to PyPIFor convenience, a Makefile is also provided with the following targets:
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
The project includes a comprehensive test suite covering all major functionality. Tests are located in the tests/
directory.
Before running the tests, install the test dependencies:
pip install -e ".[test]"
You can run all tests with:
pytest
To run tests with coverage reporting:
pytest --cov=mcp_duckduckgo
To run a specific test file:
pytest tests/test_models.py
To run tests with verbose output:
pytest -v
Or use the provided script:
./scripts/test.sh
Or use Make:
make test
The test suite is organized as follows:
conftest.py
- Shared fixtures and configurations for teststest_models.py
- Tests for data modelstest_search.py
- Tests for search functionalitytest_tools.py
- Tests for MCP toolstest_resources.py
- Tests for MCP resourcestest_integration.py
- End-to-end integration teststest_server.py
- Server lifecycle testsFor more details about testing, see the tests/README.md file.
black mcp_duckduckgo isort mcp_duckduckgo mypy mcp_duckduckgo
Or use the provided script:
./scripts/lint.sh
Or use Make:
make lint
If you want to publish the package to PyPI:
pyproject.toml
pip install build twine
python -m build twine upload dist/*
Or use the provided script if available:
./scripts/publish.sh
Or use Make:
make publish
Contributions are welcome! Please feel free to submit a Pull Request.
Discover shared experiences
Shared threads will appear here, showcasing real-world applications and insights from the community. Check back soon for updates!