aidex-mcp 1.4.2 → 1.5.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/CHANGELOG.md CHANGED
@@ -2,6 +2,20 @@
2
2
 
3
3
  All notable changes to AiDex will be documented in this file.
4
4
 
5
+ ## [1.5.1] - 2026-01-31
6
+
7
+ ### Fixed
8
+ - **`aidex setup`**: Now creates config file if client directory exists but config is missing (e.g. fresh Claude Code install)
9
+
10
+ ## [1.5.0] - 2026-01-31
11
+
12
+ ### Added
13
+ - **`aidex setup`**: Auto-register AiDex as MCP server in all detected AI clients
14
+ - Supports: Claude Code, Claude Desktop, Cursor, Windsurf
15
+ - Cross-platform: Windows, macOS, Linux
16
+ - **`aidex unsetup`**: Remove AiDex registration from all clients
17
+ - **Postinstall hint**: Shows `Run "aidex setup"` after npm install
18
+
5
19
  ## [1.4.2] - 2026-01-31
6
20
 
7
21
  ### Added
package/README.md CHANGED
@@ -106,13 +106,16 @@ The index lives in `.aidex/index.db` (SQLite) - fast, portable, no external depe
106
106
 
107
107
  ## Quick Start
108
108
 
109
- ### 1. Install
109
+ ### 1. Install & Register
110
110
 
111
111
  ```bash
112
112
  npm install -g aidex-mcp
113
+ aidex setup
113
114
  ```
114
115
 
115
- ### 2. Register with your AI assistant
116
+ `aidex setup` automatically detects and registers AiDex with your installed AI clients (Claude Code, Claude Desktop, Cursor, Windsurf). To unregister: `aidex unsetup`.
117
+
118
+ ### 2. Or register manually with your AI assistant
116
119
 
117
120
  **For Claude Code** (`~/.claude/settings.json` or `~/.claude.json`):
118
121
  ```json
@@ -0,0 +1,8 @@
1
+ /**
2
+ * AiDex Setup - Auto-register as MCP server in AI clients
3
+ *
4
+ * Supports: Claude Code, Claude Desktop, Cursor, Windsurf
5
+ */
6
+ export declare function setupMcpClients(): void;
7
+ export declare function unsetupMcpClients(): void;
8
+ //# sourceMappingURL=setup.d.ts.map
@@ -0,0 +1,175 @@
1
+ /**
2
+ * AiDex Setup - Auto-register as MCP server in AI clients
3
+ *
4
+ * Supports: Claude Code, Claude Desktop, Cursor, Windsurf
5
+ */
6
+ import { existsSync, readFileSync, writeFileSync } from 'fs';
7
+ import { join } from 'path';
8
+ import { homedir, platform } from 'os';
9
+ // ============================================================
10
+ // MCP Server Entry
11
+ // ============================================================
12
+ const AIDEX_MCP_ENTRY = {
13
+ command: 'aidex',
14
+ args: []
15
+ };
16
+ // ============================================================
17
+ // Client Detection
18
+ // ============================================================
19
+ function getClients() {
20
+ const home = homedir();
21
+ const plat = platform();
22
+ const clients = [];
23
+ // Claude Code
24
+ clients.push({
25
+ name: 'Claude Code',
26
+ configPath: join(home, '.claude', 'settings.json'),
27
+ detectDir: join(home, '.claude')
28
+ });
29
+ // Claude Desktop
30
+ if (plat === 'win32') {
31
+ const appData = process.env.APPDATA || join(home, 'AppData', 'Roaming');
32
+ clients.push({
33
+ name: 'Claude Desktop',
34
+ configPath: join(appData, 'Claude', 'claude_desktop_config.json'),
35
+ detectDir: join(appData, 'Claude')
36
+ });
37
+ }
38
+ else if (plat === 'darwin') {
39
+ clients.push({
40
+ name: 'Claude Desktop',
41
+ configPath: join(home, 'Library', 'Application Support', 'Claude', 'claude_desktop_config.json'),
42
+ detectDir: join(home, 'Library', 'Application Support', 'Claude')
43
+ });
44
+ }
45
+ else {
46
+ clients.push({
47
+ name: 'Claude Desktop',
48
+ configPath: join(home, '.config', 'Claude', 'claude_desktop_config.json'),
49
+ detectDir: join(home, '.config', 'Claude')
50
+ });
51
+ }
52
+ // Cursor
53
+ clients.push({
54
+ name: 'Cursor',
55
+ configPath: join(home, '.cursor', 'mcp.json'),
56
+ detectDir: join(home, '.cursor')
57
+ });
58
+ // Windsurf
59
+ clients.push({
60
+ name: 'Windsurf',
61
+ configPath: join(home, '.codeium', 'windsurf', 'mcp_config.json'),
62
+ detectDir: join(home, '.codeium', 'windsurf')
63
+ });
64
+ return clients;
65
+ }
66
+ // ============================================================
67
+ // Config Read/Write
68
+ // ============================================================
69
+ function readJsonConfig(filePath) {
70
+ try {
71
+ const content = readFileSync(filePath, 'utf8');
72
+ return { success: true, data: JSON.parse(content) };
73
+ }
74
+ catch (err) {
75
+ if (err.code === 'ENOENT') {
76
+ return { success: false, error: 'not found' };
77
+ }
78
+ if (err instanceof SyntaxError) {
79
+ return { success: false, error: `invalid JSON: ${err.message}` };
80
+ }
81
+ return { success: false, error: String(err) };
82
+ }
83
+ }
84
+ function writeJsonConfig(filePath, data) {
85
+ try {
86
+ const content = JSON.stringify(data, null, 2) + '\n';
87
+ writeFileSync(filePath, content, 'utf8');
88
+ return { success: true };
89
+ }
90
+ catch (err) {
91
+ return { success: false, error: String(err) };
92
+ }
93
+ }
94
+ // ============================================================
95
+ // Setup / Unsetup
96
+ // ============================================================
97
+ export function setupMcpClients() {
98
+ const clients = getClients();
99
+ const results = [];
100
+ let registered = 0;
101
+ console.log('\nAiDex MCP Server Registration');
102
+ console.log('==============================\n');
103
+ for (const client of clients) {
104
+ // Check if client is installed (detect directory exists)
105
+ if (!existsSync(client.detectDir)) {
106
+ results.push({ client: client.name, status: 'skipped', configPath: client.configPath });
107
+ console.log(` - ${client.name} (not installed)`);
108
+ continue;
109
+ }
110
+ // Read existing config or start with empty object
111
+ let data;
112
+ if (existsSync(client.configPath)) {
113
+ const config = readJsonConfig(client.configPath);
114
+ if (!config.success || !config.data) {
115
+ results.push({ client: client.name, status: 'error', configPath: client.configPath, message: config.error });
116
+ console.log(` ✗ ${client.name} (${config.error})`);
117
+ continue;
118
+ }
119
+ data = config.data;
120
+ }
121
+ else {
122
+ data = {};
123
+ }
124
+ if (!data.mcpServers || typeof data.mcpServers !== 'object') {
125
+ data.mcpServers = {};
126
+ }
127
+ data.mcpServers.aidex = { ...AIDEX_MCP_ENTRY };
128
+ const writeResult = writeJsonConfig(client.configPath, data);
129
+ if (!writeResult.success) {
130
+ results.push({ client: client.name, status: 'error', configPath: client.configPath, message: writeResult.error });
131
+ console.log(` ✗ ${client.name} (${writeResult.error})`);
132
+ continue;
133
+ }
134
+ registered++;
135
+ results.push({ client: client.name, status: 'registered', configPath: client.configPath });
136
+ console.log(` ✓ ${client.name} (${client.configPath})`);
137
+ }
138
+ console.log(`\nRegistered AiDex with ${registered} client(s).\n`);
139
+ if (registered > 0) {
140
+ console.log('Restart your AI client(s) to activate AiDex.\n');
141
+ }
142
+ }
143
+ export function unsetupMcpClients() {
144
+ const clients = getClients();
145
+ let removed = 0;
146
+ console.log('\nAiDex MCP Server Unregistration');
147
+ console.log('================================\n');
148
+ for (const client of clients) {
149
+ if (!existsSync(client.configPath)) {
150
+ console.log(` - ${client.name} (not installed)`);
151
+ continue;
152
+ }
153
+ const config = readJsonConfig(client.configPath);
154
+ if (!config.success || !config.data) {
155
+ console.log(` ✗ ${client.name} (${config.error})`);
156
+ continue;
157
+ }
158
+ const data = config.data;
159
+ const servers = data.mcpServers;
160
+ if (!servers || !servers.aidex) {
161
+ console.log(` - ${client.name} (not registered)`);
162
+ continue;
163
+ }
164
+ delete servers.aidex;
165
+ const writeResult = writeJsonConfig(client.configPath, data);
166
+ if (!writeResult.success) {
167
+ console.log(` ✗ ${client.name} (${writeResult.error})`);
168
+ continue;
169
+ }
170
+ removed++;
171
+ console.log(` ✓ Removed from ${client.name}`);
172
+ }
173
+ console.log(`\nUnregistered AiDex from ${removed} client(s).\n`);
174
+ }
175
+ //# sourceMappingURL=setup.js.map
package/build/index.js CHANGED
@@ -11,6 +11,7 @@
11
11
  */
12
12
  import { createServer } from './server/mcp-server.js';
13
13
  import { scan, init } from './commands/index.js';
14
+ import { setupMcpClients, unsetupMcpClients } from './commands/setup.js';
14
15
  import { PRODUCT_NAME, PRODUCT_NAME_LOWER } from './constants.js';
15
16
  async function main() {
16
17
  const args = process.argv.slice(2);
@@ -63,6 +64,16 @@ async function main() {
63
64
  console.log(` Time: ${result.durationMs}ms`);
64
65
  return;
65
66
  }
67
+ // CLI mode: setup
68
+ if (args[0] === 'setup') {
69
+ setupMcpClients();
70
+ return;
71
+ }
72
+ // CLI mode: unsetup
73
+ if (args[0] === 'unsetup') {
74
+ unsetupMcpClients();
75
+ return;
76
+ }
66
77
  // Default: Start MCP server
67
78
  const server = createServer();
68
79
  await server.start();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aidex-mcp",
3
- "version": "1.4.2",
3
+ "version": "1.5.1",
4
4
  "description": "MCP Server providing persistent code indexing for Claude Code",
5
5
  "main": "build/index.js",
6
6
  "bin": {
@@ -16,6 +16,7 @@
16
16
  "dev": "tsc && node build/index.js",
17
17
  "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
18
18
  "clean": "rimraf build",
19
+ "postinstall": "node scripts/postinstall.mjs",
19
20
  "prepublishOnly": "npm run build"
20
21
  },
21
22
  "keywords": [
@@ -0,0 +1,2 @@
1
+ // Postinstall hint - shown after npm install -g aidex-mcp
2
+ console.log('\n AiDex installed! Run "aidex setup" to register with your AI clients.\n');