search1api-mcp 0.1.3 → 0.1.4

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/README.md CHANGED
@@ -11,7 +11,8 @@ https://github.com/user-attachments/assets/58bc98ae-3b6b-442c-a7fc-010508b5f028
11
11
  - News search functionality
12
12
  - Web page content extraction
13
13
  - Website sitemap extraction
14
- - Seamless integration with Claude Desktop
14
+ - Deep thinking and complex problem solving with DeepSeek R1
15
+ - Seamless integration with Claude Desktop, Cursor and Windsurf
15
16
 
16
17
  ## Tools
17
18
 
@@ -43,14 +44,20 @@ https://github.com/user-attachments/assets/58bc98ae-3b6b-442c-a7fc-010508b5f028
43
44
  - Parameters:
44
45
  * `url` (required): URL to get sitemap
45
46
 
47
+ ### 5. Reasoning Tool
48
+ - Name: `reasoning`
49
+ - Description: A tool for deep thinking and complex problem solving with fast deepseek r1 model and web search ability(You can change to any other model in search1api website but the speed is not guaranteed)
50
+ - Parameters:
51
+ * `content` (required): The question or problem that needs deep thinking
52
+
46
53
  ## Setup Guide
47
54
 
48
55
  ### 1. Get Search1API Key
49
- 1. Register at [Search1API](https://www.search1api.com/)
50
- 2. Choose a pricing plan (starts from $0.99)
51
- 3. After payment, copy your API key from the confirmation email
56
+ 1. Register at [Search1API](https://www.search1api.com/?utm_source=mcp)
57
+ 2. Get your api key and 100 free credits
52
58
 
53
- ### 2. Configure Claude Desktop
59
+ ### 2. Configure
60
+ #### 2.1 Claude Desktop
54
61
  Update your Claude configuration file (`claude_desktop_config.json`) with the following content:
55
62
 
56
63
  ```json
@@ -71,8 +78,36 @@ Configuration file location:
71
78
  - macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
72
79
  - Windows: `%APPDATA%\Claude\claude_desktop_config.json`
73
80
 
81
+ #### 2.2 Cursor
82
+ 1. Copy the run.template.sh to your file path and rename it to run.sh
83
+ 2. Add your own Search1API key to the run.sh file
84
+ 3. Open Cursor Settings to add new MCP server `search1api` with the command `sh ./your_file_path/run.sh`
85
+
86
+ Read the Cursor MCP Server [Official Documentation](https://docs.cursor.com/context/model-context-protocol#adding-an-mcp-server-to-cursor) to get more information.
87
+
88
+ #### 2.3 Windsurf
89
+ Update your Windsurf configuration file (`mcp_config.json`) with the following content:
90
+
91
+ ```json
92
+ {
93
+ "mcpServers": {
94
+ "search1api": {
95
+ "command": "npx",
96
+ "args": ["-y", "search1api-mcp"],
97
+ "env": {
98
+ "SEARCH1API_KEY": "YOUR_SEARCH1API_KEY"
99
+ }
100
+ }
101
+ }
102
+ }
103
+ ```
104
+ Read the Windsurf MCP Server [Official Documentation](https://docs.codeium.com/windsurf/mcp) to get more information.
105
+
106
+ **Notice: After the configuration is done, you can close Windsurf offcial web tools to save your credits**
107
+
74
108
  ## Version History
75
109
 
110
+ - v0.1.4: Added reasoning tool with deepseek r1 and updated the Cursor and Windsurf configuration guide
76
111
  - v0.1.3: Added news search functionality
77
112
  - v0.1.2: Added sitemap functionality
78
113
  - v0.1.1: Added web crawling functionality
package/build/index.js CHANGED
@@ -16,12 +16,13 @@ const API_CONFIG = {
16
16
  SEARCH: '/search',
17
17
  CRAWL: '/crawl',
18
18
  SITEMAP: '/sitemap',
19
- NEWS: '/news'
19
+ NEWS: '/news',
20
+ REASONING: '/v1/chat/completions'
20
21
  }
21
22
  };
22
23
  const SEARCH_TOOL = {
23
24
  name: "search",
24
- description: "A fast way to search the world",
25
+ description: "Search the web for real-time results",
25
26
  inputSchema: {
26
27
  type: "object",
27
28
  properties: {
@@ -95,6 +96,20 @@ const SITEMAP_TOOL = {
95
96
  required: ["url"]
96
97
  }
97
98
  };
99
+ const REASONING_TOOL = {
100
+ name: "reasoning",
101
+ description: "Deep thinking and complex problem solving",
102
+ inputSchema: {
103
+ type: "object",
104
+ properties: {
105
+ content: {
106
+ type: "string",
107
+ description: "The question or problem that needs deep thinking"
108
+ }
109
+ },
110
+ required: ["content"]
111
+ }
112
+ };
98
113
  // Server implementation
99
114
  const server = new Server({
100
115
  name: "search1api-mcp",
@@ -116,64 +131,52 @@ const server = new Server({
116
131
  },
117
132
  sitemap: {
118
133
  description: "Sitemap extraction functionality"
134
+ },
135
+ reasoning: {
136
+ description: "Deep thinking and complex problem solving"
119
137
  }
120
138
  },
121
139
  },
122
140
  });
123
- // 添加服务器事件监听
141
+ // Add server event listeners
124
142
  server.onerror = (error) => {
125
143
  log('MCP Server Error:', error);
126
144
  };
127
145
  server.onclose = () => {
128
146
  log('MCP Server Connection Closed');
129
147
  };
130
- // 添加异步请求函数
148
+ // Add asynchronous request function
131
149
  async function makeRequest(endpoint, data) {
132
150
  const startTime = Date.now();
133
- // 确保 BASE_URL 末尾没有斜杠,endpoint 开头有斜杠
151
+ // Ensure BASE_URL has no trailing slash and endpoint starts with slash
134
152
  const baseUrl = API_CONFIG.BASE_URL.replace(/\/+$/, '');
135
153
  const path = endpoint.startsWith('/') ? endpoint : `/${endpoint}`;
136
154
  const url = `${baseUrl}${path}`;
137
- log(`Starting request to ${url}`);
138
155
  try {
139
- const controller = new AbortController();
140
- const timeoutId = setTimeout(() => controller.abort(), 30000); // 30 seconds timeout
141
156
  const response = await fetch(url, {
142
157
  method: 'POST',
143
158
  headers: {
144
159
  'Authorization': `Bearer ${API_KEY}`,
145
160
  'Content-Type': 'application/json',
146
161
  },
147
- body: JSON.stringify(data),
148
- signal: controller.signal
162
+ body: JSON.stringify(data)
149
163
  });
150
- clearTimeout(timeoutId);
151
164
  if (!response.ok) {
152
165
  const errorData = await response.json().catch(() => ({}));
153
166
  throw new Error(`API error: ${response.status} ${errorData.message || response.statusText}`);
154
167
  }
155
168
  const result = await response.json();
156
- const endTime = Date.now();
157
- log(`Request completed in ${endTime - startTime}ms`);
169
+ const duration = Date.now() - startTime;
170
+ log(`API request to ${endpoint} completed in ${duration}ms`);
158
171
  return result;
159
172
  }
160
173
  catch (error) {
161
- const endTime = Date.now();
162
- log(`Request failed after ${endTime - startTime}ms:`, error);
163
- if (error instanceof Error) {
164
- if (error.name === 'AbortError') {
165
- throw new Error('Request timeout after 30 seconds');
166
- }
167
- // 添加更多网络错误的详细信息
168
- const networkError = error;
169
- if (networkError.code) {
170
- throw new Error(`Network error (${networkError.code}): ${networkError.message}`);
171
- }
172
- }
174
+ const duration = Date.now() - startTime;
175
+ log(`API request to ${endpoint} failed after ${duration}ms:`, error);
173
176
  throw error;
174
177
  }
175
178
  }
176
- // 添加错误处理工具函数
179
+ // Add error handling utility function
177
180
  function formatError(error) {
178
181
  if (error instanceof Error) {
179
182
  return error.message;
@@ -222,7 +225,7 @@ server.setRequestHandler(ReadResourceRequestSchema, async (request) => {
222
225
  });
223
226
  // Tool handlers
224
227
  server.setRequestHandler(ListToolsRequestSchema, async () => ({
225
- tools: [SEARCH_TOOL, CRAWL_TOOL, SITEMAP_TOOL, NEWS_TOOL],
228
+ tools: [SEARCH_TOOL, CRAWL_TOOL, SITEMAP_TOOL, NEWS_TOOL, REASONING_TOOL],
226
229
  }));
227
230
  server.setRequestHandler(CallToolRequestSchema, async (request) => {
228
231
  try {
@@ -316,6 +319,41 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
316
319
  }]
317
320
  };
318
321
  }
322
+ case "reasoning": {
323
+ if (!args) {
324
+ throw new Error("No arguments provided");
325
+ }
326
+ const { content } = args;
327
+ const response = await fetch(`${API_CONFIG.BASE_URL}${API_CONFIG.ENDPOINTS.REASONING}`, {
328
+ method: 'POST',
329
+ headers: {
330
+ 'Authorization': `Bearer ${API_KEY}`,
331
+ 'Content-Type': 'application/json',
332
+ },
333
+ body: JSON.stringify({
334
+ model: "deepseek-r1-70b-fast-online",
335
+ messages: [
336
+ {
337
+ role: "user",
338
+ content: content
339
+ }
340
+ ],
341
+ stream: false
342
+ })
343
+ });
344
+ if (!response.ok) {
345
+ const errorData = await response.json().catch(() => ({}));
346
+ throw new Error(`API error: ${response.status} ${errorData.message || response.statusText}`);
347
+ }
348
+ const result = await response.json();
349
+ return {
350
+ content: [{
351
+ type: "text",
352
+ mimeType: "application/json",
353
+ text: JSON.stringify(result.choices[0].message)
354
+ }]
355
+ };
356
+ }
319
357
  default:
320
358
  throw new McpError(ErrorCode.MethodNotFound, `Unknown tool: ${name}`);
321
359
  }
@@ -332,7 +370,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
332
370
  };
333
371
  }
334
372
  });
335
- // 添加日志工具函数
373
+ // Add logging utility function
336
374
  function log(message, ...args) {
337
375
  const timestamp = new Date().toISOString();
338
376
  console.error(`[${timestamp}] ${message}`, ...args);
@@ -340,7 +378,7 @@ function log(message, ...args) {
340
378
  async function runServer() {
341
379
  const transport = new StdioServerTransport();
342
380
  log("Starting Search1API MCP Server...");
343
- // 添加全局错误处理
381
+ // Add global error handling
344
382
  process.on('uncaughtException', (error) => {
345
383
  log('Uncaught Exception:', error);
346
384
  });
package/build/types.js CHANGED
@@ -50,3 +50,13 @@ export function isValidNewsArgs(args) {
50
50
  }
51
51
  return true;
52
52
  }
53
+ export function isValidReasoningArgs(args) {
54
+ if (typeof args !== 'object' || args === null) {
55
+ return false;
56
+ }
57
+ const { content } = args;
58
+ if (typeof content !== 'string' || content.trim().length === 0) {
59
+ return false;
60
+ }
61
+ return true;
62
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "search1api-mcp",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "A Model Context Protocol (MCP) server that provides search and crawl functionality using Search1API",
5
5
  "private": false,
6
6
  "type": "module",