ddgs-mcp-server 0.1.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,126 @@
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 text search using DuckDuckGo. Use this for general web queries.",
22
+ inputSchema={
23
+ "type": "object",
24
+ "properties": {
25
+ "query": {"type": "string", "description": "Search query"},
26
+ "region": {"type": "string", "default": "us-en", "description": "e.g., us-en, uk-en"},
27
+ "safesearch": {"type": "string", "enum": ["on", "moderate", "off"], "default": "moderate"},
28
+ "timelimit": {"type": "string", "enum": ["d", "w", "m", "y"], "default": None},
29
+ "max_results": {"type": "integer", "default": 10}
30
+ },
31
+ "required": ["query"]
32
+ }
33
+ ),
34
+ types.Tool(
35
+ name="search_images",
36
+ description="Perform an image search using DuckDuckGo.",
37
+ inputSchema={
38
+ "type": "object",
39
+ "properties": {
40
+ "query": {"type": "string"},
41
+ "region": {"type": "string", "default": "us-en"},
42
+ "safesearch": {"type": "string", "default": "moderate"},
43
+ "timelimit": {"type": "string", "default": None},
44
+ "max_results": {"type": "integer", "default": 10}
45
+ },
46
+ "required": ["query"]
47
+ }
48
+ ),
49
+ types.Tool(
50
+ name="search_videos",
51
+ description="Perform a video search using DuckDuckGo.",
52
+ inputSchema={
53
+ "type": "object",
54
+ "properties": {
55
+ "query": {"type": "string"},
56
+ "region": {"type": "string", "default": "us-en"},
57
+ "safesearch": {"type": "string", "default": "moderate"},
58
+ "timelimit": {"type": "string", "default": None},
59
+ "max_results": {"type": "integer", "default": 10}
60
+ },
61
+ "required": ["query"]
62
+ }
63
+ ),
64
+ types.Tool(
65
+ name="search_news",
66
+ description="Perform a news search using DuckDuckGo.",
67
+ inputSchema={
68
+ "type": "object",
69
+ "properties": {
70
+ "query": {"type": "string"},
71
+ "region": {"type": "string", "default": "us-en"},
72
+ "safesearch": {"type": "string", "default": "moderate"},
73
+ "timelimit": {"type": "string", "default": None},
74
+ "max_results": {"type": "integer", "default": 10}
75
+ },
76
+ "required": ["query"]
77
+ }
78
+ ),
79
+ types.Tool(
80
+ name="search_books",
81
+ description="Perform a book search using DuckDuckGo (Anna's Archive backend).",
82
+ inputSchema={
83
+ "type": "object",
84
+ "properties": {
85
+ "query": {"type": "string"},
86
+ "max_results": {"type": "integer", "default": 10}
87
+ },
88
+ "required": ["query"]
89
+ }
90
+ )
91
+ ]
92
+
93
+ @server.call_tool()
94
+ async def call_tool(name: str, arguments: dict) -> list[types.TextContent | types.ImageContent | types.EmbeddedResource]:
95
+ logger.info(f"Calling tool: {name} with args: {arguments}")
96
+
97
+ query = arguments.get("query")
98
+ region = arguments.get("region", "us-en")
99
+ safesearch = arguments.get("safesearch", "moderate")
100
+ timelimit = arguments.get("timelimit")
101
+ max_results = arguments.get("max_results", 10)
102
+
103
+ try:
104
+ with DDGS() as ddgs:
105
+ results = []
106
+ if name == "search_text":
107
+ results = ddgs.text(keywords=query, region=region, safesearch=safesearch, timelimit=timelimit, max_results=max_results)
108
+ elif name == "search_images":
109
+ results = ddgs.images(keywords=query, region=region, safesearch=safesearch, timelimit=timelimit, max_results=max_results)
110
+ elif name == "search_videos":
111
+ results = ddgs.videos(keywords=query, region=region, safesearch=safesearch, timelimit=timelimit, max_results=max_results)
112
+ elif name == "search_news":
113
+ results = ddgs.news(keywords=query, region=region, safesearch=safesearch, timelimit=timelimit, max_results=max_results)
114
+ elif name == "search_books":
115
+ if hasattr(ddgs, 'books'):
116
+ results = ddgs.books(keywords=query, max_results=max_results)
117
+ else:
118
+ return [types.TextContent(type="text", text="Error: 'books' search backend not available in this version of python-ddgs.")]
119
+ else:
120
+ raise ValueError(f"Unknown tool: {name}")
121
+
122
+ return [types.TextContent(type="text", text=json.dumps(results, indent=2))]
123
+
124
+ except Exception as e:
125
+ logger.error(f"Error executing {name}: {e}")
126
+ return [types.TextContent(type="text", text=f"Error performing search: {str(e)}")]
@@ -0,0 +1,65 @@
1
+ Metadata-Version: 2.4
2
+ Name: ddgs-mcp-server
3
+ Version: 0.1.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
+ - **Text Search**: General web search (`search_text`)
18
+ - **Image Search**: Find images (`search_images`)
19
+ - **Video Search**: Find videos (`search_videos`)
20
+ - **News Search**: Get latest news (`search_news`)
21
+ - **Book Search**: Search for books (`search_books`)
22
+
23
+ ## Installation & Usage
24
+
25
+ You can run this server directly using `uvx` without installing it globally.
26
+
27
+ ### VS Code (Claude Desktop / Cline)
28
+
29
+ Add this to your MCP settings file (e.g., `cline_mcp_settings.json` or `claude_desktop_config.json`):
30
+
31
+ ```json
32
+ {
33
+ "mcpServers": {
34
+ "ddgs-search": {
35
+ "command": "uvx",
36
+ "args": [
37
+ "ddgs-mcp-server"
38
+ ],
39
+ "disabled": false,
40
+ "alwaysAllow": []
41
+ }
42
+ }
43
+ }
44
+ ```
45
+
46
+ ### Manual Execution
47
+
48
+ ```bash
49
+ uvx ddgs-mcp-server
50
+ ```
51
+
52
+ ## Development / Publishing
53
+
54
+ To build and publish this package to PyPI:
55
+
56
+ 1. **Build**:
57
+ ```bash
58
+ pip install build twine
59
+ python -m build
60
+ ```
61
+
62
+ 2. **Publish**:
63
+ ```bash
64
+ python -m twine upload dist/*
65
+ ```
@@ -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=Zv7v9H7nA1ZY8l8Ltw6OojdkYxj35COZxruY02av3f8,5531
4
+ ddgs_mcp_server-0.1.0.dist-info/METADATA,sha256=ILZeHuWCe4qJm6zW9McrdbiKHjKyF-wplHUlH0XvueU,1356
5
+ ddgs_mcp_server-0.1.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
6
+ ddgs_mcp_server-0.1.0.dist-info/entry_points.txt,sha256=8YvtzhkNDMvAy2CdIx8VppBFjiBSJ56JtLX-v8SUHGc,62
7
+ ddgs_mcp_server-0.1.0.dist-info/licenses/LICENSE,sha256=vLPKcNOa4dGBRPq4I_mIBKyVSbIlzrOdinbwXFeKb88,1091
8
+ ddgs_mcp_server-0.1.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.