@imenam/simple-scraper 1.0.12 → 1.0.13
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/dist/gui.js +7 -0
- package/dist/index.js +14 -1
- package/package.json +2 -2
package/dist/gui.js
CHANGED
|
@@ -194,6 +194,13 @@ async function startServer() {
|
|
|
194
194
|
// À partir d'ici la route nous appartient : cleanupProxy peut la libérer.
|
|
195
195
|
proxyClient = client;
|
|
196
196
|
const port = result.port;
|
|
197
|
+
// Signale au master que la GUI est enregistrée et joignable, pour que
|
|
198
|
+
// reconnect_gui se résolve immédiatement au lieu d'attendre le timeout.
|
|
199
|
+
ipc.send({
|
|
200
|
+
type: 'READY',
|
|
201
|
+
data: { url: result.url ?? `${process.env.PROXY_URL}${APP_PATH}` },
|
|
202
|
+
timestamp: new Date().toISOString(),
|
|
203
|
+
});
|
|
197
204
|
app.post('/api/stop', async (_req, res) => {
|
|
198
205
|
console.error('POST /api/stop called');
|
|
199
206
|
res.json({ success: true, message: 'Stopping...' });
|
package/dist/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import { z } from 'zod';
|
|
|
9
9
|
import { setupLogging } from './logger.js';
|
|
10
10
|
import { getBrowser, closeBrowser, getDefaultTimeout } from './browser.js';
|
|
11
11
|
import { loadAllCookies } from './cookies.js';
|
|
12
|
-
import { GuiLauncher } from '@imenam/mcp-gui-interface';
|
|
12
|
+
import { GuiLauncher, reconnectGuiToolDefinition } from '@imenam/mcp-gui-interface';
|
|
13
13
|
import { createSession, getSession, closeSession, closeAllSessions, listSessions, getSessionLogs, clearSessionLogs } from './sessions.js';
|
|
14
14
|
import { registerSessionRpc } from './session-rpc.js';
|
|
15
15
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
@@ -19,6 +19,7 @@ dotenv.config({ path: envPath, override: true });
|
|
|
19
19
|
setupLogging('MASTER');
|
|
20
20
|
const launcher = new GuiLauncher({
|
|
21
21
|
guiPath: path.join(__dirname, 'gui.js'),
|
|
22
|
+
reloadEnv: () => dotenv.config({ path: envPath, override: true }),
|
|
22
23
|
onMessage: (msg) => {
|
|
23
24
|
if (msg.type === 'STOP') {
|
|
24
25
|
process.exit(0);
|
|
@@ -197,6 +198,18 @@ server.tool('scrape_page', 'Navigate to a URL using a headless browser and retur
|
|
|
197
198
|
await page.close();
|
|
198
199
|
}
|
|
199
200
|
});
|
|
201
|
+
// ─── reconnect_gui ──────────────────────────────────────────────────────────────
|
|
202
|
+
server.tool('reconnect_gui', reconnectGuiToolDefinition().description, {
|
|
203
|
+
force: z
|
|
204
|
+
.boolean()
|
|
205
|
+
.optional()
|
|
206
|
+
.describe('Restart the GUI worker even if it is already running and registered (default: false)'),
|
|
207
|
+
}, async ({ force }) => {
|
|
208
|
+
const res = await launcher.handleReconnectTool({ force });
|
|
209
|
+
return res.isError
|
|
210
|
+
? { content: res.content, isError: true }
|
|
211
|
+
: { content: res.content };
|
|
212
|
+
});
|
|
200
213
|
// ─── execute_js ───────────────────────────────────────────────────────────────
|
|
201
214
|
server.tool('execute_js', 'Navigate to a URL and execute custom JavaScript in the page context. The script is executed as a JavaScript function body with new Function(script)(), so it must use an explicit return statement to send data back to the tool. A bare expression such as document.title returns undefined. Return serializable values only; objects and arrays are returned as formatted JSON, primitives as text. For async work, return a Promise, for example: return (async () => { /* ... */ return data; })();', {
|
|
202
215
|
url: z.string().url().describe('URL of the page'),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@imenam/simple-scraper",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.13",
|
|
4
4
|
"description": "MCP server for web scraping and JavaScript execution using Puppeteer",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"node": ">=18.0.0"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@imenam/mcp-gui-interface": "^1.0.
|
|
38
|
+
"@imenam/mcp-gui-interface": "^1.0.10",
|
|
39
39
|
"@modelcontextprotocol/sdk": "^1.28.0",
|
|
40
40
|
"body-parser": "^2.2.2",
|
|
41
41
|
"dotenv": "^17.3.1",
|