@softerist/heuristic-mcp 2.1.3 → 2.1.4
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/README.md +16 -0
- package/features/register.js +121 -0
- package/index.js +14 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -176,6 +176,22 @@ Add the server configuration to the `mcpServers` object in your config file:
|
|
|
176
176
|
}
|
|
177
177
|
```
|
|
178
178
|
|
|
179
|
+
### Auto-Fix Configuration (New!)
|
|
180
|
+
|
|
181
|
+
To automatically configure your IDEs (Antigravity, Claude, Cursor) with the correct path:
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
heuristic-mcp --register
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
This will automatically find your IDE config files and inject the correct absolute path to the server. You can also target a specific IDE:
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
heuristic-mcp --register antigravity
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
---
|
|
194
|
+
|
|
179
195
|
## Environment Variables
|
|
180
196
|
|
|
181
197
|
Override configuration settings via environment variables in your MCP config:
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import fs from 'fs/promises';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import os from 'os';
|
|
4
|
+
import { fileURLToPath } from 'url';
|
|
5
|
+
|
|
6
|
+
// Helper to expand ~ and %vars%
|
|
7
|
+
function expandPath(p) {
|
|
8
|
+
if (p.startsWith('~/')) {
|
|
9
|
+
return path.join(os.homedir(), p.slice(2));
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
if (process.platform === 'win32') {
|
|
13
|
+
return p.replace(/%([^%]+)%/g, (_, n) => process.env[n] || '%' + n + '%');
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return p;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Known config paths for different IDEs
|
|
20
|
+
function getConfigPaths() {
|
|
21
|
+
const platform = process.platform;
|
|
22
|
+
const home = os.homedir();
|
|
23
|
+
const paths = [];
|
|
24
|
+
|
|
25
|
+
// Antigravity
|
|
26
|
+
if (platform === 'win32') {
|
|
27
|
+
paths.push({
|
|
28
|
+
name: 'Antigravity',
|
|
29
|
+
path: expandPath('%USERPROFILE%\\.gemini\\antigravity\\mcp_config.json')
|
|
30
|
+
});
|
|
31
|
+
} else {
|
|
32
|
+
paths.push({
|
|
33
|
+
name: 'Antigravity',
|
|
34
|
+
path: expandPath('~/.gemini/antigravity/mcp_config.json')
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Claude Desktop
|
|
39
|
+
if (platform === 'darwin') {
|
|
40
|
+
paths.push({
|
|
41
|
+
name: 'Claude Desktop',
|
|
42
|
+
path: expandPath('~/Library/Application Support/Claude/claude_desktop_config.json')
|
|
43
|
+
});
|
|
44
|
+
} else if (platform === 'win32') {
|
|
45
|
+
paths.push({
|
|
46
|
+
name: 'Claude Desktop',
|
|
47
|
+
path: expandPath('%APPDATA%\\Claude\\claude_desktop_config.json')
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Cursor (Cascade) - Settings are usually in settings.json but MCP might have a specific spot?
|
|
52
|
+
// Cursor often uses VS Code's settings.json for some things, but explicit MCP support varies.
|
|
53
|
+
// For now, we'll stick to Antigravity and Claude as confirmed targets.
|
|
54
|
+
// NOTE: If Cursor adds a specific mcp_config, add it here.
|
|
55
|
+
|
|
56
|
+
return paths;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export async function register(filter = null) {
|
|
60
|
+
const binaryPath = process.execPath; // The node binary
|
|
61
|
+
const scriptPath = fileURLToPath(new URL('../index.js', import.meta.url)); // Absolute path to index.js
|
|
62
|
+
|
|
63
|
+
const serverConfig = {
|
|
64
|
+
command: binaryPath,
|
|
65
|
+
args: [scriptPath, "--workspace", process.cwd()],
|
|
66
|
+
disabled: false,
|
|
67
|
+
autoRegistered: true // Marker to know we did this
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const configPaths = getConfigPaths();
|
|
71
|
+
let registeredCount = 0;
|
|
72
|
+
|
|
73
|
+
console.log(`[Auto-Register] Detecting IDE configurations...`);
|
|
74
|
+
|
|
75
|
+
for (const { name, path: configPath } of configPaths) {
|
|
76
|
+
if (filter && name.toLowerCase() !== filter.toLowerCase()) {
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
try {
|
|
81
|
+
// Check if file exists
|
|
82
|
+
try {
|
|
83
|
+
await fs.access(configPath);
|
|
84
|
+
} catch {
|
|
85
|
+
console.log(`[Auto-Register] Skipped ${name}: Config file not found at ${configPath}`);
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Read config
|
|
90
|
+
const content = await fs.readFile(configPath, 'utf-8');
|
|
91
|
+
let config = {};
|
|
92
|
+
try {
|
|
93
|
+
config = JSON.parse(content);
|
|
94
|
+
} catch (e) {
|
|
95
|
+
console.error(`[Auto-Register] Error parsing ${name} config: ${e.message}`);
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// Init mcpServers if missing
|
|
100
|
+
if (!config.mcpServers) {
|
|
101
|
+
config.mcpServers = {};
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Inject configuration
|
|
105
|
+
config.mcpServers['heuristic-mcp'] = serverConfig;
|
|
106
|
+
|
|
107
|
+
// Write back
|
|
108
|
+
await fs.writeFile(configPath, JSON.stringify(config, null, 2));
|
|
109
|
+
console.log(`[Auto-Register] ✅ Successfully registered with ${name}`);
|
|
110
|
+
registeredCount++;
|
|
111
|
+
|
|
112
|
+
} catch (err) {
|
|
113
|
+
console.error(`[Auto-Register] Failed to register with ${name}: ${err.message}`);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (registeredCount === 0) {
|
|
118
|
+
console.log(`[Auto-Register] No compatible IDE configurations found to update.`);
|
|
119
|
+
console.log(`[Auto-Register] Manual Config:\n${JSON.stringify({ mcpServers: { "heuristic-mcp": serverConfig } }, null, 2)}`);
|
|
120
|
+
}
|
|
121
|
+
}
|
package/index.js
CHANGED
|
@@ -19,10 +19,23 @@ import * as IndexCodebaseFeature from "./features/index-codebase.js";
|
|
|
19
19
|
import * as HybridSearchFeature from "./features/hybrid-search.js";
|
|
20
20
|
import * as ClearCacheFeature from "./features/clear-cache.js";
|
|
21
21
|
import * as FindSimilarCodeFeature from "./features/find-similar-code.js";
|
|
22
|
-
import
|
|
22
|
+
import { register } from "./features/register.js";
|
|
23
23
|
|
|
24
24
|
// Parse workspace from command line arguments
|
|
25
25
|
const args = process.argv.slice(2);
|
|
26
|
+
|
|
27
|
+
// Check if --register flag is present
|
|
28
|
+
if (args.includes('--register')) {
|
|
29
|
+
// Extract optional filter (e.g. --register antigravity)
|
|
30
|
+
const filterIndex = args.indexOf('--register');
|
|
31
|
+
const filter = args[filterIndex + 1] && !args[filterIndex + 1].startsWith('-')
|
|
32
|
+
? args[filterIndex + 1]
|
|
33
|
+
: null;
|
|
34
|
+
|
|
35
|
+
await register(filter);
|
|
36
|
+
process.exit(0);
|
|
37
|
+
}
|
|
38
|
+
|
|
26
39
|
const workspaceIndex = args.findIndex(arg => arg.startsWith('--workspace'));
|
|
27
40
|
let workspaceDir = null;
|
|
28
41
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@softerist/heuristic-mcp",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.4",
|
|
4
4
|
"description": "An enhanced MCP server providing intelligent semantic code search with find-similar-code, recency ranking, and improved chunking. Fork of smart-coding-mcp.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|