@codeconductorai/harmony-mcp 1.0.11 → 1.0.13
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 +52 -2
- package/package.json +1 -1
- package/src/deviceAuth.js +8 -3
- package/src/fileFilters.js +2 -0
- package/src/server.js +3 -3
- package/src/serverInstructions.js +19 -3
- package/src/toolSchemas.js +52 -5
package/README.md
CHANGED
|
@@ -108,7 +108,7 @@ After adding the server and restarting your client:
|
|
|
108
108
|
1. **`login`** — starts a device-flow login and returns a URL to open in your browser.
|
|
109
109
|
2. Finish logging in, then tell the agent you're done so it can call **`confirm_login`** to complete authentication. The session is cached at `~/.harmony-mcp/session.json`, so you won't need to log in again until it expires.
|
|
110
110
|
3. **`setup_workspace`** — registers the current project (`language` and `buildTool` required the first time) and fully indexes it (zips and uploads the codebase) in one call. It's idempotent, so calling it again once setup and indexing have completed is a cheap no-op; if it fails partway, calling it again retries just the incomplete step. Once indexing succeeds, a background file watcher pushes incremental updates to the backend as you edit files.
|
|
111
|
-
4. Use **`locate`**, **`search_code_context`**, **`find_files`**, or **`get_context_bundle`**
|
|
111
|
+
4. Use **`context_search`** first to pull relevant code context for a prompt — it's Harmony's newest, best-ranked search endpoint, always available as the default entry point for every discovery need in a task, and takes precedence over the others below. Fall back to **`locate`**, **`search_code_context`**, **`get_symbol_context`**, **`find_files`**, **`find_related_tests`**, or **`get_context_bundle`** only if it comes up short or you need one of their specialized output shapes — and when you do, feed the fallback tool a combination of the user's original query and the symbols/identifiers/file paths `context_search` already surfaced, not the raw query on its own. Use **`remember_task_state`** to persist facts/decisions/todos/warnings across a task.
|
|
112
112
|
|
|
113
113
|
Workspace state (workspace ID, language, build tool, setup/upload status) is cached in a `.harmony_workspace.json` marker file in the project root.
|
|
114
114
|
|
|
@@ -129,8 +129,29 @@ Registers the current project as a workspace on the backend and fully indexes it
|
|
|
129
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
130
|
|
|
131
131
|
### `get_context_bundle`
|
|
132
|
-
Retrieves a ranked XML context bundle of the most relevant code for a prompt
|
|
132
|
+
Retrieves a ranked XML context bundle of the most relevant code for a prompt, including deterministic
|
|
133
|
+
(non-LLM) `guidance` (requirement facets, edit/inspect/test targets, risk checks, suggested verification
|
|
134
|
+
commands), a locally-counted token `budget` (with truncation applied if the ranked results exceed it),
|
|
135
|
+
an `index_state` snapshot (indexed file/symbol/relation counts and last-indexed time), and any
|
|
136
|
+
`memories` recorded for the given `taskId`.
|
|
133
137
|
- `prompt` (required): natural-language question or instruction.
|
|
138
|
+
- `taskId` (optional): pass the same `taskId` used with `remember_task_state` to include those memories.
|
|
139
|
+
- `workspaceId` (optional): target a specific workspace instead of the local project's. Defaults to the local `setup_workspace` workspace.
|
|
140
|
+
|
|
141
|
+
### `context_search`
|
|
142
|
+
PREFERRED FIRST CHOICE for any code discovery/comprehension need — Harmony's newest and best-ranked
|
|
143
|
+
search endpoint. Given a natural-language query or exact identifier, returns ranked matching symbols
|
|
144
|
+
with their code snippets, file paths, and relevance. Takes precedence over `locate`,
|
|
145
|
+
`search_code_context`, `find_files`, and `get_context_bundle`; only fall back to one of those if
|
|
146
|
+
`context_search`'s result is empty/insufficient or you specifically need one of their specialized
|
|
147
|
+
output shapes (e.g. `locate`'s line-number-only anchors for a targeted edit). Treat it as the
|
|
148
|
+
always-on default entry point for every new discovery/comprehension need that comes up during a
|
|
149
|
+
task — call it again each time, not just once. When a fallback tool is used afterward, its input
|
|
150
|
+
should combine the user's original query with the symbols/identifiers/file paths this call already
|
|
151
|
+
surfaced, rather than repeating the same raw query unchanged.
|
|
152
|
+
- `prompt` (required): natural-language query or exact identifier to find context for.
|
|
153
|
+
- `file_path` (optional): path substring to restrict results to a subdirectory, module, or specific file.
|
|
154
|
+
- `limit` (optional): max results; the backend applies its own default if omitted.
|
|
134
155
|
- `workspaceId` (optional): target a specific workspace instead of the local project's. Defaults to the local `setup_workspace` workspace.
|
|
135
156
|
|
|
136
157
|
### `locate`
|
|
@@ -154,6 +175,35 @@ Given a natural-language query, returns lightweight file path and architectural
|
|
|
154
175
|
- `limit` (optional): max results (default 30).
|
|
155
176
|
- `workspaceId` (optional): target a specific workspace instead of the local project's. Defaults to the local `setup_workspace` workspace.
|
|
156
177
|
|
|
178
|
+
### `get_symbol_context`
|
|
179
|
+
Like `search_code_context`, but each matched symbol's file is also enriched with one-hop import
|
|
180
|
+
relationships and probable test files, derived from the backend's file-relationship graph (import
|
|
181
|
+
edges, mirrored test-path naming, bounded git co-change). Prefer this over `search_code_context` when
|
|
182
|
+
you're about to edit and need to know what else touches the file.
|
|
183
|
+
- `prompt` (required): natural-language query or unique identifier to find context for.
|
|
184
|
+
- `file_path` (optional): path substring to restrict results to a subdirectory, module, or specific file.
|
|
185
|
+
- `limit` (optional): max results (default 10).
|
|
186
|
+
- `workspaceId` (optional): target a specific workspace instead of the local project's. Defaults to the local `setup_workspace` workspace.
|
|
187
|
+
|
|
188
|
+
### `find_related_tests`
|
|
189
|
+
Given a file path, returns test files related to it via mirrored test-path naming (e.g.
|
|
190
|
+
`src/foo.py` ↔ `tests/test_foo.py`) or bounded git co-change history, falling back to a lexical
|
|
191
|
+
`primary_role: test` search when the workspace has no relationship-graph edges for it yet (e.g. right
|
|
192
|
+
after a fresh index). Unlike the other search tools, this takes `file_path`, not a natural-language `prompt`.
|
|
193
|
+
- `file_path` (required): the file (or a substring uniquely identifying it) to find related tests for.
|
|
194
|
+
- `limit` (optional): max results (default 10).
|
|
195
|
+
- `workspaceId` (optional): target a specific workspace instead of the local project's. Defaults to the local `setup_workspace` workspace.
|
|
196
|
+
|
|
197
|
+
### `remember_task_state`
|
|
198
|
+
Records an explicit fact, decision, todo, or warning against a `taskId`, optionally with `evidence`
|
|
199
|
+
(`path:line` references). Recalled later via `get_context_bundle`'s `taskId` parameter — this does not
|
|
200
|
+
affect search/locate ranking directly, it's recall-on-demand within the same task.
|
|
201
|
+
- `taskId` (required): identifier grouping this memory with others from the same task/session.
|
|
202
|
+
- `content` (required): the memory itself, in plain language.
|
|
203
|
+
- `memoryType` (optional): one of `fact`, `decision`, `todo`, `warning` (default `fact`).
|
|
204
|
+
- `evidence` (optional): array of `path:line` references supporting this memory.
|
|
205
|
+
- `workspaceId` (optional): target a specific workspace instead of the local project's. Defaults to the local `setup_workspace` workspace.
|
|
206
|
+
|
|
157
207
|
## Local development
|
|
158
208
|
|
|
159
209
|
```bash
|
package/package.json
CHANGED
package/src/deviceAuth.js
CHANGED
|
@@ -134,10 +134,15 @@ export async function pollDeviceLogin(timeoutSeconds = 300) {
|
|
|
134
134
|
pendingDeviceCode = null;
|
|
135
135
|
|
|
136
136
|
const claims = decodeJwtPayload(accessToken);
|
|
137
|
+
const sub = field(data, "sub", "sub") || claims?.sub;
|
|
138
|
+
const email = field(data, "email", "email") || claims?.email || null;
|
|
139
|
+
const givenName = field(data, "givenName", "given_name") || claims?.given_name;
|
|
140
|
+
const familyName = field(data, "familyName", "family_name") || claims?.family_name;
|
|
141
|
+
const fullName = [givenName, familyName].filter(Boolean).join(" ");
|
|
137
142
|
loggedInUser = {
|
|
138
|
-
username: claims?.preferred_username ||
|
|
139
|
-
name: claims?.name || claims?.preferred_username || "unknown",
|
|
140
|
-
email
|
|
143
|
+
username: claims?.preferred_username || sub || "unknown",
|
|
144
|
+
name: fullName || claims?.name || claims?.preferred_username || email || "unknown",
|
|
145
|
+
email,
|
|
141
146
|
};
|
|
142
147
|
saveSession();
|
|
143
148
|
|
package/src/fileFilters.js
CHANGED
|
@@ -18,6 +18,8 @@ export const EXCLUDED_DIR_NAMES = [
|
|
|
18
18
|
"obj",
|
|
19
19
|
// Secrets / credentials
|
|
20
20
|
".ssh", ".aws", ".gnupg",
|
|
21
|
+
// Seed / fixture / mock data dumps - not application source
|
|
22
|
+
"db_dump", "fixtures", "__fixtures__", "seed", "seeds", "mock-data", "sample-data", "testdata",
|
|
21
23
|
];
|
|
22
24
|
|
|
23
25
|
export const EXCLUDED_DIR_SUFFIXES = [".egg-info"];
|
package/src/server.js
CHANGED
|
@@ -152,14 +152,14 @@ function describeIndexOutcome(indexStatus, workspaceId) {
|
|
|
152
152
|
return {
|
|
153
153
|
ready: true,
|
|
154
154
|
message: `Workspace ${workspaceId} is fully indexed — text and symbols are ready. ` +
|
|
155
|
-
`It's ready for locate, search_code_context, find_files, and get_context_bundle.`,
|
|
155
|
+
`It's ready for context_search, locate, search_code_context, find_files, and get_context_bundle.`,
|
|
156
156
|
};
|
|
157
157
|
}
|
|
158
158
|
if (DEGRADED_STATUSES.has(indexStatus)) {
|
|
159
159
|
return {
|
|
160
160
|
ready: false,
|
|
161
161
|
message: `Workspace ${workspaceId} finished indexing, but only partially (status: ${indexStatus}). ` +
|
|
162
|
-
`find_files and get_context_bundle should still work; locate/search_code_context may return no results.`,
|
|
162
|
+
`find_files and get_context_bundle should still work; locate/search_code_context/context_search may return no results.`,
|
|
163
163
|
};
|
|
164
164
|
}
|
|
165
165
|
if (indexStatus === "CORRUPTED") {
|
|
@@ -270,7 +270,6 @@ async function handleGetContextBundle(args) {
|
|
|
270
270
|
return textContent(annotateIfFallbackBundle(body));
|
|
271
271
|
}
|
|
272
272
|
|
|
273
|
-
// locate, search_code_context, and find_files differ only in backend endpoint and tool name.
|
|
274
273
|
function makeSearchHandler(endpointPath, toolName) {
|
|
275
274
|
return async (args) => {
|
|
276
275
|
const workspaceId = resolveWorkspaceId(args);
|
|
@@ -284,6 +283,7 @@ const TOOL_HANDLERS = {
|
|
|
284
283
|
confirm_login: handleConfirmLogin,
|
|
285
284
|
setup_workspace: handleSetupWorkspace,
|
|
286
285
|
get_context_bundle: handleGetContextBundle,
|
|
286
|
+
context_search: makeSearchHandler("context-search", "context_search"),
|
|
287
287
|
locate: makeSearchHandler("locate-symbol", "locate"),
|
|
288
288
|
search_code_context: makeSearchHandler("search", "search_code_context"),
|
|
289
289
|
find_files: makeSearchHandler("find-files", "find_files"),
|
|
@@ -10,7 +10,14 @@ for the "first call in a session" — it applies every time a new discovery/comp
|
|
|
10
10
|
up during the task, not just once. Local tools are the fallback for when Harmony comes up short
|
|
11
11
|
(see Trust but verify below), never the default first move.
|
|
12
12
|
|
|
13
|
-
Routing —
|
|
13
|
+
Routing — \`context_search\` is the default first call for ANY discovery/comprehension need (finding
|
|
14
|
+
code, understanding how something works, discovering files/modules, gathering context). It is
|
|
15
|
+
Harmony's newest, best-ranked search endpoint and takes precedence over locate, search_code_context and
|
|
16
|
+
find_files — call it first, then only reach for one of those narrower tools if
|
|
17
|
+
context_search's result is empty/insufficient or you specifically need one of their specialized output
|
|
18
|
+
shapes (e.g. locate's line-number-only anchors for a targeted edit):
|
|
19
|
+
- \`context_search\` — try this FIRST. Ranked matching symbols with code snippets, file paths, and
|
|
20
|
+
relevance for a natural language query or exact identifier.
|
|
14
21
|
- \`locate\` — "which file(s) handle X" / "where is X" for a task you're about to edit. Returns
|
|
15
22
|
every matching symbol occurrence (definitions and references) with exact line numbers,
|
|
16
23
|
optionally scoped to a file_path once you already know the file.
|
|
@@ -21,6 +28,15 @@ Routing — pick the narrowest Harmony tool for the job, call one, then decide w
|
|
|
21
28
|
- \`get_context_bundle\` — broader contextual understanding for a task or question, not a specific
|
|
22
29
|
edit location. Returns a fuller XML context bundle for a prompt.
|
|
23
30
|
|
|
31
|
+
High availability: \`context_search\` is the always-on default for every discovery/comprehension need
|
|
32
|
+
that comes up during a task — call it again each time a new one arises, not just once per session or
|
|
33
|
+
once per task. Composing fallback input: when context_search comes up short and you drop down to one
|
|
34
|
+
of the narrower tools above, never just resend the same raw user query — carry forward the specific
|
|
35
|
+
symbols, identifiers, and file paths context_search's response already surfaced, and combine THOSE
|
|
36
|
+
with the user's original query when building the fallback tool's \`prompt\` (and \`file_path\` where
|
|
37
|
+
applicable). The fallback call should read as "user's intent, sharpened by what context_search already
|
|
38
|
+
found," not a blind retry of the same input.
|
|
39
|
+
|
|
24
40
|
Trust but verify: Harmony's index can be stale, incomplete, or briefly out of date relative to the
|
|
25
41
|
working tree. If a result is empty, errors, looks stale (references code that no longer exists), or
|
|
26
42
|
is otherwise insufficient, don't retry the same call — fall back immediately to local tools (rg,
|
|
@@ -53,8 +69,8 @@ Workspace setup — before the first search/locate/context call in a project:
|
|
|
53
69
|
`.trim();
|
|
54
70
|
|
|
55
71
|
const AUTH_INSTRUCTIONS = `
|
|
56
|
-
Auth gate — setup_workspace, get_context_bundle, locate, search_code_context
|
|
57
|
-
|
|
72
|
+
Auth gate — setup_workspace, get_context_bundle, context_search, locate, search_code_context and find_files all return a "not
|
|
73
|
+
authenticated" error until login has succeeded. Do not attempt to work around this by
|
|
58
74
|
guessing tokens or skipping the tool; just run the login flow below.
|
|
59
75
|
- Call \`login\`, show the returned loginUrl to the user verbatim, and ask them to complete it in
|
|
60
76
|
their browser.
|
package/src/toolSchemas.js
CHANGED
|
@@ -67,9 +67,49 @@ export const TOOLS = [
|
|
|
67
67
|
required: [],
|
|
68
68
|
},
|
|
69
69
|
},
|
|
70
|
+
{
|
|
71
|
+
name: "context_search",
|
|
72
|
+
description:
|
|
73
|
+
"PREFERRED FIRST CHOICE for any code discovery/comprehension need — Harmony's newest and best-ranked " +
|
|
74
|
+
"search endpoint. Given a natural language query or exact identifier, returns ranked matching symbols " +
|
|
75
|
+
"with their code snippets, file paths, and relevance. Try this BEFORE locate, search_code_context, " +
|
|
76
|
+
"find_files; only fall back to one of those narrower tools if context_search's " +
|
|
77
|
+
"result is empty, insufficient, or you specifically need one of their specialized output shapes " +
|
|
78
|
+
"(e.g. locate's line-number-only anchors for a targeted edit). Treat this as the always-on default " +
|
|
79
|
+
"entry point for every new discovery/comprehension need that comes up during a task — call it again " +
|
|
80
|
+
"each time one arises, not just once. Whenever you do fall back to one of the narrower tools, don't " +
|
|
81
|
+
"discard what this call already found: carry its matched symbols, identifiers, and file paths forward " +
|
|
82
|
+
"and combine them with the user's original query to build that tool's input, rather than re-issuing " +
|
|
83
|
+
"the raw query alone.",
|
|
84
|
+
inputSchema: {
|
|
85
|
+
type: "object",
|
|
86
|
+
properties: {
|
|
87
|
+
prompt: {
|
|
88
|
+
type: "string",
|
|
89
|
+
description:
|
|
90
|
+
"REQUIRED. Natural language query or exact identifier (symbol name, class name, endpoint " +
|
|
91
|
+
"route, API path) describing what to find context for.",
|
|
92
|
+
},
|
|
93
|
+
file_path: {
|
|
94
|
+
type: "string",
|
|
95
|
+
description: "Optional path substring to restrict results to a subdirectory, module, or specific file.",
|
|
96
|
+
},
|
|
97
|
+
limit: {
|
|
98
|
+
type: "number",
|
|
99
|
+
description: "Optional maximum number of results to return; the backend applies its own default if omitted.",
|
|
100
|
+
},
|
|
101
|
+
workspaceId: WORKSPACE_ID_PROPERTY,
|
|
102
|
+
},
|
|
103
|
+
required: ["prompt"],
|
|
104
|
+
},
|
|
105
|
+
},
|
|
70
106
|
{
|
|
71
107
|
name: "get_context_bundle",
|
|
72
|
-
description:
|
|
108
|
+
description:
|
|
109
|
+
"Retrieve a coding context bundle for a prompt from the backend. Returns XML context. If reached " +
|
|
110
|
+
"as a fallback after context_search came up short, build this prompt from the user's original " +
|
|
111
|
+
"query plus the symbols/identifiers/file paths context_search's response already surfaced, rather " +
|
|
112
|
+
"than resending the raw query unchanged.",
|
|
73
113
|
inputSchema: {
|
|
74
114
|
type: "object",
|
|
75
115
|
properties: {
|
|
@@ -91,7 +131,10 @@ export const TOOLS = [
|
|
|
91
131
|
"edit for a task, e.g. every occurrence of a name across the codebase, or (scoped with file_path) " +
|
|
92
132
|
"exact line numbers within a file you already know. It does not return full file content — Read() the " +
|
|
93
133
|
"file once you have the line numbers if you need surrounding context beyond what the anchor tells you. " +
|
|
94
|
-
"A missing/blank prompt returns an empty result list rather than an error or 'match everything'."
|
|
134
|
+
"A missing/blank prompt returns an empty result list rather than an error or 'match everything'. If " +
|
|
135
|
+
"reached as a fallback after context_search came up short, build this prompt from the user's original " +
|
|
136
|
+
"query plus the specific symbol/identifier names context_search's response already surfaced, rather " +
|
|
137
|
+
"than repeating the raw query verbatim.",
|
|
95
138
|
inputSchema: {
|
|
96
139
|
type: "object",
|
|
97
140
|
properties: {
|
|
@@ -128,7 +171,9 @@ export const TOOLS = [
|
|
|
128
171
|
description:
|
|
129
172
|
"Given a natural language query, returns rich Q&A context: matching symbols along with their code " +
|
|
130
173
|
"snippets, documentation, and decorators. Use this when you need to understand or explain how " +
|
|
131
|
-
"something works, not when you're about to make a targeted edit (use locate for that)."
|
|
174
|
+
"something works, not when you're about to make a targeted edit (use locate for that). If reached " +
|
|
175
|
+
"as a fallback after context_search came up short, fold the symbols/identifiers/file paths from " +
|
|
176
|
+
"context_search's response together with the user's original query into this prompt.",
|
|
132
177
|
inputSchema: {
|
|
133
178
|
type: "object",
|
|
134
179
|
properties: {
|
|
@@ -154,7 +199,9 @@ export const TOOLS = [
|
|
|
154
199
|
description:
|
|
155
200
|
"Given a natural language query, returns lightweight file path and architectural role/tag matches — " +
|
|
156
201
|
"no symbols or code content. Use this for broad file/module discovery (e.g. \"find all the " +
|
|
157
|
-
"controllers\") rather than pinpointing a specific edit location."
|
|
202
|
+
"controllers\") rather than pinpointing a specific edit location. If reached as a fallback after " +
|
|
203
|
+
"context_search came up short, incorporate any relevant file paths/modules context_search already " +
|
|
204
|
+
"surfaced along with the user's original query when composing this prompt.",
|
|
158
205
|
inputSchema: {
|
|
159
206
|
type: "object",
|
|
160
207
|
properties: {
|
|
@@ -174,5 +221,5 @@ export const TOOLS = [
|
|
|
174
221
|
},
|
|
175
222
|
required: ["prompt"],
|
|
176
223
|
},
|
|
177
|
-
}
|
|
224
|
+
}
|
|
178
225
|
];
|