Skip to main content

MCP Server for searching via DuckDuckGo

Project description

DuckDuckGo Search MCP Server

A Model Context Protocol (MCP) server that provides web search capabilities through DuckDuckGo, with additional features for content fetching and parsing.

Features

  • Web Search: Search DuckDuckGo with advanced rate limiting and result formatting
  • Content Fetching: Retrieve and parse webpage content with intelligent text extraction
  • Rate Limiting: Built-in protection against rate limits for both search and content fetching
  • Error Handling: Comprehensive error handling and logging
  • LLM-Friendly Output: Results formatted specifically for large language model consumption

Installation

This server requires Python 3.10 or higher. Install dependencies using uv (recommended) or pip:

# Using uv (recommended)
uv add "mcp[cli]" httpx beautifulsoup4

# Using pip
pip install "mcp[cli]" httpx beautifulsoup4

Usage

Running with Claude Desktop

  1. Download Claude Desktop
  2. Create or edit claude_desktop_config.json:
{
    "mcpServers": {
        "ddg-search": {
            "command": "python",
            "args": ["path/to/ddg_search_server.py"]
        }
    }
}
  1. Restart Claude Desktop

Direct Usage

Run the server directly:

python ddg_search_server.py

Or use the MCP CLI for development:

mcp dev ddg_search_server.py

Available Tools

1. Search Tool

async def search(query: str, max_results: int = 10) -> str

Performs a web search on DuckDuckGo and returns formatted results.

Parameters:

  • query: Search query string
  • max_results: Maximum number of results to return (default: 10)

Returns: Formatted string containing search results with titles, URLs, and snippets.

2. Content Fetching Tool

async def fetch_content(url: str) -> str

Fetches and parses content from a webpage.

Parameters:

  • url: The webpage URL to fetch content from

Returns: Cleaned and formatted text content from the webpage.

Features in Detail

Rate Limiting

  • Search: Limited to 30 requests per minute
  • Content Fetching: Limited to 20 requests per minute
  • Automatic queue management and wait times

Result Processing

  • Removes ads and irrelevant content
  • Cleans up DuckDuckGo redirect URLs
  • Formats results for optimal LLM consumption
  • Truncates long content appropriately

Error Handling

  • Comprehensive error catching and reporting
  • Detailed logging through MCP context
  • Graceful degradation on rate limits or timeouts

Contributing

Issues and pull requests are welcome! Some areas for potential improvement:

  • Additional search parameters (region, language, etc.)
  • Enhanced content parsing options
  • Caching layer for frequently accessed content
  • Additional rate limiting strategies

License

This project is licensed under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

duckduckgo_mcp_server-0.1.1.tar.gz (19.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

duckduckgo_mcp_server-0.1.1-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file duckduckgo_mcp_server-0.1.1.tar.gz.

File metadata

File hashes

Hashes for duckduckgo_mcp_server-0.1.1.tar.gz
Algorithm Hash digest
SHA256 d6f48f4cb4234de9e716e87f7d49aa54637ebc4a3700ecfd05f260696463c0ec
MD5 413c46a44145929b54e409aa3d7b4b05
BLAKE2b-256 8682ad813d88199de0a88aa50536e569f6191da572a6d5bf2e7fcccb7e28b522

See more details on using hashes here.

File details

Details for the file duckduckgo_mcp_server-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for duckduckgo_mcp_server-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ca56c67bcfcef259ce083d1700700f5b66f75a48b4c1e13f556289cf3351b50b
MD5 7cbfd1c8b3f1f50e500838c8f5daa463
BLAKE2b-256 c642e7d7fc70744d3ebf7b309a19176bb745c5e7d5babf77fcf903068cb08bbd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page