-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest-pdf.mjs
More file actions
62 lines (52 loc) · 1.41 KB
/
test-pdf.mjs
File metadata and controls
62 lines (52 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env node
import { spawn } from 'child_process';
const serverPath = './dist/index.js';
console.log('Starting PDF parsing test...\n');
const server = spawn('node', [serverPath], {
stdio: ['pipe', 'pipe', 'pipe'],
});
let responseBuffer = '';
server.stdout.on('data', (data) => {
responseBuffer += data.toString();
try {
const messages = responseBuffer.split('\n').filter(line => line.trim());
for (const msg of messages) {
if (msg.trim()) {
const parsed = JSON.parse(msg);
console.log('Server response:', JSON.stringify(parsed, null, 2));
}
}
responseBuffer = '';
} catch (e) {
// Buffer incomplete JSON
}
});
server.stderr.on('data', (data) => {
console.error('Server stderr:', data.toString());
});
server.on('close', (code) => {
console.log(`Server exited with code ${code}`);
process.exit(code);
});
// Wait for server to start
setTimeout(() => {
console.log('\nTesting search_fetch with PDF result...');
const searchRequest = {
jsonrpc: '2.0',
id: 1,
method: 'tools/call',
params: {
name: 'search_fetch',
arguments: {
query: 'typescript pdf documentation',
region: 'en-US',
maxFetch: 3
}
}
};
server.stdin.write(JSON.stringify(searchRequest) + '\n');
setTimeout(() => {
console.log('\nTest completed. Terminating server...');
server.kill('SIGTERM');
}, 30000);
}, 1000);