-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
43 lines (36 loc) · 939 Bytes
/
test.js
File metadata and controls
43 lines (36 loc) · 939 Bytes
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
import { spawn } from "child_process";
const server = spawn("node", ["./build/index.js"], {
env: { ...process.env, GITHUB_PERSONAL_ACCESS_TOKEN: "dummy_token" },
stdio: ["pipe", "pipe", "pipe"]
});
server.stderr.on("data", (data) => {
console.log(`[STDERR]: ${data.toString()}`);
});
server.stdout.on("data", (data) => {
console.log(`[STDOUT JSONRPC RECV]: ${data.toString()}`);
});
// JSON-RPC Init Request
const initReq = {
jsonrpc: "2.0",
id: 1,
method: "initialize",
params: {
protocolVersion: "2024-11-05",
capabilities: {},
clientInfo: { name: "test-client", version: "1.0.0" }
}
};
server.stdin.write(JSON.stringify(initReq) + "\n");
setTimeout(() => {
const toolsReq = {
jsonrpc: "2.0",
id: 2,
method: "tools/list",
params: {}
};
server.stdin.write(JSON.stringify(toolsReq) + "\n");
}, 1000);
setTimeout(() => {
server.kill();
console.log("Test finished.");
}, 2000);