@pharaoh-so/mcp 0.3.9 → 0.3.10

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/dist/helpers.js CHANGED
@@ -42,7 +42,7 @@ export function parseArgs(argv = process.argv.slice(2)) {
42
42
  return { server, logout };
43
43
  }
44
44
  export function printUsage() {
45
- printLines("Usage: pharaoh-mcp [options]", "", "Options:", " --server <url> Pharaoh server URL (default: https://mcp.pharaoh.so)", " --logout Clear stored credentials and exit", " --install-skills Force reinstall Pharaoh skills (Claude Code + OpenClaw)", " --help, -h Show this help", "", "Get started:", ` ${NPX_COMMAND}`, "");
45
+ printLines("Usage: pharaoh-mcp [options]", "", "Options:", " --server <url> Pharaoh server URL (default: https://mcp.pharaoh.so)", " --logout Clear credentials and MCP config, then exit", " --clean Remove all Pharaoh MCP entries from Claude Code config", " --install-skills Force reinstall Pharaoh skills (Claude Code + OpenClaw)", " --help, -h Show this help", "", "Get started:", ` ${NPX_COMMAND}`, "");
46
46
  }
47
47
  /**
48
48
  * Validate that a server-supplied SSE URL shares the same origin as the configured server.
package/dist/index.js CHANGED
@@ -41,10 +41,20 @@ async function main() {
41
41
  runInstallSkills();
42
42
  return;
43
43
  }
44
+ // Clean mode — remove all pharaoh traces from Claude Code config (MCP entries,
45
+ // disabled states, project-scoped configs). Useful for resetting broken installs.
46
+ if (args.includes("--clean")) {
47
+ const { cleanSlate } = await import("./setup.js");
48
+ cleanSlate();
49
+ printLines("Pharaoh: cleaned all MCP entries from Claude Code config");
50
+ process.exit(0);
51
+ }
44
52
  const { server, logout } = parseArgs(args);
45
53
  if (logout) {
54
+ const { cleanSlate } = await import("./setup.js");
55
+ cleanSlate();
46
56
  deleteCredentials();
47
- printLines("Pharaoh: credentials cleared");
57
+ printLines("Pharaoh: credentials and MCP config cleared");
48
58
  process.exit(0);
49
59
  }
50
60
  const creds = readCredentials();
package/dist/setup.d.ts CHANGED
@@ -1,5 +1,16 @@
1
1
  /**
2
- * Full automated setup: remove stale entries, register MCP server globally,
2
+ * Remove all traces of pharaoh from Claude Code's internal config (~/.claude.json).
3
+ *
4
+ * The `claude mcp remove` CLI only removes the server definition from one scope
5
+ * at a time and does NOT clear:
6
+ * - `disabledMcpServers` arrays (set when user disables via UI)
7
+ * - Project-scoped `mcpServers.pharaoh` entries in other workspaces
8
+ *
9
+ * This function handles what the CLI cannot — a true clean slate.
10
+ */
11
+ export declare function cleanSlate(home?: string): void;
12
+ /**
13
+ * Full automated setup: clean slate removal, register MCP server globally,
3
14
  * install skills. Requires valid credentials (caller handles auth first).
4
15
  *
5
16
  * @returns true if setup succeeded, false if Claude CLI not found.
package/dist/setup.js CHANGED
@@ -6,6 +6,9 @@
6
6
  * One command does everything: `npx @pharaoh-so/mcp`
7
7
  */
8
8
  import { execFileSync } from "node:child_process";
9
+ import { existsSync, readFileSync, writeFileSync } from "node:fs";
10
+ import { homedir } from "node:os";
11
+ import { join } from "node:path";
9
12
  import { NPX_COMMAND, printLines } from "./helpers.js";
10
13
  /** Check if `claude` CLI is available in PATH. */
11
14
  function hasClaude() {
@@ -41,7 +44,64 @@ function runClaude(args) {
41
44
  }
42
45
  }
43
46
  /**
44
- * Full automated setup: remove stale entries, register MCP server globally,
47
+ * Remove all traces of pharaoh from Claude Code's internal config (~/.claude.json).
48
+ *
49
+ * The `claude mcp remove` CLI only removes the server definition from one scope
50
+ * at a time and does NOT clear:
51
+ * - `disabledMcpServers` arrays (set when user disables via UI)
52
+ * - Project-scoped `mcpServers.pharaoh` entries in other workspaces
53
+ *
54
+ * This function handles what the CLI cannot — a true clean slate.
55
+ */
56
+ export function cleanSlate(home = homedir()) {
57
+ const claudeJsonPath = join(home, ".claude.json");
58
+ if (!existsSync(claudeJsonPath))
59
+ return;
60
+ let raw;
61
+ let data;
62
+ try {
63
+ raw = readFileSync(claudeJsonPath, "utf-8");
64
+ data = JSON.parse(raw);
65
+ }
66
+ catch {
67
+ // Corrupt or unreadable — don't risk making it worse
68
+ return;
69
+ }
70
+ let changed = false;
71
+ // Remove global User MCP server definition
72
+ if (data.mcpServers?.pharaoh) {
73
+ delete data.mcpServers.pharaoh;
74
+ changed = true;
75
+ }
76
+ // Walk all project/workspace entries
77
+ if (data.projects) {
78
+ for (const proj of Object.values(data.projects)) {
79
+ // Remove project-scoped pharaoh server definitions
80
+ if (proj.mcpServers?.pharaoh) {
81
+ delete proj.mcpServers.pharaoh;
82
+ changed = true;
83
+ }
84
+ // Remove pharaoh from disabled lists (UI "disable" state).
85
+ // filter() handles duplicates — indexOf+splice would leave extras.
86
+ if (Array.isArray(proj.disabledMcpServers)) {
87
+ const before = proj.disabledMcpServers.length;
88
+ proj.disabledMcpServers = proj.disabledMcpServers.filter((s) => s !== "pharaoh");
89
+ if (proj.disabledMcpServers.length !== before)
90
+ changed = true;
91
+ }
92
+ }
93
+ }
94
+ if (changed) {
95
+ try {
96
+ writeFileSync(claudeJsonPath, JSON.stringify(data, null, " "));
97
+ }
98
+ catch {
99
+ // Read-only file or permissions issue — fall through to CLI removal
100
+ }
101
+ }
102
+ }
103
+ /**
104
+ * Full automated setup: clean slate removal, register MCP server globally,
45
105
  * install skills. Requires valid credentials (caller handles auth first).
46
106
  *
47
107
  * @returns true if setup succeeded, false if Claude CLI not found.
@@ -54,9 +114,13 @@ export function runSetup(options) {
54
114
  }
55
115
  if (!silent)
56
116
  printLines("Pharaoh: setting up...");
57
- // Step 1: Remove any stale entry (ignore failures may not exist)
58
- runClaude(["mcp", "remove", "pharaoh"]);
59
- // Step 2: Register as global stdio MCP server
117
+ // Step 1: Clean slate remove pharaoh from all scopes, disabled lists,
118
+ // and project-scoped configs. Direct file edit handles what CLI cannot.
119
+ cleanSlate();
120
+ // Step 2: Belt-and-suspenders — also remove via CLI (both scopes)
121
+ runClaude(["mcp", "remove", "pharaoh", "-s", "user"]);
122
+ runClaude(["mcp", "remove", "pharaoh", "-s", "project"]);
123
+ // Step 3: Register as global stdio MCP server
60
124
  const added = runClaude([
61
125
  "mcp",
62
126
  "add",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pharaoh-so/mcp",
3
3
  "mcpName": "so.pharaoh/pharaoh",
4
- "version": "0.3.9",
4
+ "version": "0.3.10",
5
5
  "description": "MCP proxy for Pharaoh — maps codebases into queryable knowledge graphs for AI agents. Enables Claude Code in headless environments (VPS, SSH, CI) via device flow auth.",
6
6
  "type": "module",
7
7
  "main": "dist/index.js",