-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcall_get_me.js
More file actions
52 lines (46 loc) · 1.41 KB
/
call_get_me.js
File metadata and controls
52 lines (46 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
import { spawn } from "child_process";
import * as dotenv from "dotenv";
dotenv.config();
const server = spawn("npx", ["-y", "github-mcp-plus"], {
env: { ...process.env, GITHUB_PERSONAL_ACCESS_TOKEN: process.env.GITHUB_PERSONAL_ACCESS_TOKEN },
stdio: ["pipe", "pipe", "pipe"]
});
server.stderr.on("data", (data) => {
// console.error(`[STDERR]: ${data.toString()}`);
});
let buffer = "";
server.stdout.on("data", (data) => {
buffer += data.toString();
const messages = buffer.split('\n');
buffer = messages.pop() || "";
for (const msg of messages) {
if (!msg.trim()) continue;
try {
const parsed = JSON.parse(msg);
if (parsed.id === 1) {
// initialized, now call get_me
server.stdin.write(JSON.stringify({
jsonrpc: "2.0",
id: 2,
method: "tools/call",
params: { name: "get_me", arguments: {} }
}) + "\n");
} else if (parsed.id === 2) {
console.log("PROFILE DATA FROM MCP:");
console.log(parsed.result.content[0].text);
server.kill();
process.exit(0);
}
} catch(e) {}
}
});
server.stdin.write(JSON.stringify({
jsonrpc: "2.0",
id: 1,
method: "initialize",
params: { protocolVersion: "2024-11-05", capabilities: {}, clientInfo: { name: "test-client", version: "1.0.0" } }
}) + "\n");
server.stdin.write(JSON.stringify({
jsonrpc: "2.0",
method: "notifications/initialized"
}) + "\n");