@codeconductorai/harmony-mcp 1.0.30 → 1.0.31

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. The commands below pin an exact version (`@1.0.30`) 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.
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.31`) 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@1.0.30
35
+ claude mcp add harmony -- npx -y @codeconductorai/harmony-mcp@1.0.31
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@1.0.30"]
50
+ "args": ["-y", "@codeconductorai/harmony-mcp@1.0.31"]
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@1.0.30
61
+ codex mcp add harmony -- npx -y @codeconductorai/harmony-mcp@1.0.31
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@1.0.30"]
69
+ args = ["-y", "@codeconductorai/harmony-mcp@1.0.31"]
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@1.0.30"]
81
+ "args": ["-y", "@codeconductorai/harmony-mcp@1.0.31"]
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@1.0.30"]
98
+ "args": ["-y", "@codeconductorai/harmony-mcp@1.0.31"]
99
99
  }
100
100
  }
101
101
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codeconductorai/harmony-mcp",
3
- "version": "1.0.30",
3
+ "version": "1.0.31",
4
4
  "type": "module",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -124,7 +124,27 @@ export async function setupWorkspace(workspaceId, language, buildTool) {
124
124
  }
125
125
 
126
126
  // POST /api/v1/index/zip — upload a zipped snapshot of the workspace for full indexing.
127
- export async function uploadWorkspace(zipPath, workspaceId, language, buildTool, phase = "LEXICAL") {
127
+ // Thrown when the backend rejects an upload because it contains hardcoded secrets (HTTP 422
128
+ // SECRETS_DETECTED). `details` is the backend's response body: masked findings + how to proceed.
129
+ export class SecretsDetectedError extends Error {
130
+ constructor(details) {
131
+ super(details?.message || "Upload blocked: potential hardcoded secrets detected.");
132
+ this.name = "SecretsDetectedError";
133
+ this.details = details;
134
+ }
135
+ }
136
+
137
+ function parseSecretsDetected(status, body) {
138
+ if (status !== 422) return null;
139
+ try {
140
+ const parsed = JSON.parse(body);
141
+ return parsed?.error === "SECRETS_DETECTED" ? parsed : null;
142
+ } catch {
143
+ return null;
144
+ }
145
+ }
146
+
147
+ export async function uploadWorkspace(zipPath, workspaceId, language, buildTool, phase = "LEXICAL", allowSecrets = false) {
128
148
  try {
129
149
  const form = new FormData();
130
150
 
@@ -138,6 +158,8 @@ export async function uploadWorkspace(zipPath, workspaceId, language, buildTool,
138
158
  form.append("language", language);
139
159
  if (buildTool) form.append("buildTool", buildTool);
140
160
  form.append("phase", phase);
161
+ // Only ever true after the user agreed to index despite detected secrets.
162
+ if (allowSecrets) form.append("allowSecrets", "true");
141
163
 
142
164
  // Field name must be "file" per @RequestPart("file")
143
165
  form.append("file", fs.createReadStream(zipPath), { filename: "workspace.zip", contentType: "application/zip" });
@@ -153,6 +175,10 @@ export async function uploadWorkspace(zipPath, workspaceId, language, buildTool,
153
175
  const body = await response.text();
154
176
  log("Upload status:", response.status);
155
177
  log("Upload response:", body);
178
+ const secretsDetected = parseSecretsDetected(response.status, body);
179
+ if (secretsDetected) {
180
+ throw new SecretsDetectedError(secretsDetected);
181
+ }
156
182
  if (!response.ok) {
157
183
  throw new Error(`Upload failed: ${response.status} ${body}${traceSuffix()}`);
158
184
  }
@@ -162,6 +188,7 @@ export async function uploadWorkspace(zipPath, workspaceId, language, buildTool,
162
188
  response: body,
163
189
  };
164
190
  } catch (error) {
191
+ if (error instanceof SecretsDetectedError) throw error;
165
192
  log("Upload Error:", error);
166
193
  let msg = error?.message || "Unknown upload error";
167
194
  if (error.code) msg += `\nError code: ${error.code}`;
@@ -170,7 +197,7 @@ export async function uploadWorkspace(zipPath, workspaceId, language, buildTool,
170
197
  }
171
198
 
172
199
  // Ensure the workspace is set up and uploaded, re-uploading if the local commit has moved on since the last upload.
173
- export async function ensureWorkspaceUploaded(language, buildTool) {
200
+ export async function ensureWorkspaceUploaded(language, buildTool, allowSecrets = false) {
174
201
  let marker = readMarker();
175
202
  let workspaceId;
176
203
 
@@ -215,7 +242,7 @@ export async function ensureWorkspaceUploaded(language, buildTool) {
215
242
  // Indexing is lexical-only — no embedding/semantic pass on the backend.
216
243
  const phase = "LEXICAL";
217
244
  const zipFile = await zipWorkspace();
218
- const result = await uploadWorkspace(zipFile, workspaceId, lang, tool, phase);
245
+ const result = await uploadWorkspace(zipFile, workspaceId, lang, tool, phase, allowSecrets);
219
246
  marker.upload = { done: true, phase, status: result.status, response: result.response };
220
247
  marker.commitHash = currentCommit;
221
248
  writeMarker(marker);
@@ -320,14 +347,14 @@ export async function callHarmonySearchEndpoint(endpointPath, args, workspaceId)
320
347
 
321
348
  // Shared POST caller for the newer single-purpose endpoints (query-module-dependencies,
322
349
  // outline-file-symbols, get-repository-map) — identical JSON-in/XML-out shape, different path/body.
323
- async function callHarmonyJsonEndpoint(endpointPath, requestBody, workspaceId) {
350
+ async function callHarmonyJsonEndpoint(endpointPath, requestBody, workspaceId, accept = "application/xml") {
324
351
  log(`[${endpointPath}] Request body:`, JSON.stringify(requestBody, null, 2));
325
352
 
326
353
  const response = await fetch(`${API_URL}/api/code-workspace/${workspaceId}/${endpointPath}`, {
327
354
  method: "POST",
328
355
  headers: {
329
356
  "Content-Type": "application/json",
330
- Accept: "application/xml",
357
+ Accept: accept,
331
358
  ...(await authHeader(workspaceId)),
332
359
  },
333
360
  body: JSON.stringify(requestBody),
@@ -371,6 +398,19 @@ export async function callHarmonyRepositoryMap(args, workspaceId) {
371
398
  }, workspaceId);
372
399
  }
373
400
 
401
+ // POST /api/code-workspace/{workspaceId}/security-scan — on-demand scan of the workspace's uploaded
402
+ // code (secrets, Java security patterns, endpoint auth, data exposure, unused code). JSON in/out;
403
+ // findings already have secret values masked.
404
+ export async function callHarmonySecurityScan(args, workspaceId) {
405
+ return callHarmonyJsonEndpoint("security-scan", {
406
+ file_path: args.file_path,
407
+ checks: args.checks,
408
+ min_severity: args.min_severity,
409
+ limit: args.limit,
410
+ workspaceMetadata: buildWorkspaceMetadata(workspaceId),
411
+ }, workspaceId, "application/json");
412
+ }
413
+
374
414
  // POST /api/v1/index/files — used by the file watcher for incremental updates.
375
415
  export async function sendFileUpdate(filePath, workspaceId, language, buildTool) {
376
416
  try {
package/src/server.js CHANGED
@@ -27,6 +27,8 @@ import {
27
27
  callHarmonyModuleDependencies,
28
28
  callHarmonyFileOutline,
29
29
  callHarmonyRepositoryMap,
30
+ callHarmonySecurityScan,
31
+ SecretsDetectedError,
30
32
  } from "./harmonyClient.js";
31
33
  import { buildServerInstructions } from "./serverInstructions.js";
32
34
  import { TOOLS } from "./toolSchemas.js";
@@ -184,7 +186,7 @@ function describeIndexOutcome(indexStatus, workspaceId) {
184
186
  }
185
187
 
186
188
  async function handleSetupWorkspace(args, extra) {
187
- const { language, buildTool } = args;
189
+ const { language, buildTool, allowSecrets } = args;
188
190
  const startedAt = Date.now();
189
191
  const remainingBudgetMs = () => Math.max(0, SETUP_WORKSPACE_TIME_BUDGET_MS - (Date.now() - startedAt));
190
192
  const onPollTick = (indexStatus, elapsedMs) =>
@@ -226,8 +228,26 @@ async function handleSetupWorkspace(args, extra) {
226
228
  await sendProgress(extra, `Zipping and uploading "${getProjectName()}" to the backend...`);
227
229
  let resynced = false;
228
230
  try {
229
- ({ resynced } = await ensureWorkspaceUploaded(language, buildTool));
231
+ ({ resynced } = await ensureWorkspaceUploaded(language, buildTool, allowSecrets === true));
230
232
  } catch (error) {
233
+ if (error instanceof SecretsDetectedError) {
234
+ const d = error.details;
235
+ return jsonContent({
236
+ error: "secrets_detected",
237
+ message: d.message,
238
+ totalFindings: d.totalFindings,
239
+ findings: d.findings,
240
+ truncated: d.truncated,
241
+ bypassAllowed: d.bypassAllowed,
242
+ howToProceed: d.howToProceed,
243
+ nextStep: d.bypassAllowed
244
+ ? "Show these findings to the user (file, line, type, masked snippet) and ask whether to move the " +
245
+ "secrets out of the code first or index anyway. Call setup_workspace again with allowSecrets: true " +
246
+ "ONLY after the user explicitly agrees in chat — never on your own initiative or before asking."
247
+ : "The server does not allow bypassing this check. The user must remove the secrets, then call setup_workspace again.",
248
+ user: getCurrentUsername(),
249
+ }, true);
250
+ }
231
251
  return jsonContent({
232
252
  error: "setup_workspace_failed",
233
253
  message: error?.message || "Unknown setup error",
@@ -300,6 +320,13 @@ async function handleRepositoryMap(args) {
300
320
  return textContent(body);
301
321
  }
302
322
 
323
+ async function handleSecurityScan(args) {
324
+ const workspaceId = resolveWorkspaceId(args);
325
+ const body = await callHarmonySecurityScan(args, workspaceId);
326
+ log(`[security_scan] response ${body.length} chars`);
327
+ return textContent(body);
328
+ }
329
+
303
330
  const TOOL_HANDLERS = {
304
331
  login: handleLogin,
305
332
  confirm_login: handleConfirmLogin,
@@ -309,6 +336,7 @@ const TOOL_HANDLERS = {
309
336
  query_module_dependencies: handleModuleDependencies,
310
337
  outline_file_symbols: handleFileOutline,
311
338
  get_repository_map: handleRepositoryMap,
339
+ security_scan: handleSecurityScan,
312
340
  };
313
341
 
314
342
  const AUTH_EXEMPT_TOOLS = new Set(["login", "confirm_login", "setup_workspace"]);
@@ -185,11 +185,26 @@ Workspace setup — before the first search/locate/context call in a project:
185
185
  after a short wait to re-check — repeat until \`ready\` is true. If it instead reports only
186
186
  partially finished (symbols failed/skipped — the symbol-level tools may return incomplete or no
187
187
  results) or failed outright, relay that instead of retrying blindly.
188
+ - If it returns error "secrets_detected", the backend found potential hardcoded secrets and stored
189
+ nothing. Show the user the listed findings (file, line, type, masked snippet) and ask whether to
190
+ move the secrets out of the code first, or index the workspace with them anyway. Only after the
191
+ user explicitly agrees in chat to index with the secrets, call \`setup_workspace\` again with
192
+ allowSecrets: true. Never set allowSecrets on your own initiative or before asking. If the
193
+ response says bypass is not allowed, the server forbids it: the secrets must be removed first.
194
+ `.trim();
195
+
196
+ // Ready state: setup is done, so the full setup guide above is dead weight in every session's
197
+ // prompt. Keep only the re-sync hint; secrets-consent rules travel in the secrets_detected
198
+ // response itself and security_scan guidance in that tool's (deferred) description.
199
+ const READY_SETUP_NOTE = `
200
+ Workspace is set up and indexed. If the code changed outside the file watcher (e.g. a branch
201
+ switch), call \`setup_workspace\` again — it only re-uploads when something changed. If it returns
202
+ "secrets_detected", follow that response's nextStep exactly.
188
203
  `.trim();
189
204
 
190
205
  const AUTH_INSTRUCTIONS = `
191
- Auth gate — context_search, locate, query_module_dependencies, outline_file_symbols, and
192
- get_repository_map all
206
+ Auth gate — context_search, locate, query_module_dependencies, outline_file_symbols,
207
+ get_repository_map, and security_scan all
193
208
  return a "not authenticated" error until login has succeeded; run the login flow below before
194
209
  using them. setup_workspace is the one exception: call it directly even before logging in — it
195
210
  uses the login session when one exists, but some deployments authenticate the workspace
@@ -217,7 +232,7 @@ export function buildServerInstructions() {
217
232
  ];
218
233
 
219
234
  if (ready) {
220
- sections.push(WHEN_TO_USE, QUERY_REFINEMENT, ROUTING_RULES, TRUST_BUT_VERIFY, EFFICIENCY_RULES, SETUP_INSTRUCTIONS);
235
+ sections.push(WHEN_TO_USE, QUERY_REFINEMENT, ROUTING_RULES, TRUST_BUT_VERIFY, EFFICIENCY_RULES, READY_SETUP_NOTE);
221
236
  } else if (authed) {
222
237
  sections.push(SETUP_INSTRUCTIONS, WHEN_TO_USE, QUERY_REFINEMENT, ROUTING_RULES, TRUST_BUT_VERIFY, EFFICIENCY_RULES);
223
238
  } else {
@@ -64,6 +64,13 @@ export const TOOLS = [
64
64
  "Build tool (e.g. MAVEN, GRADLE, NPM). Required the first time; can be omitted on a retry, since " +
65
65
  "it's remembered from the workspace's prior setup call.",
66
66
  },
67
+ allowSecrets: {
68
+ type: "boolean",
69
+ description:
70
+ "Index the workspace even though the backend detected hardcoded secrets in it. Only set to true " +
71
+ "after a previous call returned error \"secrets_detected\" AND the user has explicitly agreed in " +
72
+ "chat to index the code with those secrets. Never set it otherwise.",
73
+ },
67
74
  },
68
75
  required: [],
69
76
  },
@@ -239,4 +246,57 @@ export const TOOLS = [
239
246
  required: [],
240
247
  },
241
248
  },
249
+ {
250
+ name: "security_scan",
251
+ description:
252
+ "Scans the indexed workspace's code on the backend for security and code-quality issues and returns " +
253
+ "findings sorted most severe first (rule, severity, CWE/OWASP, file:line, message, snippet, " +
254
+ "recommendation). Checks: SECRETS (hardcoded passwords/API keys/tokens/private keys, every language), " +
255
+ "SECURITY (Java SQL injection, command injection, insecure deserialization, XXE, weak crypto, insecure " +
256
+ "Random), ENDPOINT_AUTH (Spring routes reachable without authentication, or privileged routes left " +
257
+ "public), DATA_EXPOSURE (Java sensitive values in logs/console, stack traces sent to clients), " +
258
+ "UNUSED_CODE (Java unused imports/private fields/private methods), DEPENDENCIES (third-party libraries " +
259
+ "in pom.xml/build.gradle/package(-lock).json/requirements.txt/poetry.lock/*.csproj/go.mod with known " +
260
+ "vulnerabilities from OSV.dev, each with the version that fixes it). Use it when the user asks to scan, " +
261
+ "audit or review the code for security issues or vulnerable/outdated dependencies, and again after fixing " +
262
+ "to confirm. Read the response's warnings (e.g. dependencies not checked). Findings are " +
263
+ "static-analysis heuristics: verify each in the code before changing it. Secret values are always " +
264
+ "masked; never try to recover them. Covers the code as last uploaded/synced to the backend. " +
265
+ "Reporting: summarise by severity, then list findings most severe first (rule, path:line, message); " +
266
+ "narrow follow-ups with checks / min_severity / file_path instead of re-running everything; say when a " +
267
+ "finding looks like a false positive. Fixing: move a secret to an environment variable or secrets " +
268
+ "manager reference (e.g. ${DB_PASSWORD}) rather than deleting the configuration, and tell the user to " +
269
+ "rotate it since it was committed. For VULNERABLE_DEPENDENCY, change the declared version (or the " +
270
+ "parent/BOM/lockfile that controls it), flag possible breaking changes on major-version jumps, and " +
271
+ "suggest rebuilding and running tests. After edits, give the file watcher a moment (or call " +
272
+ "setup_workspace) before re-scanning to confirm the findings are gone.",
273
+ inputSchema: {
274
+ type: "object",
275
+ properties: {
276
+ file_path: {
277
+ type: "string",
278
+ description:
279
+ "Optional case-insensitive path substring restricting reported findings to a subdirectory, module, " +
280
+ "or file (e.g. 'src/main/java/com/acme/web'). Endpoint auth still reads the whole project's " +
281
+ "security config.",
282
+ },
283
+ checks: {
284
+ type: "array",
285
+ items: { type: "string", enum: ["SECRETS", "SECURITY", "ENDPOINT_AUTH", "DATA_EXPOSURE", "UNUSED_CODE", "DEPENDENCIES"] },
286
+ description: "Optional subset of checks to run. Omit to run all.",
287
+ },
288
+ min_severity: {
289
+ type: "string",
290
+ enum: ["CRITICAL", "HIGH", "MEDIUM", "LOW", "INFO"],
291
+ description: "Optional lowest severity to report, e.g. HIGH to skip MEDIUM/LOW findings.",
292
+ },
293
+ limit: {
294
+ type: "number",
295
+ description: "Maximum findings to list (default 50, max 500). Totals by severity and rule are always returned.",
296
+ },
297
+ workspaceId: WORKSPACE_ID_PROPERTY,
298
+ },
299
+ required: [],
300
+ },
301
+ },
242
302
  ];