@just-every/mcp-read-website-fast 0.1.8 → 0.1.9
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/parser/dom.js +9 -3
- package/dist/serve.js +20 -1
- package/package.json +1 -1
package/dist/parser/dom.js
CHANGED
|
@@ -8,7 +8,9 @@ export function htmlToDom(html, url) {
|
|
|
8
8
|
runScripts: undefined,
|
|
9
9
|
resources: undefined,
|
|
10
10
|
pretendToBeVisual: true,
|
|
11
|
-
virtualConsole: new VirtualConsole().sendTo(console, {
|
|
11
|
+
virtualConsole: new VirtualConsole().sendTo(console, {
|
|
12
|
+
omitJSDOMErrors: true,
|
|
13
|
+
}),
|
|
12
14
|
});
|
|
13
15
|
}
|
|
14
16
|
catch {
|
|
@@ -16,14 +18,18 @@ export function htmlToDom(html, url) {
|
|
|
16
18
|
return new JSDOM(html, {
|
|
17
19
|
url,
|
|
18
20
|
contentType: 'text/html',
|
|
19
|
-
virtualConsole: new VirtualConsole().sendTo(console, {
|
|
21
|
+
virtualConsole: new VirtualConsole().sendTo(console, {
|
|
22
|
+
omitJSDOMErrors: true,
|
|
23
|
+
}),
|
|
20
24
|
});
|
|
21
25
|
}
|
|
22
26
|
catch {
|
|
23
27
|
return new JSDOM(`<!DOCTYPE html><html><body>${html}</body></html>`, {
|
|
24
28
|
url,
|
|
25
29
|
contentType: 'text/html',
|
|
26
|
-
virtualConsole: new VirtualConsole().sendTo(console, {
|
|
30
|
+
virtualConsole: new VirtualConsole().sendTo(console, {
|
|
31
|
+
omitJSDOMErrors: true,
|
|
32
|
+
}),
|
|
27
33
|
});
|
|
28
34
|
}
|
|
29
35
|
}
|
package/dist/serve.js
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
3
3
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
4
4
|
import { CallToolRequestSchema, ListToolsRequestSchema, ListResourcesRequestSchema, ReadResourceRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
|
|
5
|
+
process.stdin.on('error', () => { });
|
|
6
|
+
process.stdout.on('error', () => { });
|
|
7
|
+
process.stderr.on('error', () => { });
|
|
5
8
|
let fetchMarkdownModule;
|
|
6
9
|
let fsPromises;
|
|
7
10
|
let pathModule;
|
|
@@ -14,6 +17,9 @@ const server = new Server({
|
|
|
14
17
|
resources: {},
|
|
15
18
|
},
|
|
16
19
|
});
|
|
20
|
+
server.onerror = error => {
|
|
21
|
+
console.error('[MCP Server Error]', error);
|
|
22
|
+
};
|
|
17
23
|
const READ_WEBSITE_TOOL = {
|
|
18
24
|
name: 'read_website_fast',
|
|
19
25
|
description: 'Quickly reads webpages and converts to markdown for fast, token efficient web scraping',
|
|
@@ -185,6 +191,9 @@ server.setRequestHandler(ReadResourceRequestSchema, async (request) => {
|
|
|
185
191
|
});
|
|
186
192
|
async function runServer() {
|
|
187
193
|
const transport = new StdioServerTransport();
|
|
194
|
+
transport.onerror = error => {
|
|
195
|
+
console.error('[Transport Error]', error);
|
|
196
|
+
};
|
|
188
197
|
process.on('SIGINT', async () => {
|
|
189
198
|
console.error('Received SIGINT, shutting down gracefully...');
|
|
190
199
|
await server.close();
|
|
@@ -197,11 +206,21 @@ async function runServer() {
|
|
|
197
206
|
});
|
|
198
207
|
process.on('uncaughtException', error => {
|
|
199
208
|
console.error('Uncaught exception:', error);
|
|
209
|
+
if (error && error.message && error.message.includes('EPIPE')) {
|
|
210
|
+
console.error('Pipe error detected, keeping server alive');
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
200
213
|
process.exit(1);
|
|
201
214
|
});
|
|
202
215
|
process.on('unhandledRejection', (reason, promise) => {
|
|
203
216
|
console.error('Unhandled rejection at:', promise, 'reason:', reason);
|
|
204
|
-
|
|
217
|
+
});
|
|
218
|
+
process.stdin.on('end', () => {
|
|
219
|
+
console.error('Stdin closed, shutting down...');
|
|
220
|
+
process.exit(0);
|
|
221
|
+
});
|
|
222
|
+
process.stdin.on('error', error => {
|
|
223
|
+
console.error('Stdin error:', error);
|
|
205
224
|
});
|
|
206
225
|
try {
|
|
207
226
|
await server.connect(transport);
|
package/package.json
CHANGED