@codeconductorai/harmony-mcp 1.0.9 → 1.0.11

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 CHANGED
@@ -27,12 +27,12 @@ Re-run `node -v` afterwards to confirm before continuing.
27
27
 
28
28
  ## Installation
29
29
 
30
- The server is published as `@codeconductorai/harmony-mcp` and run via `npx`, so no local build step is required.
30
+ The server is published as `@codeconductorai/harmony-mcp` and run via `npx`, so no local build step is required. The commands below pin an exact version (`@1.0.11`) rather than a floating tag — this lets `npx` reuse its local cache instead of re-resolving the package from the registry on every agent startup, which otherwise makes MCP initialization noticeably slower (and occasionally hang). Bump the pinned version deliberately when you want to upgrade.
31
31
 
32
32
  ### Claude Code
33
33
 
34
34
  ```bash
35
- claude mcp add harmony -- npx -y @codeconductorai/harmony-mcp
35
+ claude mcp add harmony -- npx -y @codeconductorai/harmony-mcp@1.0.11
36
36
  ```
37
37
 
38
38
  ### Antigravity
@@ -47,7 +47,7 @@ Open **MCP Servers → Manage MCP Servers → View raw config** from the agent p
47
47
  "mcpServers": {
48
48
  "harmony": {
49
49
  "command": "npx",
50
- "args": ["-y", "@codeconductorai/harmony-mcp"]
50
+ "args": ["-y", "@codeconductorai/harmony-mcp@1.0.11"]
51
51
  }
52
52
  }
53
53
  }
@@ -58,7 +58,7 @@ Restart Antigravity (or reload MCP servers) after saving.
58
58
  ### Codex CLI
59
59
 
60
60
  ```bash
61
- codex mcp add harmony -- npx -y @codeconductorai/harmony-mcp
61
+ codex mcp add harmony -- npx -y @codeconductorai/harmony-mcp@1.0.11
62
62
  ```
63
63
 
64
64
  This writes the entry to `~/.codex/config.toml`. To add it by hand instead:
@@ -66,7 +66,7 @@ This writes the entry to `~/.codex/config.toml`. To add it by hand instead:
66
66
  ```toml
67
67
  [mcp_servers.harmony]
68
68
  command = "npx"
69
- args = ["-y", "@codeconductorai/harmony-mcp"]
69
+ args = ["-y", "@codeconductorai/harmony-mcp@1.0.11"]
70
70
  ```
71
71
 
72
72
  ### Aria
@@ -78,7 +78,7 @@ In the Aria Code panel, click the settings icon → **MCP Servers**, then scroll
78
78
  "mcpServers": {
79
79
  "harmony": {
80
80
  "command": "npx",
81
- "args": ["-y", "@codeconductorai/harmony-mcp"]
81
+ "args": ["-y", "@codeconductorai/harmony-mcp@1.0.11"]
82
82
  }
83
83
  }
84
84
  }
@@ -95,7 +95,7 @@ Any client that reads a `command`/`args` style config (e.g. Claude Desktop's `cl
95
95
  "mcpServers": {
96
96
  "harmony": {
97
97
  "command": "npx",
98
- "args": ["-y", "@codeconductorai/harmony-mcp"]
98
+ "args": ["-y", "@codeconductorai/harmony-mcp@1.0.11"]
99
99
  }
100
100
  }
101
101
  }
@@ -122,31 +122,37 @@ Completes authentication after the browser login. Requires `userConfirmed: true`
122
122
  - `timeout` (optional): max seconds to wait (default 300).
123
123
 
124
124
  ### `setup_workspace`
125
- Registers the current project as a workspace on the backend and fully indexes it (zips and uploads the codebase, excluding `node_modules`, `.git`, `.next`, `dist`, `build`, and the workspace marker) in a single call. Starts the file watcher for incremental re-indexing once done. Idempotent — a `.harmony_workspace.json` marker tracks setup/upload state, so calling it again once both steps have completed is a no-op. If it fails partway (e.g. the upload step errors out after the workspace was already created), call it again — `language`/`buildTool` can be omitted on that retry since they're remembered from the marker, and only the incomplete step re-runs.
125
+ Registers the current project as a workspace on the backend and fully indexes it (zips and uploads the codebase) in a single call. The zip excludes VCS/IDE directories, per-language build/dependency output (`node_modules`, `target`, `dist`, `build`, `.venv`, `vendor`, etc.), compiled/binary/media file types, common lockfiles, and the workspace marker — kept in sync with the backend's own indexing file filter, so nothing gets uploaded that the backend would just discard anyway. Starts the file watcher for incremental re-indexing once done. Safe to call again anytime — a `.harmony_workspace.json` marker tracks setup/upload state and the last-indexed commit, so it's a no-op if nothing has changed, and automatically re-uploads if the local commit has moved on since the last successful upload. If it fails partway (e.g. the upload step errors out after the workspace was already created), call it again — `language`/`buildTool` can be omitted on that retry since they're remembered from the marker, and only the incomplete step re-runs.
126
126
  - `language` (required on first call): e.g. `JAVA`, `JAVASCRIPT`, `TYPESCRIPT`, `PYTHON`.
127
127
  - `buildTool` (required on first call): e.g. `MAVEN`, `GRADLE`, `NPM`.
128
128
 
129
+ Every workspace is tagged with a scheme-aware `repoId`, surfaced in the response as `repoId`/`repoIdScheme`: `git_url:<host/org/repo>` (normalized origin remote URL — the common case), falling back to `git_commit:<root sha>` (Git repo with no remote), `artifact:<ecosystem>:<name>` (no `.git` at all — read from `pom.xml`/`package.json`/`go.mod`/`Cargo.toml`/`pyproject.toml`), or `dir:<folder name>` as a last resort.
130
+
129
131
  ### `get_context_bundle`
130
132
  Retrieves a ranked XML context bundle of the most relevant code for a prompt.
131
133
  - `prompt` (required): natural-language question or instruction.
134
+ - `workspaceId` (optional): target a specific workspace instead of the local project's. Defaults to the local `setup_workspace` workspace.
132
135
 
133
136
  ### `locate`
134
137
  Given a natural-language query or exact identifier, returns lightweight symbol coordinate anchors (file path, symbol name, kind/type, whether it's a definition, line numbers, primary role) — no code snippets. Use it to find which file(s) and exact line(s) to look at or edit for a task.
135
138
  - `prompt` (required): what to find, e.g. `"where user login is handled"` or `"CrudController"`. Must be non-blank — a missing or whitespace-only prompt returns an empty list, not an error.
136
139
  - `file_path` (optional): case-insensitive substring match against the full file path (not exact-path or prefix) to restrict results to a subdirectory, module, or specific file.
137
140
  - `limit` (optional): max results (default 40); the result list is never padded to this size.
141
+ - `workspaceId` (optional): target a specific workspace instead of the local project's. Defaults to the local `setup_workspace` workspace.
138
142
 
139
143
  ### `search_code_context`
140
144
  Given a natural-language query, returns matching symbols along with their code snippets, documentation, and decorators. Use this to understand or explain how something works, not to pinpoint an edit (use `locate` for that).
141
145
  - `prompt` (required): what to find context for.
142
146
  - `file_path` (optional): path substring to restrict results to a subdirectory, module, or specific file.
143
147
  - `limit` (optional): max results (default 15).
148
+ - `workspaceId` (optional): target a specific workspace instead of the local project's. Defaults to the local `setup_workspace` workspace.
144
149
 
145
150
  ### `find_files`
146
151
  Given a natural-language query, returns lightweight file path and architectural role/tag matches — no symbols or code content. Use this for broad file/module discovery (e.g. `"find all the controllers"`).
147
152
  - `prompt` (required): what kind of file to find.
148
153
  - `file_path` (optional): path substring to restrict results to a subdirectory, module, or specific file.
149
154
  - `limit` (optional): max results (default 30).
155
+ - `workspaceId` (optional): target a specific workspace instead of the local project's. Defaults to the local `setup_workspace` workspace.
150
156
 
151
157
  ## Local development
152
158
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codeconductorai/harmony-mcp",
3
- "version": "1.0.9",
3
+ "version": "1.0.11",
4
4
  "type": "module",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -33,6 +33,7 @@
33
33
  "archiver": "^7.0.0",
34
34
  "form-data": "^4.0.0",
35
35
  "jose": "^6.2.3",
36
+ "minimatch": "^5.1.0",
36
37
  "node-fetch": "^3.3.2"
37
38
  }
38
39
  }
package/src/deviceAuth.js CHANGED
@@ -3,16 +3,9 @@ import fs from "fs";
3
3
  import os from "os";
4
4
  import path from "path";
5
5
 
6
- const API_URL = (process.env.API_URL || "https://harmony.codeconductor.ai/").replace(/\/+$/, "");
7
-
8
- const LOG_FILE = path.join(os.tmpdir(), "harmony-mcp.log");
9
- const logStream = fs.createWriteStream(LOG_FILE, { flags: "a" });
6
+ import { log } from "./log.js";
10
7
 
11
- function log(...args) {
12
- const line = `[${new Date().toISOString()}] ${args.join(" ")}\n`;
13
- logStream.write(line);
14
- process.stderr.write(line);
15
- }
8
+ const API_URL = (process.env.API_URL || "https://harmony.codeconductor.ai/").replace(/\/+$/, "");
16
9
 
17
10
  let userToken = null;
18
11
  let userTokenExpiresAt = 0;
@@ -0,0 +1,139 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+ import minimatch from "minimatch";
4
+ import { WORKSPACE_MARKER } from "./workspaceMarker.js";
5
+
6
+ export const EXCLUDED_DIR_NAMES = [
7
+ // General / VCS / IDEs
8
+ ".git", ".svn", ".hg", ".idea", ".vscode", ".settings",
9
+ // JavaScript / Node / Frontend
10
+ "node_modules", "bower_components", ".next", ".nuxt", "dist", "build", "coverage", ".cache",
11
+ // Java / Kotlin / JVM
12
+ "target", "bin", "out", ".gradle", ".mvn",
13
+ // Python
14
+ "__pycache__", ".pytest_cache", ".venv", "venv", ".tox",
15
+ // Go / Rust / C / C++
16
+ "vendor", "pkg", "cmake-build-debug", "cmake-build-release",
17
+ // .NET / C#
18
+ "obj",
19
+ // Secrets / credentials
20
+ ".ssh", ".aws", ".gnupg",
21
+ ];
22
+
23
+ export const EXCLUDED_DIR_SUFFIXES = [".egg-info"];
24
+ export const EXCLUDED_EXTENSIONS = [
25
+ // Compiled / executables / binary formats
26
+ "class", "jar", "war", "ear", "pyc", "pyo", "o", "obj", "exe", "dll", "so", "dylib", "a",
27
+ // Logs & databases
28
+ "log", "sqlite", "sqlite3", "db",
29
+ // Archives
30
+ "zip", "tar", "gz", "7z", "rar",
31
+ // Images / media
32
+ "png", "jpg", "jpeg", "gif", "ico", "svg", "pdf",
33
+ ];
34
+ export const EXCLUDED_EXACT_FILENAMES = [
35
+ ".DS_Store", "Thumbs.db", "package-lock.json", "yarn.lock", "pnpm-lock.yaml",
36
+ ];
37
+
38
+ // Secret-bearing filenames, as glob patterns ("*" only) matched against the basename.
39
+ export const EXCLUDED_FILENAME_GLOBS = [
40
+ ".env", ".env.*", "*.pem", "*.key", "*.p12", "*.pfx", "*.keystore",
41
+ "id_rsa", "id_dsa", "id_ecdsa", "id_ed25519", ".npmrc", ".netrc",
42
+ "credentials.json", "*Credentials.json",
43
+ ];
44
+
45
+ function escapeRegExpLiteral(text) {
46
+ return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
47
+ }
48
+
49
+ // Matches a basename against a glob pattern that only uses "*" as a wildcard.
50
+ function matchesFilenameGlob(name, pattern) {
51
+ if (!pattern.includes("*")) return name === pattern;
52
+ const regex = new RegExp(`^${pattern.split("*").map(escapeRegExpLiteral).join(".*")}$`);
53
+ return regex.test(name);
54
+ }
55
+
56
+ function gitignoreLineToGlobs(rawLine) {
57
+ let pattern = rawLine;
58
+ const dirOnly = pattern.endsWith("/");
59
+ if (dirOnly) pattern = pattern.slice(0, -1);
60
+ if (!pattern) return [];
61
+
62
+ const anchored = pattern.includes("/");
63
+ if (pattern.startsWith("/")) pattern = pattern.slice(1);
64
+ if (!pattern) return [];
65
+
66
+ return anchored
67
+ ? [pattern, `${pattern}/**`]
68
+ : [pattern, `**/${pattern}`, `${pattern}/**`, `**/${pattern}/**`];
69
+ }
70
+
71
+ // Reads .gitignore from the workspace root and expands its rules into glob patterns.
72
+ function loadGitignoreGlobs(workspaceRoot) {
73
+ let contents;
74
+ try {
75
+ contents = fs.readFileSync(path.join(workspaceRoot, ".gitignore"), "utf8");
76
+ } catch {
77
+ return [];
78
+ }
79
+ const globs = [];
80
+ for (const rawLine of contents.split(/\r?\n/)) {
81
+ const line = rawLine.trim();
82
+ if (!line || line.startsWith("#") || line.startsWith("!")) continue;
83
+ globs.push(...gitignoreLineToGlobs(line));
84
+ }
85
+ return globs;
86
+ }
87
+
88
+ // Build the glob ignore list for archiver.glob() from the shared exclusion data above.
89
+ export function buildZipIgnoreGlobs(workspaceRoot = process.cwd()) {
90
+ const globs = [WORKSPACE_MARKER];
91
+ for (const dir of EXCLUDED_DIR_NAMES) {
92
+ globs.push(`${dir}/**`, `**/${dir}/**`);
93
+ }
94
+ for (const suffix of EXCLUDED_DIR_SUFFIXES) {
95
+ globs.push(`*${suffix}/**`, `**/*${suffix}/**`);
96
+ }
97
+ for (const ext of EXCLUDED_EXTENSIONS) {
98
+ globs.push(`*.${ext}`, `**/*.${ext}`);
99
+ }
100
+ for (const name of EXCLUDED_EXACT_FILENAMES) {
101
+ globs.push(name, `**/${name}`);
102
+ }
103
+ for (const pattern of EXCLUDED_FILENAME_GLOBS) {
104
+ globs.push(pattern, `**/${pattern}`);
105
+ }
106
+ globs.push(...loadGitignoreGlobs(workspaceRoot));
107
+ return globs;
108
+ }
109
+
110
+ // Kept in sync with buildZipIgnoreGlobs() so the watcher matches the uploaded snapshot.
111
+ const WATCH_IGNORE_DIRS = new Set(EXCLUDED_DIR_NAMES);
112
+ const WATCH_IGNORE_EXTENSIONS = new Set(EXCLUDED_EXTENSIONS);
113
+ const WATCH_IGNORE_FILENAMES = new Set(EXCLUDED_EXACT_FILENAMES);
114
+
115
+ // .gitignore is read once per process
116
+ let cachedGitignoreGlobs = null;
117
+ function getGitignoreGlobs() {
118
+ if (cachedGitignoreGlobs === null) {
119
+ cachedGitignoreGlobs = loadGitignoreGlobs(process.cwd());
120
+ }
121
+ return cachedGitignoreGlobs;
122
+ }
123
+
124
+ export function shouldIgnore(filePath) {
125
+ const relative = path.relative(process.cwd(), filePath);
126
+ const parts = relative.split(path.sep);
127
+ const base = parts[parts.length - 1];
128
+ if (base === WORKSPACE_MARKER) return true;
129
+ if (WATCH_IGNORE_FILENAMES.has(base)) return true;
130
+ if (EXCLUDED_FILENAME_GLOBS.some((pattern) => matchesFilenameGlob(base, pattern))) return true;
131
+ if (parts.some((part) => WATCH_IGNORE_DIRS.has(part) || EXCLUDED_DIR_SUFFIXES.some((s) => part.endsWith(s)))) {
132
+ return true;
133
+ }
134
+ const posixRelative = parts.join("/");
135
+ if (getGitignoreGlobs().some((glob) => minimatch(posixRelative, glob, { dot: true }))) return true;
136
+ const dotIndex = base.lastIndexOf(".");
137
+ const ext = dotIndex > 0 ? base.slice(dotIndex + 1).toLowerCase() : "";
138
+ return WATCH_IGNORE_EXTENSIONS.has(ext);
139
+ }
@@ -0,0 +1,113 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+
4
+ import { log } from "./log.js";
5
+ import { shouldIgnore } from "./fileFilters.js";
6
+ import { readMarker } from "./workspaceMarker.js";
7
+ import { sendFileUpdate } from "./harmonyClient.js";
8
+
9
+ let fileWatchers = [];
10
+
11
+ // Close every active watcher handle, called on watcher error and process shutdown.
12
+ export function stopFileWatcher() {
13
+ for (const watcher of fileWatchers) {
14
+ try {
15
+ watcher.close();
16
+ } catch {
17
+ // already closed
18
+ }
19
+ }
20
+ fileWatchers = [];
21
+ }
22
+
23
+ // Watch one directory at a time so ignored subtrees (node_modules etc.) skip a watch handle — avoids EMFILE.
24
+ function watchDirectoryTree(dir, onFileChange) {
25
+ let watcher;
26
+ try {
27
+ watcher = fs.watch(dir, { recursive: false }, (eventType, filename) => {
28
+ if (!filename) return;
29
+ const filePath = path.join(dir, filename);
30
+ if (shouldIgnore(filePath)) return;
31
+
32
+ let stat;
33
+ try {
34
+ stat = fs.statSync(filePath);
35
+ } catch {
36
+ if (eventType === "rename") {
37
+ log(`[fileWatcher] Detected removal of ${path.relative(process.cwd(), filePath)} — ` +
38
+ `not propagated to the backend (no delete endpoint available); remote index may be stale for this path.`);
39
+ }
40
+ return;
41
+ }
42
+
43
+ if (stat.isDirectory()) {
44
+ if (eventType === "rename") watchDirectoryTree(filePath, onFileChange);
45
+ return;
46
+ }
47
+
48
+ onFileChange(filePath);
49
+ });
50
+ } catch (err) {
51
+ log(`[fileWatcher] Failed to watch ${dir}: ${err.message}`);
52
+ return;
53
+ }
54
+
55
+ watcher.on("error", (err) => {
56
+ log(`[fileWatcher] Watcher error on ${dir}: ${err.message}. Stopping file watcher.`);
57
+ stopFileWatcher();
58
+ });
59
+ fileWatchers.push(watcher);
60
+
61
+ let entries;
62
+ try {
63
+ entries = fs.readdirSync(dir, { withFileTypes: true });
64
+ } catch {
65
+ return;
66
+ }
67
+ for (const entry of entries) {
68
+ if (!entry.isDirectory()) continue;
69
+ const subDir = path.join(dir, entry.name);
70
+ if (shouldIgnore(subDir)) continue;
71
+ watchDirectoryTree(subDir, onFileChange);
72
+ }
73
+ }
74
+
75
+ // Watch the cwd for file changes and send incremental updates to the backend.
76
+ export function startFileWatcher() {
77
+ if (fileWatchers.length > 0) {
78
+ log("[fileWatcher] Already running.");
79
+ return;
80
+ }
81
+
82
+ const marker = readMarker();
83
+ if (!marker?.workspaceId || !marker?.language || !marker?.buildTool) {
84
+ log("[fileWatcher] Missing workspaceId, language, or buildTool. Skipping fileWatcher.");
85
+ return;
86
+ }
87
+ const { workspaceId, language, buildTool } = marker;
88
+ const debounceMap = new Map();
89
+
90
+ const onFileChange = (filePath) => {
91
+ if (debounceMap.has(filePath)) clearTimeout(debounceMap.get(filePath));
92
+ debounceMap.set(
93
+ filePath,
94
+ setTimeout(() => {
95
+ debounceMap.delete(filePath);
96
+ sendFileUpdate(filePath, workspaceId, language, buildTool);
97
+ }, 50)
98
+ );
99
+ };
100
+
101
+ watchDirectoryTree(process.cwd(), onFileChange);
102
+
103
+ if (fileWatchers.length === 0) {
104
+ log("[fileWatcher] No watch handles could be created; incremental sync is unavailable this session.");
105
+ return;
106
+ }
107
+ log(`[fileWatcher] Watching ${process.cwd()} for file changes (${fileWatchers.length} directories).`);
108
+ }
109
+
110
+ // True if the incremental watcher has at least one active watch handle.
111
+ export function isFileWatcherActive() {
112
+ return fileWatchers.length > 0;
113
+ }