@codeconductorai/harmony-mcp 1.0.23 → 1.0.24

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.23`) 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.24`) 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.23
35
+ claude mcp add harmony -- npx -y @codeconductorai/harmony-mcp@1.0.24
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.23"]
50
+ "args": ["-y", "@codeconductorai/harmony-mcp@1.0.24"]
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.23
61
+ codex mcp add harmony -- npx -y @codeconductorai/harmony-mcp@1.0.24
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.23"]
69
+ args = ["-y", "@codeconductorai/harmony-mcp@1.0.24"]
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.23"]
81
+ "args": ["-y", "@codeconductorai/harmony-mcp@1.0.24"]
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.23"]
98
+ "args": ["-y", "@codeconductorai/harmony-mcp@1.0.24"]
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.23",
3
+ "version": "1.0.24",
4
4
  "type": "module",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -82,6 +82,25 @@ async function zipWorkspace() {
82
82
  });
83
83
  }
84
84
 
85
+ function actionableErrorHint(status, headers) {
86
+ if (status === 401) {
87
+ const wwwAuthenticate = headers.get("www-authenticate");
88
+ return wwwAuthenticate
89
+ ? ` (${wwwAuthenticate})`
90
+ : " (this deployment requires login — call the login tool first, then confirm_login once the user has finished)";
91
+ }
92
+ if (status === 400) {
93
+ return " (the request was rejected as malformed — double-check `prompt` is non-blank and `file_path`/`limit` are the right types, then retry once; don't retry blindly)";
94
+ }
95
+ if (status === 404) {
96
+ return " (workspace not found on the backend — call setup_workspace again; the local marker may be stale)";
97
+ }
98
+ if (status >= 500) {
99
+ return " (backend error, not something a different query will fix — fall back to local tools for this lookup rather than retrying)";
100
+ }
101
+ return "";
102
+ }
103
+
85
104
  // POST /api/code-workspace/{workspaceId}/create — register a new workspace on the backend.
86
105
  export async function setupWorkspace(workspaceId, language, buildTool) {
87
106
  try {
@@ -97,13 +116,7 @@ export async function setupWorkspace(workspaceId, language, buildTool) {
97
116
  log("Setup status:", response.status);
98
117
  log("Setup response:", body);
99
118
  if (!response.ok) {
100
- const wwwAuthenticate = response.headers.get("www-authenticate");
101
- const hint = response.status === 401
102
- ? wwwAuthenticate
103
- ? ` (${wwwAuthenticate})`
104
- : " (this deployment requires login — call the login tool first)"
105
- : "";
106
- throw new Error(`Setup failed: ${response.status} ${body}${hint}`);
119
+ throw new Error(`Setup failed: ${response.status} ${body}${actionableErrorHint(response.status, response.headers)}`);
107
120
  }
108
121
  return {
109
122
  status: response.status,
@@ -294,6 +307,18 @@ export async function pollWorkspaceStatus(workspaceId, { maxWaitMs = 120_000, in
294
307
  return lastStatus;
295
308
  }
296
309
 
310
+ const MAX_RESPONSE_CHARS = 90_000;
311
+ function truncateForAgent(toolName, body) {
312
+ if (body.length <= MAX_RESPONSE_CHARS) return body;
313
+ const truncated = body.slice(0, MAX_RESPONSE_CHARS);
314
+ return `${truncated}\n\n` +
315
+ `[harmony-mcp note: ${toolName}'s response was truncated at ~${Math.round(MAX_RESPONSE_CHARS / 4)} ` +
316
+ `tokens to protect context. Don't assume the cut-off entry is complete or that nothing else ` +
317
+ `matched — narrow the search instead of re-reading this same response: pass a more specific ` +
318
+ `\`file_path\` scope, lower \`limit\`, or sharpen \`prompt\` to a more specific identifier, then ` +
319
+ `call again.]`;
320
+ }
321
+
297
322
  // Shared POST caller for the locate-symbol/search/find-files endpoints — same request/response shape.
298
323
  export async function callHarmonySearchEndpoint(endpointPath, args, workspaceId) {
299
324
  const prompt = args.prompt || args.query;
@@ -319,9 +344,9 @@ export async function callHarmonySearchEndpoint(endpointPath, args, workspaceId)
319
344
  });
320
345
  const body = await response.text();
321
346
  if (!response.ok) {
322
- throw new Error(`${endpointPath} request failed: ${response.status} ${body}`);
347
+ throw new Error(`${endpointPath} request failed: ${response.status} ${body}${actionableErrorHint(response.status, response.headers)}`);
323
348
  }
324
- return body;
349
+ return truncateForAgent(endpointPath, body);
325
350
  }
326
351
 
327
352
  // POST /api/code-workspace/{workspaceId}/bundle — ranked XML context bundle for a prompt.
@@ -345,9 +370,9 @@ export async function fetchContextBundle(workspaceId, prompt) {
345
370
  });
346
371
  const body = await response.text();
347
372
  if (!response.ok) {
348
- throw new Error(`Bundle request failed: ${response.status} ${body}`);
373
+ throw new Error(`Bundle request failed: ${response.status} ${body}${actionableErrorHint(response.status, response.headers)}`);
349
374
  }
350
- return body;
375
+ return truncateForAgent("get_context_bundle", body);
351
376
  }
352
377
 
353
378
  // An empty list is ambiguous (no matches vs. index not ready vs. failed query) — flag it.
@@ -1,13 +1,44 @@
1
1
  import { hasSessionCredential, getWorkspaceToken } from "./deviceAuth.js";
2
2
  import { readMarker } from "./workspaceMarker.js";
3
3
 
4
+ const WHEN_TO_USE = `
5
+ When Harmony helps — reach for it when the task benefits from searching or understanding this
6
+ codebase and what you already have in hand isn't enough:
7
+ - You don't yet know which file(s) or symbol(s) are relevant ("where is X handled", "how does auth
8
+ work here", "find all the controllers").
9
+ - The codebase is large or unfamiliar, or the answer likely spans multiple files you haven't read
10
+ yet, such that chaining several Read/Grep/Glob calls to triangulate it would be slower.
11
+ - You need a fuzzy/semantic match on behavior or intent rather than a literal string ("the retry
12
+ logic", "where prices get rounded") — the kind of query grep/rg would miss or over-return.
13
+ - You want one fast, ranked answer instead of manually exploring the tree.
14
+
15
+ When Harmony is not the right call — prefer your own tools, direct reasoning, or general knowledge
16
+ instead:
17
+ - Simple questions answerable from general knowledge, math, or the current conversation — no
18
+ codebase lookup needed at all.
19
+ - You already know the exact file or symbol (from the user, an earlier result, or a path you can
20
+ already see) — just Read it or Grep for the exact string; that's faster and skips network/auth/
21
+ indexing latency for no benefit.
22
+ - Small, local edits or reasoning fully contained in a file you already have open.
23
+ - The workspace isn't indexed yet, or Harmony just returned empty/stale/irrelevant results for this
24
+ specific lookup — fall back to rg/grep/Read for that lookup rather than retrying Harmony.
25
+ - Writing new code, boilerplate, or general-purpose logic that doesn't depend on this repo's
26
+ existing implementation.
27
+
28
+ These are examples, not an exhaustive checklist. Weigh cost, latency, and whether Harmony is likely
29
+ to beat your own tools for the specific thing you're about to do — the same judgment call you'd make
30
+ between Grep and Read for any other lookup. Nothing here requires calling Harmony when your own
31
+ tools are just as fast, or when the task doesn't touch this codebase at all.
32
+ `.trim();
33
+
4
34
  const QUERY_REFINEMENT = `
5
- Query refinement — before calling context_search, locate, search_code_context, or find_files, judge
6
- whether the user's own wording is already a specific enough \`prompt\`. Skip this whole section for
7
- requests that already name a concrete symbol/class/method/route/file ("find CrudController",
8
- "where is POST /api/v1/index/zip handled") — pass those straight through unchanged. Only vague or
9
- generic requests ("show all controllers", "how does auth work", "find the retry stuff") need
10
- refinement, following these steps in order:
35
+ Query refinement — once you've decided a Harmony call is the right move, before calling
36
+ context_search, locate, search_code_context, or find_files, judge whether the user's own wording is
37
+ already a specific enough \`prompt\`. Skip this whole section for requests that already name a
38
+ concrete symbol/class/method/route/file ("find CrudController", "where is POST /api/v1/index/zip
39
+ handled") — pass those straight through unchanged. Only vague or generic requests ("show all
40
+ controllers", "how does auth work", "find the retry stuff") need refinement, following these steps
41
+ in order:
11
42
  1. Extract identifiers — scan the user's wording for anything that is or implies a concrete symbol,
12
43
  class, method, route, file, or directory name (proper nouns, CamelCase/snake_case tokens, path
13
44
  fragments, HTTP verbs+paths). If something concrete is already there, use it verbatim as (or
@@ -40,48 +71,34 @@ to act on — it doesn't replace them, and it doesn't apply to the setup/auth to
40
71
  `.trim();
41
72
 
42
73
  const ROUTING_RULES = `
43
- MANDATORY DEFAULT — Harmony before your own tools: for ANY task in this project that involves
44
- finding code, understanding how something works, discovering files/modules, or gathering context,
45
- you MUST call the narrowest matching Harmony tool below FIRST, before reaching for Read, Grep,
46
- Glob, rg, find, ls, or any other built-in search/read capability. This is not optional and not just
47
- for the "first call in a session" — it applies every time a new discovery/comprehension need comes
48
- up during the task, not just once. Local tools are the fallback for when Harmony comes up short
49
- (see Trust but verify below), never the default first move.
50
-
51
- Routing — \`context_search\` is the default first call for ANY discovery/comprehension need (finding
52
- code, understanding how something works, discovering files/modules, gathering context). It is
53
- Harmony's newest, best-ranked search endpoint and takes precedence over locate, search_code_context and
54
- find_files — call it first, then only reach for one of those narrower tools if
55
- context_search's result is empty/insufficient or you specifically need one of their specialized output
56
- shapes (e.g. locate's line-number-only anchors for a targeted edit):
57
- - \`context_search\` — try this FIRST. Ranked matching symbols with code snippets, file paths, and
58
- relevance for a natural language query or exact identifier.
59
- - \`locate\` — "which file(s) handle X" / "where is X" for a task you're about to edit. Returns
60
- every matching symbol occurrence (definitions and references) with exact line numbers,
61
- optionally scoped to a file_path once you already know the file.
62
- - \`search_code_context\` — you need to understand or explain how something works: matching
63
- symbols with their code snippets, documentation, and decorators. Not for pinpointing an edit.
64
- - \`find_files\` — broad file/module discovery ("find all the controllers") without needing
65
- symbols or code content.
74
+ Choosing among Harmony's tools — once Harmony is the right move for a lookup, pick the narrowest fit:
75
+ - \`context_search\` — usually the best starting point for open-ended discovery/comprehension: ranked
76
+ matching symbols with code snippets, file paths, and relevance for a natural language query or
77
+ exact identifier.
78
+ - \`locate\` — "which file(s) handle X" / "where is X" for a task you're about to edit. Returns every
79
+ matching symbol occurrence (definitions and references) with exact line numbers, optionally scoped
80
+ to a file_path once you already know the file.
81
+ - \`search_code_context\` — you need to understand or explain how something works: matching symbols
82
+ with their code snippets, documentation, and decorators. Not for pinpointing an edit.
83
+ - \`find_files\` — broad file/module discovery ("find all the controllers") without needing symbols
84
+ or code content.
66
85
  - \`get_context_bundle\` — broader contextual understanding for a task or question, not a specific
67
86
  edit location. Returns a fuller XML context bundle for a prompt.
68
87
 
69
- High availability: \`context_search\` is the always-on default for every discovery/comprehension need
70
- that comes up during a task — call it again each time a new one arises, not just once per session or
71
- once per task. Composing fallback input: when context_search comes up short and you drop down to one
72
- of the narrower tools above, never just resend the same raw user query — carry forward the specific
73
- symbols, identifiers, and file paths context_search's response already surfaced, and combine THOSE
74
- with the user's original query when building the fallback tool's \`prompt\` (and \`file_path\` where
75
- applicable). The fallback call should read as "user's intent, sharpened by what context_search already
76
- found," not a blind retry of the same input.
77
-
78
- Carry forward a good result: once context_search's response gives you a concrete file_path, symbol
79
- name, or other specific detail relevant to the task, treat it as ground truth for every tool call
80
- that follows in that task — don't re-search for it, re-guess it, or fall back to a vaguer version of
81
- it. This isn't limited to falling back to one of the narrower Harmony tools above: it applies equally
82
- when you next call locate/search_code_context/find_files scoped to that file_path, and when you move
83
- on to Read, an edit, or any other tool — use the exact path/identifier context_search already
84
- returned rather than deriving your own guess at that point.
88
+ If context_search's result is empty or insufficient, or you specifically need one of the other
89
+ tools' output shape (e.g. locate's line-number-only anchors), fall back to that narrower tool rather
90
+ than retrying context_search. Composing that fallback: never just resend the same raw user query —
91
+ carry forward the specific symbols, identifiers, and file paths context_search's response already
92
+ surfaced, and combine THOSE with the user's original query when building the fallback tool's
93
+ \`prompt\` (and \`file_path\` where applicable). The fallback call should read as "user's intent,
94
+ sharpened by what context_search already found," not a blind retry of the same input.
95
+
96
+ Carry forward a good result: once a Harmony response gives you a concrete file_path, symbol name, or
97
+ other specific detail relevant to the task, treat it as ground truth for every tool call that
98
+ follows in that task — don't re-search for it, re-guess it, or fall back to a vaguer version of it.
99
+ This applies equally when you next call another Harmony tool scoped to that file_path, and when you
100
+ move on to Read, an edit, or any other tool — use the exact path/identifier already returned rather
101
+ than deriving your own guess at that point.
85
102
 
86
103
  Populate \`file_path\` whenever it's known: context_search, locate, search_code_context, and
87
104
  find_files all accept the same optional \`file_path\` field to scope results to a subdirectory,
@@ -90,13 +107,14 @@ earlier context_search/locate/find_files result this task, stated explicitly by
90
107
  established earlier in the conversation — pass it into that call's \`file_path\`, don't leave it
91
108
  blank and rely on the \`prompt\` text alone to imply scope. Only omit \`file_path\` when no such path
92
109
  is actually known yet; never fill it with a guessed path (see refinement step 3 above).
110
+ `.trim();
93
111
 
112
+ const TRUST_BUT_VERIFY = `
94
113
  Trust but verify: Harmony's index can be stale, incomplete, or briefly out of date relative to the
95
114
  working tree. If a result is empty, errors, looks stale (references code that no longer exists), or
96
- is otherwise insufficient, don't retry the same call — fall back immediately to local tools (rg,
97
- Read, etc.) for that specific lookup only; it doesn't lift the mandate for the next discovery need.
98
- After a good Harmony result, proceed straight to the edit/answer — don't re-derive context you just
99
- fetched, and don't Read() a whole file the tool already covered.
115
+ is otherwise insufficient, don't retry the same call — fall back to local tools (rg, Read, etc.) for
116
+ that specific lookup only. After a good Harmony result, proceed straight to the edit/answer — don't
117
+ re-derive context you just fetched, and don't Read() a whole file the tool already covered.
100
118
  `.trim();
101
119
 
102
120
  const EFFICIENCY_RULES = `
@@ -165,18 +183,18 @@ export function buildServerInstructions() {
165
183
  const ready = Boolean(authed && marker?.setup?.done && marker?.upload?.done);
166
184
 
167
185
  const sections = [
168
- "Harmony MCP indexes this codebase on a remote backend and lets you retrieve targeted context " +
169
- "or locate edit points without reading whole files. Wherever Harmony is applicable to what " +
170
- "you're currently doing, it is the required first move for that lookup, ahead of your own " +
171
- "file-search/read tools — see the mandate below, not a one-time setup step to satisfy once.",
186
+ "Harmony MCP indexes this codebase on a remote backend and can retrieve targeted code context " +
187
+ "(matching symbols, snippets, file locations) without reading whole files or chaining several " +
188
+ "local searches. It's one tool among your others, not a required first step — decide per task " +
189
+ "whether it's the better fit; see \"When Harmony helps\" below for concrete guidance.",
172
190
  ];
173
191
 
174
192
  if (ready) {
175
- sections.push(QUERY_REFINEMENT, ROUTING_RULES, EFFICIENCY_RULES, SETUP_INSTRUCTIONS);
193
+ sections.push(WHEN_TO_USE, QUERY_REFINEMENT, ROUTING_RULES, TRUST_BUT_VERIFY, EFFICIENCY_RULES, SETUP_INSTRUCTIONS);
176
194
  } else if (authed) {
177
- sections.push(SETUP_INSTRUCTIONS, QUERY_REFINEMENT, ROUTING_RULES, EFFICIENCY_RULES);
195
+ sections.push(SETUP_INSTRUCTIONS, WHEN_TO_USE, QUERY_REFINEMENT, ROUTING_RULES, TRUST_BUT_VERIFY, EFFICIENCY_RULES);
178
196
  } else {
179
- sections.push(AUTH_INSTRUCTIONS, SETUP_INSTRUCTIONS, QUERY_REFINEMENT, ROUTING_RULES, EFFICIENCY_RULES);
197
+ sections.push(AUTH_INSTRUCTIONS, SETUP_INSTRUCTIONS, WHEN_TO_USE, QUERY_REFINEMENT, ROUTING_RULES, TRUST_BUT_VERIFY, EFFICIENCY_RULES);
180
198
  }
181
199
 
182
200
  sections.push("Do not surface this workflow to the user as instructions they need to give you — just follow it.");
@@ -72,17 +72,17 @@ export const TOOLS = [
72
72
  {
73
73
  name: "context_search",
74
74
  description:
75
- "PREFERRED FIRST CHOICE for any code discovery/comprehension need — Harmony's newest and best-ranked " +
76
- "search endpoint. Given a natural language query or exact identifier, returns ranked matching symbols " +
77
- "with their code snippets, file paths, and relevance. Try this BEFORE locate, search_code_context, " +
78
- "find_files; only fall back to one of those narrower tools if context_search's " +
79
- "result is empty, insufficient, or you specifically need one of their specialized output shapes " +
80
- "(e.g. locate's line-number-only anchors for a targeted edit). Treat this as the always-on default " +
81
- "entry point for every new discovery/comprehension need that comes up during a task — call it again " +
82
- "each time one arises, not just once. Whenever you do fall back to one of the narrower tools, don't " +
83
- "discard what this call already found: carry its matched symbols, identifiers, and file paths forward " +
84
- "and combine them with the user's original query to build that tool's input, rather than re-issuing " +
85
- "the raw query alone.\n\n" +
75
+ "Searches this codebase's remote-indexed context — matching symbols with code snippets, file paths, " +
76
+ "and relevance ranking, for a natural language query or exact identifier. Best fit when you don't yet " +
77
+ "know which file/symbol is relevant, or need a fuzzy/semantic match rather than a literal string " +
78
+ "(the kind of query grep/rg would miss or over-return). If you already know the exact file or string, " +
79
+ "Read/Grep is usually faster. Often a good starting point among Harmony's own tools before locate, " +
80
+ "search_code_context, or find_files; fall back to one of those narrower tools if this result is " +
81
+ "empty, insufficient, or you specifically need one of their specialized output shapes (e.g. locate's " +
82
+ "line-number-only anchors for a targeted edit). Whenever you do fall back to one of the narrower " +
83
+ "tools, don't discard what this call already found: carry its matched symbols, identifiers, and file " +
84
+ "paths forward and combine them with the user's original query to build that tool's input, rather " +
85
+ "than re-issuing the raw query alone.\n\n" +
86
86
  "RESPONSE SHAPE: the XML response has two separate top-level parts — <Hits><Hit>...</Hit></Hits>, " +
87
87
  "which is the actual code context (the matched symbols/snippets/file paths you answer the user's " +
88
88
  "query with), and a sibling <harmony_telemetry> block (filesBundledCount, graphEdgesResolved, " +