ddgs-mcp-server 0.3.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
File without changes
@@ -0,0 +1,20 @@
1
+
2
+ import asyncio
3
+ import sys
4
+ from mcp.server.stdio import stdio_server
5
+ from .server import server
6
+
7
+ async def run():
8
+ async with stdio_server() as (read_stream, write_stream):
9
+ await server.run(read_stream, write_stream, server.create_initialization_options())
10
+
11
+ def main():
12
+ try:
13
+ asyncio.run(run())
14
+ except KeyboardInterrupt:
15
+ pass
16
+ except Exception as e:
17
+ print(f"Error: {e}", file=sys.stderr)
18
+
19
+ if __name__ == "__main__":
20
+ main()
@@ -0,0 +1,96 @@
1
+
2
+ import json
3
+ import logging
4
+ from typing import Optional, Literal
5
+ from mcp.server import Server
6
+ import mcp.types as types
7
+ from duckduckgo_search import DDGS
8
+
9
+ # Logging Configuration
10
+ logging.basicConfig(level=logging.INFO)
11
+ logger = logging.getLogger("ddgs-mcp")
12
+
13
+ # MCP Server
14
+ server = Server("ddgs-mcp-server")
15
+
16
+ @server.list_tools()
17
+ async def list_tools() -> list[types.Tool]:
18
+ return [
19
+ types.Tool(
20
+ name="search_text",
21
+ description="Perform a metasearch using various backends (DuckDuckGo, Google, Bing, etc.). Use this to find APIs, libraries, developer tools, and general information.",
22
+ inputSchema={
23
+ "type": "object",
24
+ "properties": {
25
+ "query": {"type": "string", "description": "Search query"},
26
+ "backend": {
27
+ "type": "string",
28
+ "enum": ["auto", "html", "lite", "bing", "brave", "duckduckgo", "google", "grokipedia", "mojeek", "yandex", "yahoo", "wikipedia"],
29
+ "default": "auto",
30
+ "description": "Search engine backend to use."
31
+ },
32
+ "region": {"type": "string", "default": "us-en", "description": "e.g., us-en, uk-en"},
33
+ "safesearch": {"type": "string", "enum": ["on", "moderate", "off"], "default": "moderate"},
34
+ "timelimit": {"type": "string", "enum": ["d", "w", "m", "y"], "default": None},
35
+ "max_results": {"type": "integer", "default": 10}
36
+ },
37
+ "required": ["query"]
38
+ }
39
+ ),
40
+ types.Tool(
41
+ name="search_news",
42
+ description="Perform a news search to find the latest updates, releases, or security alerts.",
43
+ inputSchema={
44
+ "type": "object",
45
+ "properties": {
46
+ "query": {"type": "string"},
47
+ "region": {"type": "string", "default": "us-en"},
48
+ "safesearch": {"type": "string", "default": "moderate"},
49
+ "timelimit": {"type": "string", "default": None},
50
+ "max_results": {"type": "integer", "default": 10}
51
+ },
52
+ "required": ["query"]
53
+ }
54
+ )
55
+ ]
56
+
57
+ @server.call_tool()
58
+ async def call_tool(name: str, arguments: dict) -> list[types.TextContent | types.ImageContent | types.EmbeddedResource]:
59
+ logger.info(f"Calling tool: {name} with args: {arguments}")
60
+
61
+ if name not in ["search_text", "search_news"]:
62
+ raise ValueError(f"Unknown tool: {name}")
63
+
64
+ query = arguments.get("query")
65
+ backend = arguments.get("backend", "auto")
66
+ region = arguments.get("region", "us-en")
67
+ safesearch = arguments.get("safesearch", "moderate")
68
+ timelimit = arguments.get("timelimit")
69
+ max_results = arguments.get("max_results", 10)
70
+
71
+ try:
72
+ with DDGS() as ddgs:
73
+ results = []
74
+ if name == "search_text":
75
+ results = ddgs.text(
76
+ keywords=query,
77
+ region=region,
78
+ safesearch=safesearch,
79
+ timelimit=timelimit,
80
+ max_results=max_results,
81
+ backend=backend
82
+ )
83
+ elif name == "search_news":
84
+ results = ddgs.news(
85
+ keywords=query,
86
+ region=region,
87
+ safesearch=safesearch,
88
+ timelimit=timelimit,
89
+ max_results=max_results
90
+ )
91
+
92
+ return [types.TextContent(type="text", text=json.dumps(results, indent=2))]
93
+
94
+ except Exception as e:
95
+ logger.error(f"Error executing {name}: {e}")
96
+ return [types.TextContent(type="text", text=f"Error performing search: {str(e)}")]
@@ -0,0 +1,85 @@
1
+ Metadata-Version: 2.4
2
+ Name: ddgs-mcp-server
3
+ Version: 0.3.0
4
+ Summary: DuckDuckGo Search MCP Server
5
+ License-File: LICENSE
6
+ Requires-Python: >=3.10
7
+ Requires-Dist: duckduckgo-search>=6.0.0
8
+ Requires-Dist: mcp>=1.0.0
9
+ Description-Content-Type: text/markdown
10
+
11
+ # DDGS MCP Server
12
+
13
+ A Model Context Protocol (MCP) server that provides DuckDuckGo Search capabilities to AI agents.
14
+
15
+ ## Features
16
+
17
+ - **search_text**: advanced metasearch using `bing`, `brave`, `duckduckgo`, `google`, `mojeek`, `yahoo`, `yandex`, `wikipedia`.
18
+ - **search_news**: Find latest updates, releases, and tech news.
19
+
20
+
21
+ ## Installation & Usage
22
+
23
+ You can run this server directly using `uvx` without installing it globally.
24
+
25
+ ### VS Code (Claude Desktop / Cline)
26
+
27
+ Add this to your MCP settings file (e.g., `cline_mcp_settings.json` or `claude_desktop_config.json`):
28
+
29
+ ```json
30
+ {
31
+ "mcpServers": {
32
+ "ddgs-search": {
33
+ "command": "uvx",
34
+ "args": [
35
+ "ddgs-mcp-server"
36
+ ],
37
+ "disabled": false,
38
+ "alwaysAllow": []
39
+ }
40
+ }
41
+ }
42
+ ```
43
+
44
+ ### Manual Execution
45
+
46
+ ```bash
47
+ uvx ddgs-mcp-server
48
+ ```
49
+
50
+
51
+ ## Secrets & Configuration
52
+
53
+ This project technically **does not require API keys** to run locally, as it scrapes DuckDuckGo. However, for **publishing** or **proxy usage**, you should configure your environment.
54
+
55
+ ### 1. Set up Secrets
56
+ Copy the example file:
57
+ ```bash
58
+ cp .env.example .env
59
+ ```
60
+
61
+ ### 2. Required Tokens
62
+
63
+ | Token | Purpose | How to Get It |
64
+ | :--- | :--- | :--- |
65
+ | **PyPI API Token** | Publishing to PyPI | 1. Go to [PyPI Account Settings](https://pypi.org/manage/account/token/)<br>2. Select "Add API Token"<br>3. Scope to "Entire account" (for first publish)<br>4. Set as `TWINE_PASSWORD` in `.env` |
66
+ | **Proxy URL** | Bypassing Blocks (Optional) | Use any HTTP/SOCKS5 proxy provider if you encounter rate limits. |
67
+
68
+ ## Development / Publishing
69
+
70
+ To build and publish this package to PyPI (using the secrets from above):
71
+
72
+ 1. **Build**:
73
+ ```bash
74
+ pip install build twine
75
+ python -m build
76
+ ```
77
+
78
+ 2. **Publish** (loads secrets from .env if you export them, or prompts you):
79
+ ```bash
80
+ # If using .env variables (PowerShell)
81
+ # $env:TWINE_USERNAME = "__token__"
82
+ # $env:TWINE_PASSWORD = "pypi-..."
83
+
84
+ python -m twine upload dist/*
85
+ ```
@@ -0,0 +1,8 @@
1
+ ddgs_mcp_server/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ ddgs_mcp_server/main.py,sha256=hqJl7UoGQoL9a-2hX24srZYFGdatheJfgkn5wz5Od70,492
3
+ ddgs_mcp_server/server.py,sha256=8Uqw88N80Bgr-gyvaHkG8btOnJt_fm3dG2D4H8s1oiA,3938
4
+ ddgs_mcp_server-0.3.0.dist-info/METADATA,sha256=5-zLeJnqv_6UYNvWEfo3GLLWS-CUKyiN9IH3F0TkgA4,2239
5
+ ddgs_mcp_server-0.3.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
6
+ ddgs_mcp_server-0.3.0.dist-info/entry_points.txt,sha256=8YvtzhkNDMvAy2CdIx8VppBFjiBSJ56JtLX-v8SUHGc,62
7
+ ddgs_mcp_server-0.3.0.dist-info/licenses/LICENSE,sha256=vLPKcNOa4dGBRPq4I_mIBKyVSbIlzrOdinbwXFeKb88,1091
8
+ ddgs_mcp_server-0.3.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.28.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ ddgs-mcp-server = ddgs_mcp_server.main:main
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Chirag Singhal
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.