mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-18 08:31:49 -06:00
f28b4b4e93
* fix(queue): narrow admission ticket session keys * fix(ci): resolve queue and MCP check regressions * fix(ci): keep steer finalizer module-private * style(queue): satisfy enqueue branch lint * fix(ci): format steer owner and type mock model tuple
60 lines
1.4 KiB
TypeScript
60 lines
1.4 KiB
TypeScript
import fs from "node:fs/promises";
|
|
|
|
export async function writeProbeMcpServer(filePath: string): Promise<void> {
|
|
await fs.writeFile(
|
|
filePath,
|
|
`let buffer = "";
|
|
const mode = process.env.MCP_MODE ?? "normal";
|
|
if (mode === "crash") {
|
|
process.exit(1);
|
|
}
|
|
function send(message) {
|
|
process.stdout.write(JSON.stringify(message) + "\\n");
|
|
}
|
|
function handle(message) {
|
|
if (message.method === "initialize") {
|
|
if (mode === "hang-start") {
|
|
return;
|
|
}
|
|
send({
|
|
jsonrpc: "2.0",
|
|
id: message.id,
|
|
result: {
|
|
protocolVersion: message.params?.protocolVersion ?? "2025-03-26",
|
|
capabilities: { tools: {} },
|
|
serverInfo: { name: "cli-probe-test", version: "1.0.0" },
|
|
},
|
|
});
|
|
return;
|
|
}
|
|
if (message.method === "tools/list") {
|
|
send({
|
|
jsonrpc: "2.0",
|
|
id: message.id,
|
|
result: { tools: [{ name: "ping", inputSchema: { type: "object" } }] },
|
|
});
|
|
}
|
|
}
|
|
process.stdin.setEncoding("utf8");
|
|
process.stdin.on("data", (chunk) => {
|
|
buffer += chunk;
|
|
while (true) {
|
|
const newline = buffer.indexOf("\\n");
|
|
if (newline < 0) {
|
|
return;
|
|
}
|
|
const line = buffer.slice(0, newline).replace(/\\r$/, "");
|
|
buffer = buffer.slice(newline + 1);
|
|
if (line.trim()) {
|
|
handle(JSON.parse(line));
|
|
}
|
|
}
|
|
});
|
|
process.stdin.on("end", () => process.exit(0));
|
|
process.on("SIGTERM", () => process.exit(0));
|
|
process.on("SIGINT", () => process.exit(0));
|
|
`,
|
|
"utf8",
|
|
);
|
|
}
|