create-guardio 0.0.1
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/index.mjs +93 -0
- package/package.json +22 -0
package/index.mjs
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createInterface } from "node:readline";
|
|
3
|
+
import { mkdir, writeFile, chmod } from "node:fs/promises";
|
|
4
|
+
import { resolve, dirname } from "node:path";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
|
|
7
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
8
|
+
|
|
9
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
10
|
+
|
|
11
|
+
function ask(question, defaultAnswer = "") {
|
|
12
|
+
const suffix = defaultAnswer ? ` (${defaultAnswer})` : "";
|
|
13
|
+
return new Promise((resolve) => {
|
|
14
|
+
rl.question(`${question}${suffix}: `, (answer) => {
|
|
15
|
+
resolve(
|
|
16
|
+
typeof answer === "string" && answer.trim() !== ""
|
|
17
|
+
? answer.trim()
|
|
18
|
+
: defaultAnswer
|
|
19
|
+
);
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
async function main() {
|
|
25
|
+
console.log("\nCreate Guardio\n");
|
|
26
|
+
|
|
27
|
+
const guardioDir = await ask("Guardio directory", "./mcp-server-gated");
|
|
28
|
+
const guardioPath = resolve(process.cwd(), guardioDir);
|
|
29
|
+
|
|
30
|
+
const command = await ask("MCP Server command", "node");
|
|
31
|
+
const argsStr = await ask(
|
|
32
|
+
"MCP Server args",
|
|
33
|
+
"path/to/your-mcp-server/index.js"
|
|
34
|
+
);
|
|
35
|
+
const args = argsStr
|
|
36
|
+
.split(",")
|
|
37
|
+
.map((s) => s.trim())
|
|
38
|
+
.filter(Boolean);
|
|
39
|
+
const serverConfig = { type: "command", command, args };
|
|
40
|
+
|
|
41
|
+
const config = {
|
|
42
|
+
server: serverConfig,
|
|
43
|
+
plugins: [
|
|
44
|
+
{ type: "policy", name: "default", config: { blockedTools: [] } },
|
|
45
|
+
],
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
await mkdir(guardioPath, { recursive: true });
|
|
49
|
+
await mkdir(resolve(guardioPath, "bin"), { recursive: true });
|
|
50
|
+
|
|
51
|
+
await writeFile(
|
|
52
|
+
resolve(guardioPath, "guardio.config.json"),
|
|
53
|
+
JSON.stringify(config, null, 2),
|
|
54
|
+
"utf-8"
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
const binContent = `#!/usr/bin/env node
|
|
58
|
+
import { spawnSync } from "child_process";
|
|
59
|
+
import path from "path";
|
|
60
|
+
import { fileURLToPath } from "url";
|
|
61
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
62
|
+
const configPath = path.resolve(__dirname, "..", "guardio.config.json");
|
|
63
|
+
const result = spawnSync(
|
|
64
|
+
"npx",
|
|
65
|
+
["-y", "@guardiojs/guardio", "--config", configPath],
|
|
66
|
+
{ stdio: "inherit" }
|
|
67
|
+
);
|
|
68
|
+
process.exit(result.status ?? 1);
|
|
69
|
+
`;
|
|
70
|
+
|
|
71
|
+
const binPath = resolve(guardioPath, "bin", "guardio.mjs");
|
|
72
|
+
await writeFile(binPath, binContent, "utf-8");
|
|
73
|
+
await chmod(binPath, 0o755);
|
|
74
|
+
|
|
75
|
+
const relativeBin = `${guardioDir}/bin/guardio.mjs`;
|
|
76
|
+
const absoluteBin = resolve(guardioPath, "bin", "guardio.mjs");
|
|
77
|
+
|
|
78
|
+
console.log("\n---\n");
|
|
79
|
+
console.log("Add to MCP client\n");
|
|
80
|
+
console.log("# Copy/paste the shown command\n");
|
|
81
|
+
console.log(relativeBin);
|
|
82
|
+
console.log("\n# Or use absolute path:\n");
|
|
83
|
+
console.log(absoluteBin);
|
|
84
|
+
console.log("");
|
|
85
|
+
|
|
86
|
+
rl.close();
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
main().catch((err) => {
|
|
90
|
+
console.error(err);
|
|
91
|
+
rl.close();
|
|
92
|
+
process.exit(1);
|
|
93
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "create-guardio",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Scaffold a Guardio project",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"create-guardio": "./index.mjs"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"index.mjs"
|
|
11
|
+
],
|
|
12
|
+
"keywords": [
|
|
13
|
+
"mcp",
|
|
14
|
+
"security",
|
|
15
|
+
"guardio",
|
|
16
|
+
"scaffold",
|
|
17
|
+
"ai",
|
|
18
|
+
"agents"
|
|
19
|
+
],
|
|
20
|
+
"author": "Radoslaw Szymkiewicz",
|
|
21
|
+
"license": "Apache-2.0"
|
|
22
|
+
}
|