@arkheia/mcp-server 0.1.10 → 1.2.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.
@@ -1,163 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * Installs the Arkheia detection protocol into AI CLI instruction files
4
- * and registers the MCP server with each detected CLI.
5
- *
6
- * Usage:
7
- * npx @arkheia/mcp-server --setup
8
- * node scripts/setup-claude.js
9
- *
10
- * What it does:
11
- * 1. Detects which AI CLIs are installed (claude, codex, gemini, grok)
12
- * 2. Appends detection protocol to instruction files that need it:
13
- * - Claude Code: ~/.claude/CLAUDE.md
14
- * - Codex: ~/.codex/CODEX.md
15
- * - Gemini: not needed (reads protocol from tool descriptions)
16
- * - Grok: not needed (no instruction file mechanism)
17
- * 3. Registers the MCP server with each detected CLI
18
- */
19
-
20
- const fs = require("fs");
21
- const path = require("path");
22
- const os = require("os");
23
- const { execSync } = require("child_process");
24
-
25
- const MARKER = "# Arkheia Integration — Detection Protocol";
26
-
27
- const PROTOCOL = `
28
- # Arkheia Integration — Detection Protocol
29
-
30
- When Arkheia MCP tools are available in this session, follow this protocol.
31
-
32
- ## Fabrication Detection
33
-
34
- Call \`arkheia_verify\` on EVERY model response before surfacing it to the user. Do not skip responses that appear obviously correct.
35
-
36
- ## Risk Escalation
37
-
38
- - **HIGH risk**: Warn the user that the response may be fabricated. Include the \`detection_id\`. Still show the response — never hide or suppress it. Ask the user if they want to verify with a different model.
39
- - **MEDIUM risk**: Show the response with a brief confidence note.
40
- - **LOW risk**: Show normally.
41
- - **UNKNOWN risk**: Flag for human review. Include the \`detection_id\`.
42
-
43
- ## Cross-Model Verification
44
-
45
- When HIGH or UNKNOWN risk is detected, offer to verify using: \`run_grok\`, \`run_gemini\`, \`run_ollama\`, \`run_together\`.
46
-
47
- ## Audit Trail
48
-
49
- Use \`arkheia_audit_log\` when the user asks about detection history or for compliance evidence.
50
-
51
- ## Persistent Knowledge Graph
52
-
53
- Use \`memory_store\` to persist facts, \`memory_retrieve\` to recall them, \`memory_relate\` to track relationships between entities.
54
-
55
- ## Key Rules
56
-
57
- 1. Never hide a response from the user regardless of risk level
58
- 2. Always include the \`detection_id\` when reporting HIGH or UNKNOWN risk
59
- 3. Call \`arkheia_verify\` proactively — do not wait for the user to ask
60
- 4. Audit logging happens automatically through \`arkheia_verify\`
61
- `;
62
-
63
- function cmdExists(cmd) {
64
- try {
65
- execSync(process.platform === "win32" ? `where ${cmd}` : `which ${cmd}`, { stdio: "pipe" });
66
- return true;
67
- } catch { return false; }
68
- }
69
-
70
- function installProtocol(filePath, cliName) {
71
- const dir = path.dirname(filePath);
72
- if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
73
-
74
- if (fs.existsSync(filePath)) {
75
- const existing = fs.readFileSync(filePath, "utf8");
76
- if (existing.includes(MARKER)) {
77
- console.log(` [${cliName}] Detection protocol already installed in ${filePath}`);
78
- return;
79
- }
80
- fs.appendFileSync(filePath, "\n" + PROTOCOL);
81
- console.log(` [${cliName}] Detection protocol appended to ${filePath}`);
82
- } else {
83
- fs.writeFileSync(filePath, PROTOCOL.trim() + "\n");
84
- console.log(` [${cliName}] Detection protocol written to ${filePath}`);
85
- }
86
- }
87
-
88
- function registerMcp(cli, args) {
89
- try {
90
- execSync(args, { stdio: "inherit", timeout: 15000 });
91
- console.log(` [${cli}] MCP server registered`);
92
- } catch {
93
- console.log(` [${cli}] Auto-registration failed — run manually:`);
94
- console.log(` ${args}`);
95
- }
96
- }
97
-
98
- function main() {
99
- const apiKey = process.env.ARKHEIA_API_KEY || "";
100
- const home = os.homedir();
101
- const detected = [];
102
-
103
- console.log("\n[arkheia] Setting up detection protocol for installed AI CLIs...\n");
104
-
105
- // ── Claude Code ──────────────────────────────────────────────
106
- if (cmdExists("claude")) {
107
- detected.push("claude");
108
- console.log("[claude] Detected");
109
- installProtocol(path.join(home, ".claude", "CLAUDE.md"), "claude");
110
- if (apiKey) {
111
- registerMcp("claude", `claude mcp add arkheia -s user -e ARKHEIA_API_KEY="${apiKey}" -- mcp-server`);
112
- } else {
113
- console.log(' [claude] Set ARKHEIA_API_KEY then run: claude mcp add arkheia -s user -e ARKHEIA_API_KEY="$ARKHEIA_API_KEY" -- mcp-server');
114
- }
115
- }
116
-
117
- // ── Codex ────────────────────────────────────────────────────
118
- if (cmdExists("codex")) {
119
- detected.push("codex");
120
- console.log("[codex] Detected");
121
- installProtocol(path.join(home, ".codex", "CODEX.md"), "codex");
122
- if (apiKey) {
123
- registerMcp("codex", `codex mcp add arkheia --env ARKHEIA_API_KEY="${apiKey}" -- mcp-server`);
124
- } else {
125
- console.log(' [codex] Set ARKHEIA_API_KEY then run: codex mcp add arkheia --env ARKHEIA_API_KEY="$ARKHEIA_API_KEY" -- mcp-server');
126
- }
127
- }
128
-
129
- // ── Gemini ───────────────────────────────────────────────────
130
- // Gemini reads the detection protocol directly from tool descriptions.
131
- // No instruction file needed — just register the MCP server.
132
- if (cmdExists("gemini")) {
133
- detected.push("gemini");
134
- console.log("[gemini] Detected (no instruction file needed — reads protocol from tool descriptions)");
135
- if (apiKey) {
136
- registerMcp("gemini", `gemini mcp add -s user -e ARKHEIA_API_KEY="${apiKey}" arkheia mcp-server`);
137
- } else {
138
- console.log(' [gemini] Set ARKHEIA_API_KEY then run: gemini mcp add -s user -e ARKHEIA_API_KEY="$ARKHEIA_API_KEY" arkheia mcp-server');
139
- }
140
- }
141
-
142
- // ── Grok ─────────────────────────────────────────────────────
143
- // No instruction file mechanism. Register MCP server only.
144
- if (cmdExists("grok")) {
145
- detected.push("grok");
146
- console.log("[grok] Detected (no instruction file mechanism)");
147
- if (apiKey) {
148
- registerMcp("grok", `grok mcp add arkheia -t stdio -c mcp-server -e ARKHEIA_API_KEY="${apiKey}"`);
149
- } else {
150
- console.log(' [grok] Set ARKHEIA_API_KEY then run: grok mcp add arkheia -t stdio -c mcp-server -e ARKHEIA_API_KEY="$ARKHEIA_API_KEY"');
151
- }
152
- }
153
-
154
- if (detected.length === 0) {
155
- console.log("No AI CLIs detected on PATH (claude, codex, gemini, grok).");
156
- console.log("Install one and re-run: npx @arkheia/mcp-server --setup");
157
- } else {
158
- console.log(`\n[arkheia] Setup complete for: ${detected.join(", ")}`);
159
- console.log("[arkheia] Restart each CLI to activate Arkheia detection.\n");
160
- }
161
- }
162
-
163
- main();