@oevortex/ddg_search 1.1.8 → 1.2.0

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/CHANGELOG.md CHANGED
@@ -1,7 +1,29 @@
1
- # Changelog
2
-
3
- All notable changes to this project will be documented in this file.
4
- ## [1.1.8] - 2025-12-03
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+ ## [1.2.0] - 2025-12-21
5
+ ### Added
6
+ - Comprehensive Jest testing framework with ES module support
7
+ - Complete unit test suite for all utility functions (search, user_agents, search_iask, search_monica)
8
+ - Integration tests for MCP server functionality and tool routing
9
+ - Test infrastructure with mocking for all external dependencies
10
+ - Input validation across all search modules and tools
11
+ - Enhanced error handling with specific network error types
12
+ - Performance optimizations with timeout management and caching
13
+ - Improved logging and monitoring capabilities
14
+ - Fixed JSON parsing error in searchTool handler (1.1.9 regression)
15
+ - Updated package.json with comprehensive test scripts
16
+ - Added Babel configuration for test compatibility
17
+
18
+ ### Improved
19
+ - Search module robustness with AbortController and timeout management
20
+ - IAsk AI WebSocket connection handling with enhanced error reporting
21
+ - Monica AI stream processing with improved validation
22
+ - Tool schema validation with comprehensive parameter checking
23
+ - User agent rotation consistency and logging
24
+ - Cache management with hit detection and size controls
25
+
26
+ ## [1.1.9] - 2025-12-21
5
27
  ### Added
6
28
  - Added new `getRandomUserAgent` function to rotate user agents
7
29
  - Added new `src/utils/user_agents.js` file containing list of user agents
@@ -0,0 +1,12 @@
1
+ module.exports = {
2
+ presets: [
3
+ [
4
+ '@babel/preset-env',
5
+ {
6
+ targets: {
7
+ node: 'current'
8
+ }
9
+ }
10
+ ]
11
+ ]
12
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oevortex/ddg_search",
3
- "version": "1.1.8",
3
+ "version": "1.2.0",
4
4
  "description": "A Model Context Protocol server for web search using DuckDuckGo and IAsk AI",
5
5
  "main": "src/index.js",
6
6
  "module": "src/index.ts",
@@ -15,7 +15,13 @@
15
15
  "oevortex-ddg-search": "bin/cli.js"
16
16
  },
17
17
  "scripts": {
18
- "test": "echo \"Error: no test specified\" && exit 1",
18
+ "test": "jest",
19
+ "test:watch": "jest --watch",
20
+ "test:coverage": "jest --coverage",
21
+ "test:unit": "jest --testPathPattern=src/__tests__/utils",
22
+ "test:integration": "jest --testPathPattern=src/__tests__/mcp-integration",
23
+ "test:tools": "jest --testPathPattern=src/__tests__/tools",
24
+ "test:all": "jest --coverage --verbose",
19
25
  "start": "node bin/cli.js",
20
26
  "prepublishOnly": "npm run lint",
21
27
  "lint": "echo \"No linting configured\"",
@@ -51,8 +57,13 @@
51
57
  "ws": "^8.18.3"
52
58
  },
53
59
  "devDependencies": {
60
+ "@babel/core": "^7.28.5",
61
+ "@babel/preset-env": "^7.28.5",
62
+ "@jest/globals": "^29.7.0",
54
63
  "@types/node": "^24.3.0",
64
+ "babel-jest": "^29.7.0",
65
+ "jest": "^29.7.0",
55
66
  "tsx": "^4.20.4",
56
67
  "typescript": "^5.9.2"
57
68
  }
58
- }
69
+ }
@@ -37,19 +37,43 @@ export const searchToolDefinition = {
37
37
  * @param {Object} params - The tool parameters
38
38
  * @returns {Promise<Object>} - The tool result
39
39
  */
40
- export async function searchToolHandler(params) {
41
- const { query, numResults = 3, mode = 'short' } = params;
42
- console.log(`Searching for: ${query} (${numResults} results, mode: ${mode})`);
43
-
44
- const results = await searchDuckDuckGo(query, numResults, mode);
45
- console.log(`Found ${results.length} results`);
46
-
47
- return {
48
- content: [
49
- {
50
- type: 'text',
51
- text: JSON.stringify(results)
52
- }
53
- ]
54
- };
55
- }
40
+ export async function searchToolHandler(params) {
41
+ const { query, numResults = 3, mode = 'short' } = params;
42
+ console.log(`Searching for: ${query} (${numResults} results, mode: ${mode})`);
43
+
44
+ const results = await searchDuckDuckGo(query, numResults, mode);
45
+ console.log(`Found ${results.length} results`);
46
+
47
+ // Format results as readable text, similar to other search tools
48
+ const formattedResults = results.map((result, index) => {
49
+ let formatted = `${index + 1}. **${result.title}**\n`;
50
+ formatted += `URL: ${result.url}\n`;
51
+
52
+ if (result.displayUrl) {
53
+ formatted += `Display URL: ${result.displayUrl}\n`;
54
+ }
55
+
56
+ if (result.snippet) {
57
+ formatted += `Snippet: ${result.snippet}\n`;
58
+ }
59
+
60
+ if (mode === 'detailed' && result.description) {
61
+ formatted += `Content: ${result.description}\n`;
62
+ }
63
+
64
+ if (result.favicon) {
65
+ formatted += `Favicon: ${result.favicon}\n`;
66
+ }
67
+
68
+ return formatted;
69
+ }).join('\n');
70
+
71
+ return {
72
+ content: [
73
+ {
74
+ type: 'text',
75
+ text: formattedResults || 'No results found.'
76
+ }
77
+ ]
78
+ };
79
+ }