duckduckgo-websearch 0.1.1

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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 HeiSir
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.
package/README.md ADDED
@@ -0,0 +1,233 @@
1
+ # DuckDuckGo Search MCP Server (Node.js/TypeScript)
2
+
3
+ A Model Context Protocol (MCP) server that provides web search capabilities through DuckDuckGo, with additional features for content fetching and parsing. This is the Node.js/TypeScript version of the original Python implementation.
4
+
5
+ ## Features
6
+
7
+ - **Web Search**: Search DuckDuckGo with advanced rate limiting and result formatting
8
+ - **Content Fetching**: Retrieve and parse webpage content with intelligent text extraction
9
+ - **Rate Limiting**: Built-in protection against rate limits for both search and content fetching
10
+ - **Error Handling**: Comprehensive error handling and logging
11
+ - **LLM-Friendly Output**: Results formatted specifically for large language model consumption
12
+ - **TypeScript**: Full TypeScript support with type definitions
13
+ - **Global CLI**: Available as a global npm package
14
+
15
+ ## Installation
16
+
17
+ ### Global Installation (Recommended)
18
+
19
+ ```bash
20
+ # Install globally via npm
21
+ npm install -g duckduckgo-websearch
22
+
23
+ # Or using pnpm
24
+ pnpm add -g duckduckgo-websearch
25
+
26
+ # Or using yarn
27
+ yarn global add duckduckgo-websearch
28
+ ```
29
+
30
+ After global installation, you can use the following commands:
31
+ - `duckduckgo-mcp-server`
32
+ - `ddg-mcp-server` (short alias)
33
+
34
+ ### Local Installation
35
+
36
+ ```bash
37
+ # Clone and install locally
38
+ git clone https://github.com/HeiSir2014/duckduckgo-mcp-server
39
+ cd duckduckgo-mcp-server
40
+ npm install
41
+ npm run build
42
+ ```
43
+
44
+ ## Usage
45
+
46
+ ### Global Usage
47
+
48
+ After global installation, you can run the server directly:
49
+
50
+ ```bash
51
+ # Start the server
52
+ duckduckgo-websearch
53
+
54
+ # Or using the short alias
55
+ ddg-websearch
56
+ ```
57
+
58
+ ### Running with Claude Desktop
59
+
60
+ 1. Download [Claude Desktop](https://claude.ai/download)
61
+ 2. Create or edit your Claude Desktop configuration:
62
+ - On macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
63
+ - On Windows: `%APPDATA%\Claude\claude_desktop_config.json`
64
+
65
+ #### For Global Installation:
66
+ ```json
67
+ {
68
+ "mcpServers": {
69
+ "ddg-search": {
70
+ "command": "npx duckduckgo-websearch"
71
+ }
72
+ }
73
+ }
74
+ ```
75
+
76
+ #### For Local Installation:
77
+ ```json
78
+ {
79
+ "mcpServers": {
80
+ "ddg-search": {
81
+ "command": "node",
82
+ "args": ["path/to/duckduckgo-mcp-server/build/index.js"]
83
+ }
84
+ }
85
+ }
86
+ ```
87
+
88
+ 3. Restart Claude Desktop
89
+
90
+ ### Development
91
+
92
+ For local development:
93
+
94
+ ```bash
95
+ # Install dependencies
96
+ npm install
97
+
98
+ # Build the project
99
+ npm run build
100
+
101
+ # Run in development mode
102
+ npm run dev
103
+
104
+ # Start the built server
105
+ npm start
106
+
107
+ # Run tests
108
+ npm test
109
+ ```
110
+
111
+ ## Available Tools
112
+
113
+ ### 1. Search Tool
114
+
115
+ ```typescript
116
+ async function search(query: string, max_results?: number): Promise<string>
117
+ ```
118
+
119
+ Performs a web search on DuckDuckGo and returns formatted results.
120
+
121
+ **Parameters:**
122
+ - `query`: Search query string
123
+ - `max_results`: Maximum number of results to return (default: 10)
124
+
125
+ **Returns:**
126
+ Formatted string containing search results with titles, URLs, and snippets.
127
+
128
+ ### 2. Content Fetching Tool
129
+
130
+ ```typescript
131
+ async function fetch_content(url: string, max_length?: number): Promise<string>
132
+ ```
133
+
134
+ Fetches and parses content from a webpage.
135
+
136
+ **Parameters:**
137
+ - `url`: The webpage URL to fetch content from
138
+ - `max_length`: Maximum content length to return (default: 8000)
139
+
140
+ **Returns:**
141
+ Cleaned and formatted text content from the webpage.
142
+
143
+ ## Features in Detail
144
+
145
+ ### Rate Limiting
146
+
147
+ - Search: Limited to 30 requests per minute
148
+ - Content Fetching: Limited to 20 requests per minute
149
+ - Automatic queue management and wait times
150
+
151
+ ### Result Processing
152
+
153
+ - Removes ads and irrelevant content
154
+ - Cleans up DuckDuckGo redirect URLs
155
+ - Formats results for optimal LLM consumption
156
+ - Truncates long content appropriately
157
+
158
+ ### Error Handling
159
+
160
+ - Comprehensive error catching and reporting
161
+ - Graceful degradation on rate limits or timeouts
162
+
163
+ ## Technical Details
164
+
165
+ ### Dependencies
166
+
167
+ - `@modelcontextprotocol/sdk`: MCP SDK for Node.js
168
+ - `cheerio`: Server-side jQuery implementation for HTML parsing
169
+ - Node.js 内置 `fetch` API:用于 HTTP 请求(无需额外依赖)
170
+
171
+ ### Architecture
172
+
173
+ The server is built using the MCP SDK and consists of several key components:
174
+
175
+ - **DuckDuckGoSearcher**: Handles search requests with rate limiting
176
+ - **WebContentFetcher**: Fetches and parses webpage content
177
+ - **RateLimiter**: Manages request rate limiting
178
+ - **Main Server**: Integrates everything and handles MCP protocol
179
+
180
+ ## Publishing (For Maintainers)
181
+
182
+ ### Version Management
183
+
184
+ ```bash
185
+ # Update version
186
+ npm run version:patch # 0.1.1 -> 0.1.2
187
+ npm run version:minor # 0.1.1 -> 0.2.0
188
+ npm run version:major # 0.1.1 -> 1.0.0
189
+ ```
190
+
191
+ ### Publishing to npm
192
+
193
+ ```bash
194
+ # Check publish readiness
195
+ npm run publish:check
196
+
197
+ # Publish (after version update)
198
+ npm publish
199
+ ```
200
+
201
+ ### Pre-publish Checklist
202
+
203
+ - [ ] All tests pass (`npm test`)
204
+ - [ ] Build succeeds (`npm run build`)
205
+ - [ ] Version updated (`npm version [patch|minor|major]`)
206
+ - [ ] README updated
207
+ - [ ] CHANGELOG updated
208
+
209
+ ## Contributing
210
+
211
+ Issues and pull requests are welcome! Some areas for potential improvement:
212
+
213
+ - Additional search parameters (region, language, etc.)
214
+ - Enhanced content parsing options
215
+ - Caching layer for frequently accessed content
216
+ - Additional rate limiting strategies
217
+ - Better error recovery mechanisms
218
+
219
+ ## License
220
+
221
+ This project is licensed under the MIT License.
222
+
223
+ ## Comparison with Python Version
224
+
225
+ This Node.js/TypeScript version provides the same functionality as the original Python version with the following benefits:
226
+
227
+ - **Type Safety**: Full TypeScript support with compile-time type checking
228
+ - **Performance**: Generally faster startup and execution times
229
+ - **Ecosystem**: Access to the extensive npm ecosystem
230
+ - **Compatibility**: Better integration with Node.js-based toolchains
231
+ - **Global CLI**: Easy global installation and usage
232
+
233
+ The API and behavior are designed to be identical to the Python version, making it a drop-in replacement.
@@ -0,0 +1,10 @@
1
+ import { SearchResult, SearchOptions } from './types';
2
+ export declare class DuckDuckGoSearcher {
3
+ private static readonly BASE_URL;
4
+ private static readonly HEADERS;
5
+ private rateLimiter;
6
+ constructor();
7
+ formatResultsForLLM(results: SearchResult[]): string;
8
+ search(query: string, options?: SearchOptions): Promise<SearchResult[]>;
9
+ }
10
+ //# sourceMappingURL=duckduckgoSearcher.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"duckduckgoSearcher.d.ts","sourceRoot":"","sources":["../src/duckduckgoSearcher.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAGtD,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAsC;IACtE,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAE7B;IAEF,OAAO,CAAC,WAAW,CAAc;;IAMjC,mBAAmB,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,MAAM;IAkB9C,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE,aAAkB,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;CAoFlF"}
@@ -0,0 +1,130 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.DuckDuckGoSearcher = void 0;
37
+ const cheerio = __importStar(require("cheerio"));
38
+ const rateLimiter_1 = require("./rateLimiter");
39
+ class DuckDuckGoSearcher {
40
+ constructor() {
41
+ this.rateLimiter = new rateLimiter_1.RateLimiter({ requestsPerMinute: 30 });
42
+ }
43
+ formatResultsForLLM(results) {
44
+ if (!results || results.length === 0) {
45
+ return "No results were found for your search query. This could be due to DuckDuckGo's bot detection or the query returned no matches. Please try rephrasing your search or try again in a few minutes.";
46
+ }
47
+ const output = [];
48
+ output.push(`Found ${results.length} search results:\n`);
49
+ for (const result of results) {
50
+ output.push(`${result.position}. ${result.title}`);
51
+ output.push(` URL: ${result.link}`);
52
+ output.push(` Summary: ${result.snippet}`);
53
+ output.push(''); // Empty line between results
54
+ }
55
+ return output.join('\n');
56
+ }
57
+ async search(query, options = {}) {
58
+ const { maxResults = 10 } = options;
59
+ try {
60
+ // Apply rate limiting
61
+ await this.rateLimiter.acquire();
62
+ const controller = new AbortController();
63
+ const timeoutId = setTimeout(() => controller.abort(), 30000);
64
+ const formData = new URLSearchParams({
65
+ q: query,
66
+ b: '',
67
+ kl: ''
68
+ });
69
+ const response = await fetch(DuckDuckGoSearcher.BASE_URL, {
70
+ method: 'POST',
71
+ headers: {
72
+ ...DuckDuckGoSearcher.HEADERS,
73
+ 'Content-Type': 'application/x-www-form-urlencoded'
74
+ },
75
+ body: formData,
76
+ signal: controller.signal
77
+ });
78
+ clearTimeout(timeoutId);
79
+ if (!response.ok) {
80
+ throw new Error(`HTTP ${response.status}: ${response.statusText}`);
81
+ }
82
+ const html = await response.text();
83
+ const $ = cheerio.load(html);
84
+ const results = [];
85
+ $('.result').each((index, element) => {
86
+ if (results.length >= maxResults) {
87
+ return false; // Break the loop
88
+ }
89
+ const $element = $(element);
90
+ const titleElement = $element.find('.result__title');
91
+ if (!titleElement.length) {
92
+ return; // Continue to next iteration
93
+ }
94
+ const linkElement = titleElement.find('a');
95
+ if (!linkElement.length) {
96
+ return; // Continue to next iteration
97
+ }
98
+ const title = linkElement.text().trim();
99
+ let link = linkElement.attr('href') || '';
100
+ // Skip ad results
101
+ if (link.includes('y.js')) {
102
+ return; // Continue to next iteration
103
+ }
104
+ // Clean up DuckDuckGo redirect URLs
105
+ if (link.startsWith('//duckduckgo.com/l/?uddg=')) {
106
+ const decoded = decodeURIComponent(link.split('uddg=')[1]?.split('&')[0] || '');
107
+ link = decoded;
108
+ }
109
+ const snippetElement = $element.find('.result__snippet');
110
+ const snippet = snippetElement.text().trim() || '';
111
+ results.push({
112
+ title,
113
+ link,
114
+ snippet,
115
+ position: results.length + 1
116
+ });
117
+ });
118
+ return results;
119
+ }
120
+ catch {
121
+ return [];
122
+ }
123
+ }
124
+ }
125
+ exports.DuckDuckGoSearcher = DuckDuckGoSearcher;
126
+ DuckDuckGoSearcher.BASE_URL = 'https://html.duckduckgo.com/html';
127
+ DuckDuckGoSearcher.HEADERS = {
128
+ 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36'
129
+ };
130
+ //# sourceMappingURL=duckduckgoSearcher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"duckduckgoSearcher.js","sourceRoot":"","sources":["../src/duckduckgoSearcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAmC;AAEnC,+CAA4C;AAE5C,MAAa,kBAAkB;IAQ7B;QACE,IAAI,CAAC,WAAW,GAAG,IAAI,yBAAW,CAAC,EAAE,iBAAiB,EAAE,EAAE,EAAE,CAAC,CAAC;IAChE,CAAC;IAED,mBAAmB,CAAC,OAAuB;QACzC,IAAI,C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I,EAAE,CAAC;gBAE1C,kBAAkB;gBAClB,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;oBAC1B,OAAO,CAAC,6BAA6B;gBACvC,CAAC;gBAED,oCAAoC;gBACpC,IAAI,IAAI,CAAC,UAAU,CAAC,2BAA2B,CAAC,EAAE,CAAC;oBACjD,MAAM,OAAO,GAAG,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;oBAChF,IAAI,GAAG,OAAO,CAAC;gBACjB,CAAC;gBAED,MAAM,cAAc,GAAG,QAAQ,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;gBACzD,MAAM,OAAO,GAAG,cAAc,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC;gBAEnD,OAAO,CAAC,IAAI,CAAC;oBACX,KAAK;oBACL,IAAI;oBACJ,OAAO;oBACP,QAAQ,EAAE,OAAO,CAAC,MAAM,GAAG,CAAC;iBAC7B,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;YAEH,OAAO,OAAO,CAAC;QAEjB,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,EAAE,CAAC;QACZ,CAAC;IACH,CAAC;;AAjHH,gDAkHC;AAjHyB,2BAAQ,GAAG,kCAAkC,CAAC;AAC9C,0BAAO,GAAG;IAChC,YAAY,EAAE,qHAAqH;CACpI,CAAC"}
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
package/build/index.js ADDED
@@ -0,0 +1,129 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ const index_js_1 = require("@modelcontextprotocol/sdk/server/index.js");
5
+ const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
6
+ const types_js_1 = require("@modelcontextprotocol/sdk/types.js");
7
+ const duckduckgoSearcher_1 = require("./duckduckgoSearcher");
8
+ const webContentFetcher_1 = require("./webContentFetcher");
9
+ class DuckDuckGoMCPServer {
10
+ constructor() {
11
+ this.server = new index_js_1.Server({
12
+ name: 'duckduckgo-mcp-server',
13
+ version: '0.1.1',
14
+ }, {
15
+ capabilities: {
16
+ tools: {},
17
+ },
18
+ });
19
+ this.searcher = new duckduckgoSearcher_1.DuckDuckGoSearcher();
20
+ this.fetcher = new webContentFetcher_1.WebContentFetcher();
21
+ this.setupToolHandlers();
22
+ }
23
+ setupToolHandlers() {
24
+ this.server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => {
25
+ return {
26
+ tools: [
27
+ {
28
+ name: 'search',
29
+ description: 'Search DuckDuckGo and return formatted results',
30
+ inputSchema: {
31
+ type: 'object',
32
+ properties: {
33
+ query: {
34
+ type: 'string',
35
+ description: 'The search query string',
36
+ },
37
+ max_results: {
38
+ type: 'integer',
39
+ description: 'Maximum number of results to return (default: 25)',
40
+ default: 25,
41
+ },
42
+ },
43
+ required: ['query'],
44
+ },
45
+ },
46
+ {
47
+ name: 'fetch_content',
48
+ description: 'Fetch and parse content from a webpage URL',
49
+ inputSchema: {
50
+ type: 'object',
51
+ properties: {
52
+ url: {
53
+ type: 'string',
54
+ description: 'The webpage URL to fetch content from',
55
+ },
56
+ max_content_length: {
57
+ type: 'integer',
58
+ description: 'Maximum number of characters to return (default: 8000)',
59
+ default: 8000,
60
+ },
61
+ },
62
+ required: ['url'],
63
+ },
64
+ },
65
+ ],
66
+ };
67
+ });
68
+ this.server.setRequestHandler(types_js_1.CallToolRequestSchema, async (request) => {
69
+ const { name, arguments: args } = request.params;
70
+ try {
71
+ if (name === 'search') {
72
+ const { query, max_results = 10 } = args;
73
+ const results = await this.searcher.search(query, {
74
+ maxResults: max_results,
75
+ });
76
+ const formattedResults = this.searcher.formatResultsForLLM(results);
77
+ return {
78
+ content: [
79
+ {
80
+ type: 'text',
81
+ text: formattedResults,
82
+ },
83
+ ],
84
+ };
85
+ }
86
+ else if (name === 'fetch_content') {
87
+ const { url, max_content_length = 8000 } = args;
88
+ const content = await this.fetcher.fetchAndParse(url, max_content_length);
89
+ return {
90
+ content: [
91
+ {
92
+ type: 'text',
93
+ text: content,
94
+ },
95
+ ],
96
+ };
97
+ }
98
+ throw new Error(`Unknown tool: ${name}`);
99
+ }
100
+ catch (error) {
101
+ const message = error instanceof Error ? error.message : String(error);
102
+ return {
103
+ content: [
104
+ {
105
+ type: 'text',
106
+ text: `An error occurred while executing ${name}: ${message}`,
107
+ },
108
+ ],
109
+ isError: true,
110
+ };
111
+ }
112
+ });
113
+ }
114
+ async run() {
115
+ const transport = new stdio_js_1.StdioServerTransport();
116
+ await this.server.connect(transport);
117
+ }
118
+ }
119
+ async function main() {
120
+ const server = new DuckDuckGoMCPServer();
121
+ await server.run();
122
+ }
123
+ if (require.main === module) {
124
+ main().catch((error) => {
125
+ console.error('Fatal error:', error);
126
+ process.exit(1);
127
+ });
128
+ }
129
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAEA,wEAAmE;AACnE,wEAAiF;AACjF,iEAI4C;AAC5C,6DAA0D;AAC1D,2DAAwD;AAExD,MAAM,mBAAmB;IAKvB;QACE,IAAI,CAAC,MAAM,GAAG,IAAI,iBAAM,CACtB;YACE,IAAI,EAAE,uBAAuB;YAC7B,OAAO,EAAE,OAAO;SACjB,EACD;YACE,YAAY,EAAE;gBACZ,KAAK,EAAE,EAAE;aACV;SACF,CACF,CAAC;QAEF,IAAI,CAAC,QAAQ,GAAG,IAAI,uCAAkB,EAAE,CAAC;QACzC,IAAI,CAAC,OAAO,GAAG,IAAI,qCAAiB,EAAE,CAAC;QA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CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IACvC,CAAC;CACF;AAED,KAAK,UAAU,IAAI;IACjB,MAAM,MAAM,GAAG,IAAI,mBAAmB,EAAE,CAAC;IACzC,MAAM,MAAM,CAAC,GAAG,EAAE,CAAC;AACrB,CAAC;AAED,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;IAC5B,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;QACrB,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;QACrC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { RateLimiterOptions } from './types';
2
+ export declare class RateLimiter {
3
+ private requestsPerMinute;
4
+ private requests;
5
+ constructor(options?: RateLimiterOptions);
6
+ acquire(): Promise<void>;
7
+ }
8
+ //# sourceMappingURL=rateLimiter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rateLimiter.d.ts","sourceRoot":"","sources":["../src/rateLimiter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAE7C,qBAAa,WAAW;IACtB,OAAO,CAAC,iBAAiB,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAc;gBAElB,OAAO,GAAE,kBAAuB;IAItC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAkB/B"}
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RateLimiter = void 0;
4
+ class RateLimiter {
5
+ constructor(options = {}) {
6
+ this.requests = [];
7
+ this.requestsPerMinute = options.requestsPerMinute || 30;
8
+ }
9
+ async acquire() {
10
+ const now = new Date();
11
+ // Remove requests older than 1 minute
12
+ this.requests = this.requests.filter(req => now.getTime() - req.getTime() < 60000);
13
+ if (this.requests.length >= this.requestsPerMinute) {
14
+ // Wait until we can make another request
15
+ const waitTime = 60000 - (now.getTime() - this.requests[0].getTime());
16
+ if (waitTime > 0) {
17
+ await new Promise(resolve => setTimeout(resolve, waitTime));
18
+ }
19
+ }
20
+ this.requests.push(now);
21
+ }
22
+ }
23
+ exports.RateLimiter = RateLimiter;
24
+ //# sourceMappingURL=rateLimiter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rateLimiter.js","sourceRoot":"","sources":["../src/rateLimiter.ts"],"names":[],"mappings":";;;AAEA,MAAa,WAAW;IAItB,YAAY,UAA8B,EAAE;QAFpC,aAAQ,GAAW,EAAE,CAAC;QAG5B,IAAI,CAAC,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,IAAI,EAAE,CAAC;IAC3D,CAAC;IAED,KAAK,CAAC,OAAO;QACX,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;QAEvB,sCAAsC;QACtC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAClC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,GAAG,CAAC,OAAO,EAAE,GAAG,KAAK,CAC7C,CAAC;QAEF,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,IAAI,IAAI,CAAC,iBAAiB,EAAE,CAAC;YACnD,yCAAyC;YACzC,MAAM,QAAQ,GAAG,KAAK,GAAG,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;YACtE,IAAI,QAAQ,GAAG,CAAC,EAAE,CAAC;gBACjB,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC;YAC9D,CAAC;QACH,CAAC;QAED,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC1B,CAAC;CACF;AA1BD,kCA0BC"}
@@ -0,0 +1,13 @@
1
+ export interface SearchResult {
2
+ title: string;
3
+ link: string;
4
+ snippet: string;
5
+ position: number;
6
+ }
7
+ export interface RateLimiterOptions {
8
+ requestsPerMinute?: number;
9
+ }
10
+ export interface SearchOptions {
11
+ maxResults?: number;
12
+ }
13
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,kBAAkB;IACjC,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,aAAa;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB"}
package/build/types.js ADDED
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ export declare class WebContentFetcher {
2
+ private rateLimiter;
3
+ constructor();
4
+ fetchAndParse(url: string, max_content_length?: number): Promise<string>;
5
+ }
6
+ //# sourceMappingURL=webContentFetcher.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webContentFetcher.d.ts","sourceRoot":"","sources":["../src/webContentFetcher.ts"],"names":[],"mappings":"AAGA,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,WAAW,CAAc;;IAM3B,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,kBAAkB,GAAE,MAAa,GAAG,OAAO,CAAC,MAAM,CAAC;CA8DrF"}
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.WebContentFetcher = void 0;
37
+ const cheerio = __importStar(require("cheerio"));
38
+ const rateLimiter_1 = require("./rateLimiter");
39
+ class WebContentFetcher {
40
+ constructor() {
41
+ this.rateLimiter = new rateLimiter_1.RateLimiter({ requestsPerMinute: 20 });
42
+ }
43
+ async fetchAndParse(url, max_content_length = 8000) {
44
+ try {
45
+ await this.rateLimiter.acquire();
46
+ const controller = new AbortController();
47
+ const timeoutId = setTimeout(() => controller.abort(), 30000);
48
+ const response = await fetch(url, {
49
+ headers: {
50
+ 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'
51
+ },
52
+ redirect: 'follow',
53
+ signal: controller.signal
54
+ });
55
+ clearTimeout(timeoutId);
56
+ if (!response.ok) {
57
+ throw new Error(`HTTP ${response.status}: ${response.statusText}`);
58
+ }
59
+ const html = await response.text();
60
+ const $ = cheerio.load(html);
61
+ // Remove script and style elements
62
+ $('script, style, nav, header, footer').remove();
63
+ // Get the text content
64
+ const text = $.text();
65
+ // Clean up the text
66
+ const lines = text.split('\n').map((line) => line.trim());
67
+ const chunks = lines.flatMap((line) => line.split(/\s{2,}/).map((phrase) => phrase.trim()));
68
+ let cleanText = chunks.filter((chunk) => chunk).join(' ');
69
+ // Remove extra whitespace
70
+ cleanText = cleanText.replace(/\s+/g, ' ').trim();
71
+ // Truncate if too long
72
+ if (cleanText.length > max_content_length) {
73
+ cleanText = cleanText.substring(0, max_content_length) + '... [content truncated]';
74
+ }
75
+ return cleanText;
76
+ }
77
+ catch (error) {
78
+ if (error instanceof Error) {
79
+ if (error.name === 'AbortError') {
80
+ return 'Error: The request timed out while trying to fetch the webpage.';
81
+ }
82
+ else if (error.message.includes('HTTP')) {
83
+ return `Error: Could not access the webpage (${error.message})`;
84
+ }
85
+ else {
86
+ return `Error: An unexpected error occurred while fetching the webpage (${error.message})`;
87
+ }
88
+ }
89
+ else {
90
+ const errorMessage = String(error);
91
+ return `Error: An unexpected error occurred while fetching the webpage (${errorMessage})`;
92
+ }
93
+ }
94
+ }
95
+ }
96
+ exports.WebContentFetcher = WebContentFetcher;
97
+ //# sourceMappingURL=webContentFetcher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webContentFetcher.js","sourceRoot":"","sources":["../src/webContentFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAmC;AACnC,+CAA4C;AAE5C,MAAa,iBAAiB;IAG5B;QACE,IAAI,CAAC,WAAW,GAAG,IAAI,yBAAW,CAAC,EAAE,iBAAiB,EAAE,EAAE,EAAE,CAAC,CAAC;IA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AAG,CAAC,CAAC,MAAc,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAC5D,CAAC;YACF,IAAI,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,KAAa,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YAElE,0BAA0B;YAC1B,SAAS,GAAG,SAAS,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;YAElD,uBAAuB;YACvB,IAAI,SAAS,CAAC,MAAM,GAAG,kBAAkB,EAAE,CAAC;gBAC1C,SAAS,GAAG,SAAS,CAAC,SAAS,CAAC,CAAC,EAAE,kBAAkB,CAAC,GAAG,yBAAyB,CAAC;YACrF,CAAC;YAED,OAAO,SAAS,CAAC;QAEnB,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACxB,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;gBAC3B,IAAI,KAAK,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;oBAChC,OAAO,iEAAiE,CAAC;gBAC3E,CAAC;qBAAM,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;oBAC1C,OAAO,wCAAwC,KAAK,CAAC,OAAO,GAAG,CAAC;gBAClE,CAAC;qBAAM,CAAC;oBACN,OAAO,mEAAmE,KAAK,CAAC,OAAO,GAAG,CAAC;gBAC7F,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,MAAM,YAAY,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;gBACnC,OAAO,mEAAmE,YAAY,GAAG,CAAC;YAC5F,CAAC;QACH,CAAC;IACH,CAAC;CACF;AArED,8CAqEC"}
package/package.json ADDED
@@ -0,0 +1,66 @@
1
+ {
2
+ "name": "duckduckgo-websearch",
3
+ "version": "0.1.1",
4
+ "description": "MCP Server for searching via DuckDuckGo (Node.js version)",
5
+ "main": "build/index.js",
6
+ "bin": {
7
+ "duckduckgo-websearch": "build/index.js",
8
+ "ddg-websearch": "build/index.js"
9
+ },
10
+ "scripts": {
11
+ "build": "tsc",
12
+ "dev": "tsx src/index.ts",
13
+ "start": "node build/index.js",
14
+ "clean": "rimraf build",
15
+ "prepare": "npm run build",
16
+ "prepublishOnly": "npm run clean && npm run build",
17
+ "postbuild": "chmod +x build/index.js || echo 'chmod skipped on Windows'",
18
+ "publish:check": "node scripts/publish.js",
19
+ "version:patch": "npm version patch",
20
+ "version:minor": "npm version minor",
21
+ "version:major": "npm version major"
22
+ },
23
+ "keywords": [
24
+ "mcp",
25
+ "model-context-protocol",
26
+ "duckduckgo",
27
+ "search",
28
+ "ai",
29
+ "llm"
30
+ ],
31
+ "author": {
32
+ "name": "HeiSir2014",
33
+ "email": "heisir21@163.com"
34
+ },
35
+ "license": "MIT",
36
+ "dependencies": {
37
+ "@modelcontextprotocol/sdk": "^1.17.0",
38
+ "cheerio": "^1.1.2"
39
+ },
40
+ "devDependencies": {
41
+ "@types/node": "^20",
42
+ "tsx": "^4.20.3",
43
+ "typescript": "^5.8.3",
44
+ "rimraf": "^6.0.1"
45
+ },
46
+ "engines": {
47
+ "node": ">=18.0.0",
48
+ "npm": ">=8.0.0"
49
+ },
50
+ "files": [
51
+ "build/",
52
+ "README.md",
53
+ "LICENSE"
54
+ ],
55
+ "publishConfig": {
56
+ "access": "public"
57
+ },
58
+ "repository": {
59
+ "type": "git",
60
+ "url": "git+https://github.com/HeiSir2014/duckduckgo-mcp-server.git"
61
+ },
62
+ "bugs": {
63
+ "url": "https://github.com/HeiSir2014/duckduckgo-mcp-server/issues"
64
+ },
65
+ "homepage": "https://github.com/HeiSir2014/duckduckgo-mcp-server"
66
+ }