@codeconductorai/harmony-mcp 1.0.26 → 1.0.28
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 +9 -29
- package/package.json +1 -1
- package/src/harmonyClient.js +36 -28
- package/src/log.js +65 -3
- package/src/server.js +130 -16
- package/src/serverInstructions.js +52 -39
- package/src/toolSchemas.js +48 -73
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
|
+
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.28`) 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.
|
|
35
|
+
claude mcp add harmony -- npx -y @codeconductorai/harmony-mcp@1.0.28
|
|
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.
|
|
50
|
+
"args": ["-y", "@codeconductorai/harmony-mcp@1.0.28"]
|
|
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.
|
|
61
|
+
codex mcp add harmony -- npx -y @codeconductorai/harmony-mcp@1.0.28
|
|
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.
|
|
69
|
+
args = ["-y", "@codeconductorai/harmony-mcp@1.0.28"]
|
|
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.
|
|
81
|
+
"args": ["-y", "@codeconductorai/harmony-mcp@1.0.28"]
|
|
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.
|
|
98
|
+
"args": ["-y", "@codeconductorai/harmony-mcp@1.0.28"]
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
101
|
}
|
|
@@ -108,7 +108,7 @@ After adding the server and restarting your client:
|
|
|
108
108
|
1. **`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. Call this first, even before logging in: some backend deployments authenticate the workspace internally with no login involved at all, so this can succeed on its own. 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.
|
|
109
109
|
2. If `setup_workspace` (or any tool below) fails with a "not authenticated" error, this deployment requires login: call **`login`**, which starts a device-flow login and returns a URL to open in your browser.
|
|
110
110
|
3. 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. Call `setup_workspace` again afterward.
|
|
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 **`locate`** below. Fall back to `locate` only if `context_search` comes up short or you need its line-number-only anchors — and when you do, feed it 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.
|
|
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 **`locate`** below. Fall back to `locate` only if `context_search` comes up short or you need its line-number-only anchors — and when you do, feed it 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.
|
|
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
|
|
|
@@ -140,9 +140,7 @@ search endpoint. Given a natural-language query or exact identifier, returns ran
|
|
|
140
140
|
as structural facts and precise file:line locations, deliberately without embedded source code.
|
|
141
141
|
Takes precedence over `locate`; only fall back to it if
|
|
142
142
|
`context_search`'s result is empty/insufficient or you specifically need its line-number-only
|
|
143
|
-
anchors for a targeted edit.
|
|
144
|
-
`explain_symbol`/`path_between`/`explain_subsystem` instead — don't route through `context_search`
|
|
145
|
-
first. Treat it as the
|
|
143
|
+
anchors for a targeted edit. Treat it as the
|
|
146
144
|
always-on default entry point for every new discovery/comprehension need that comes up during a
|
|
147
145
|
task — call it again each time, not just once. When falling back to `locate` afterward, its input
|
|
148
146
|
should combine the user's original query with the symbols/identifiers/file paths this call already
|
|
@@ -159,24 +157,6 @@ Given a natural-language query or exact identifier, returns lightweight symbol c
|
|
|
159
157
|
- `limit` (optional): max results (default 40); the result list is never padded to this size.
|
|
160
158
|
- `workspaceId` (optional): target a specific workspace instead of the local project's. Defaults to the local `setup_workspace` workspace.
|
|
161
159
|
|
|
162
|
-
### `explain_symbol`
|
|
163
|
-
Given an exact symbol name (method, function, or class), returns what it's connected to in the persisted call graph: which symbols call it, which symbols it calls, and any call targets that couldn't be confidently resolved to a single definition. Use this to understand a symbol's role and blast radius before changing it, or to answer "who calls X" / "what does X call" directly, without falling back to reading every file that might reference it — this is the highest-leverage tool in this set for that shape of question.
|
|
164
|
-
- `prompt` (required): the exact symbol name to explain.
|
|
165
|
-
- `file_path` (optional): path substring narrowing which definition to use when the name alone is ambiguous (e.g. a common interface-method name implemented by hundreds of classes).
|
|
166
|
-
- `workspaceId` (optional): target a specific workspace instead of the local project's. Defaults to the local `setup_workspace` workspace.
|
|
167
|
-
|
|
168
|
-
### `path_between`
|
|
169
|
-
Given two exact symbol names, finds the shortest resolved call-graph path from the first to the second (e.g. how a controller method eventually reaches a repository call several hops down). Returns `found: false` if no path exists within the search bounds — that doesn't necessarily mean no relationship exists; it can also mean a bare name was too ambiguous to resolve.
|
|
170
|
-
- `from` / `to` (required): the starting and target symbols' exact names.
|
|
171
|
-
- `from_file_path` / `to_file_path` (optional): path substrings narrowing which definition to use when a name alone is ambiguous.
|
|
172
|
-
- `workspaceId` (optional): target a specific workspace instead of the local project's. Defaults to the local `setup_workspace` workspace.
|
|
173
|
-
|
|
174
|
-
### `explain_subsystem`
|
|
175
|
-
Given a loose subsystem/module name (e.g. `"billing"`, `"auth"`), returns every file Harmony has clustered into that subsystem via its persisted import-graph communities — a direct listing, not a ranked search. Use this for "how does the billing system work" style questions where you want the whole subsystem's files at once, rather than piecing it together from several `context_search` calls.
|
|
176
|
-
- `prompt` (required): loose subsystem/module name to match against detected community labels.
|
|
177
|
-
- `limit` (optional): max files to return (default 60).
|
|
178
|
-
- `workspaceId` (optional): target a specific workspace instead of the local project's. Defaults to the local `setup_workspace` workspace.
|
|
179
|
-
|
|
180
160
|
## Observability (OpenObserve)
|
|
181
161
|
|
|
182
162
|
The server ships its own logs, traces, and metrics over OTLP/HTTP using OpenTelemetry, and forwards the active trace id to every request it makes to the harmony backend (as a W3C `traceparent` header plus a plain `X-Trace-Id` header) so backend-side logs can be correlated with the MCP session that triggered them.
|
package/package.json
CHANGED
package/src/harmonyClient.js
CHANGED
|
@@ -284,7 +284,7 @@ export async function pollWorkspaceStatus(workspaceId, { maxWaitMs = 120_000, in
|
|
|
284
284
|
return lastStatus;
|
|
285
285
|
}
|
|
286
286
|
|
|
287
|
-
// Shared POST caller for the context-search/locate-symbol
|
|
287
|
+
// Shared POST caller for the context-search/locate-symbol endpoints — same request/response shape.
|
|
288
288
|
export async function callHarmonySearchEndpoint(endpointPath, args, workspaceId) {
|
|
289
289
|
const prompt = args.prompt || args.query;
|
|
290
290
|
if (!prompt) throw new Error("prompt is required.");
|
|
@@ -314,24 +314,12 @@ export async function callHarmonySearchEndpoint(endpointPath, args, workspaceId)
|
|
|
314
314
|
return body;
|
|
315
315
|
}
|
|
316
316
|
|
|
317
|
-
// POST
|
|
318
|
-
//
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
const to = args.to;
|
|
322
|
-
if (!from || !to) throw new Error("Both 'from' and 'to' are required.");
|
|
323
|
-
|
|
324
|
-
const requestBody = {
|
|
325
|
-
from,
|
|
326
|
-
to,
|
|
327
|
-
from_file_path: args.from_file_path,
|
|
328
|
-
to_file_path: args.to_file_path,
|
|
329
|
-
workspaceMetadata: buildWorkspaceMetadata(workspaceId),
|
|
330
|
-
};
|
|
331
|
-
|
|
332
|
-
log(`[path-between] Request body:`, JSON.stringify(requestBody, null, 2));
|
|
317
|
+
// Shared POST caller for the newer single-purpose endpoints (query-module-dependencies,
|
|
318
|
+
// outline-file-symbols, get-repository-map) — identical JSON-in/XML-out shape, different path/body.
|
|
319
|
+
async function callHarmonyJsonEndpoint(endpointPath, requestBody, workspaceId) {
|
|
320
|
+
log(`[${endpointPath}] Request body:`, JSON.stringify(requestBody, null, 2));
|
|
333
321
|
|
|
334
|
-
const response = await fetch(`${API_URL}/api/code-workspace/${workspaceId}
|
|
322
|
+
const response = await fetch(`${API_URL}/api/code-workspace/${workspaceId}/${endpointPath}`, {
|
|
335
323
|
method: "POST",
|
|
336
324
|
headers: {
|
|
337
325
|
"Content-Type": "application/json",
|
|
@@ -342,21 +330,41 @@ export async function callHarmonyPathBetween(args, workspaceId) {
|
|
|
342
330
|
});
|
|
343
331
|
const body = await response.text();
|
|
344
332
|
if (!response.ok) {
|
|
345
|
-
throw new Error(
|
|
333
|
+
throw new Error(`${endpointPath} request failed: ${response.status} ${body}${traceSuffix()}`);
|
|
346
334
|
}
|
|
347
335
|
return body;
|
|
348
336
|
}
|
|
349
337
|
|
|
350
|
-
//
|
|
351
|
-
|
|
352
|
-
|
|
338
|
+
// POST /api/code-workspace/{workspaceId}/query-module-dependencies — a file's directed
|
|
339
|
+
// import/inheritance dependencies.
|
|
340
|
+
export async function callHarmonyModuleDependencies(args, workspaceId) {
|
|
341
|
+
if (!args.file_path) throw new Error("file_path is required.");
|
|
342
|
+
return callHarmonyJsonEndpoint("query-module-dependencies", {
|
|
343
|
+
file_path: args.file_path,
|
|
344
|
+
depth: args.depth,
|
|
345
|
+
workspaceMetadata: buildWorkspaceMetadata(workspaceId),
|
|
346
|
+
}, workspaceId);
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
// POST /api/code-workspace/{workspaceId}/outline-file-symbols — a file's structural skeleton.
|
|
350
|
+
export async function callHarmonyFileOutline(args, workspaceId) {
|
|
351
|
+
if (!args.file_path) throw new Error("file_path is required.");
|
|
352
|
+
return callHarmonyJsonEndpoint("outline-file-symbols", {
|
|
353
|
+
file_path: args.file_path,
|
|
354
|
+
include_private: args.include_private,
|
|
355
|
+
workspaceMetadata: buildWorkspaceMetadata(workspaceId),
|
|
356
|
+
}, workspaceId);
|
|
357
|
+
}
|
|
353
358
|
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
359
|
+
// POST /api/code-workspace/{workspaceId}/get-repository-map — ranked, token-budgeted architectural
|
|
360
|
+
// map of the workspace.
|
|
361
|
+
export async function callHarmonyRepositoryMap(args, workspaceId) {
|
|
362
|
+
return callHarmonyJsonEndpoint("get-repository-map", {
|
|
363
|
+
focus_files: args.focus_files,
|
|
364
|
+
max_tokens: args.max_tokens,
|
|
365
|
+
directory_filter: args.directory_filter,
|
|
366
|
+
workspaceMetadata: buildWorkspaceMetadata(workspaceId),
|
|
367
|
+
}, workspaceId);
|
|
360
368
|
}
|
|
361
369
|
|
|
362
370
|
// POST /api/v1/index/files — used by the file watcher for incremental updates.
|
package/src/log.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import fs from "fs";
|
|
2
2
|
import os from "os";
|
|
3
3
|
import path from "path";
|
|
4
|
+
import { randomUUID } from "crypto";
|
|
4
5
|
import { logs, SeverityNumber } from "@opentelemetry/api-logs";
|
|
5
6
|
|
|
6
7
|
const LOG_FILE = path.join(os.tmpdir(), "harmony-mcp.log");
|
|
@@ -9,14 +10,75 @@ const logStream = fs.createWriteStream(LOG_FILE, { flags: "a" });
|
|
|
9
10
|
// No-op until telemetry.js starts the SDK and registers the real LoggerProvider.
|
|
10
11
|
const otelLogger = logs.getLogger("harmony-mcp");
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
// Groups one server process's records together in OpenObserve.
|
|
14
|
+
export const SESSION_ID = randomUUID();
|
|
15
|
+
|
|
16
|
+
// The log backend is for inspecting what happened, not for storing payloads; the local copy is
|
|
17
|
+
// read by eye, so it is cut harder still.
|
|
18
|
+
const MAX_ATTR_CHARS = Number(process.env.HARMONY_LOG_MAX_ATTR_CHARS) || 8000;
|
|
19
|
+
const MAX_LOCAL_ATTR_CHARS = 300;
|
|
20
|
+
|
|
21
|
+
function truncate(value, limit) {
|
|
22
|
+
if (typeof value !== "string" || value.length <= limit) return value;
|
|
23
|
+
return `${value.slice(0, limit)}…[truncated ${value.length - limit} chars]`;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// OTLP carries primitives reliably and little else, so anything richer is JSON-encoded here
|
|
27
|
+
// rather than left for the exporter to drop silently.
|
|
28
|
+
function normalizeAttributes(attributes) {
|
|
29
|
+
const out = {};
|
|
30
|
+
for (const [key, value] of Object.entries(attributes || {})) {
|
|
31
|
+
if (value === undefined || value === null) continue;
|
|
32
|
+
let normalized = value;
|
|
33
|
+
if (typeof value === "object") {
|
|
34
|
+
try {
|
|
35
|
+
normalized = JSON.stringify(value);
|
|
36
|
+
} catch {
|
|
37
|
+
normalized = String(value);
|
|
38
|
+
}
|
|
39
|
+
} else if (typeof value !== "string" && typeof value !== "number" && typeof value !== "boolean") {
|
|
40
|
+
normalized = String(value);
|
|
41
|
+
}
|
|
42
|
+
out[key] = truncate(normalized, MAX_ATTR_CHARS);
|
|
43
|
+
}
|
|
44
|
+
return out;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function writeLocal(line) {
|
|
15
48
|
logStream.write(line);
|
|
16
49
|
process.stderr.write(line);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function log(...args) {
|
|
53
|
+
const message = args.join(" ");
|
|
54
|
+
writeLocal(`[${new Date().toISOString()}] ${message}\n`);
|
|
17
55
|
try {
|
|
18
56
|
otelLogger.emit({ severityNumber: SeverityNumber.INFO, body: message });
|
|
19
57
|
} catch {
|
|
20
58
|
// best-effort only — never let telemetry export break local logging
|
|
21
59
|
}
|
|
22
60
|
}
|
|
61
|
+
|
|
62
|
+
// Structured counterpart to log(): attributes become queryable fields in OpenObserve instead of
|
|
63
|
+
// text to be grepped, and the active span stamps the record with its trace id.
|
|
64
|
+
export function logEvent(eventName, attributes = {}, { severity = SeverityNumber.INFO, summary } = {}) {
|
|
65
|
+
const body = summary || eventName;
|
|
66
|
+
const attrs = normalizeAttributes({
|
|
67
|
+
"event.name": eventName,
|
|
68
|
+
"session.id": SESSION_ID,
|
|
69
|
+
...attributes,
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
const local = Object.fromEntries(
|
|
73
|
+
Object.entries(attrs).map(([key, value]) => [key, truncate(value, MAX_LOCAL_ATTR_CHARS)])
|
|
74
|
+
);
|
|
75
|
+
writeLocal(`[${new Date().toISOString()}] [${eventName}] ${body} ${JSON.stringify(local)}\n`);
|
|
76
|
+
|
|
77
|
+
try {
|
|
78
|
+
otelLogger.emit({ severityNumber: severity, body, attributes: attrs });
|
|
79
|
+
} catch {
|
|
80
|
+
// best-effort only — never let telemetry export break local logging
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export { SeverityNumber };
|
package/src/server.js
CHANGED
|
@@ -5,7 +5,7 @@ import { SpanStatusCode } from "@opentelemetry/api";
|
|
|
5
5
|
|
|
6
6
|
const packageJson = createRequire(import.meta.url)("../package.json");
|
|
7
7
|
|
|
8
|
-
import { log } from "./log.js";
|
|
8
|
+
import { log, logEvent, SESSION_ID, SeverityNumber } from "./log.js";
|
|
9
9
|
import { tracer, toolCallCounter, toolCallDuration, getActiveTraceId } from "./telemetry.js";
|
|
10
10
|
import {
|
|
11
11
|
initiateDeviceLogin,
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
minSecondsBeforeConfirm,
|
|
17
17
|
getWorkspaceToken,
|
|
18
18
|
} from "./deviceAuth.js";
|
|
19
|
-
import { getGitCommitHash, getProjectName } from "./repoIdentity.js";
|
|
19
|
+
import { getGitBranch, getGitCommitHash, getProjectName } from "./repoIdentity.js";
|
|
20
20
|
import { getCurrentUsername, REPO_ID, REPO_IDENTITY } from "./workspaceIdentity.js";
|
|
21
21
|
import { readMarker, writeMarker } from "./workspaceMarker.js";
|
|
22
22
|
import { startFileWatcher, isFileWatcherActive } from "./fileWatcher.js";
|
|
@@ -24,8 +24,9 @@ import {
|
|
|
24
24
|
ensureWorkspaceUploaded,
|
|
25
25
|
pollWorkspaceStatus,
|
|
26
26
|
callHarmonySearchEndpoint,
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
callHarmonyModuleDependencies,
|
|
28
|
+
callHarmonyFileOutline,
|
|
29
|
+
callHarmonyRepositoryMap,
|
|
29
30
|
} from "./harmonyClient.js";
|
|
30
31
|
import { buildServerInstructions } from "./serverInstructions.js";
|
|
31
32
|
import { TOOLS } from "./toolSchemas.js";
|
|
@@ -155,16 +156,17 @@ function describeIndexOutcome(indexStatus, workspaceId) {
|
|
|
155
156
|
return {
|
|
156
157
|
ready: true,
|
|
157
158
|
message: `Workspace ${workspaceId} is fully indexed — text and symbols are ready. ` +
|
|
158
|
-
`It's ready for context_search, locate,
|
|
159
|
+
`It's ready for context_search, locate, query_module_dependencies, outline_file_symbols, ` +
|
|
160
|
+
`and get_repository_map.`,
|
|
159
161
|
};
|
|
160
162
|
}
|
|
161
163
|
if (DEGRADED_STATUSES.has(indexStatus)) {
|
|
162
164
|
return {
|
|
163
165
|
ready: false,
|
|
164
166
|
message: `Workspace ${workspaceId} finished indexing, but only partially (status: ${indexStatus}). ` +
|
|
165
|
-
`Symbol-level tools (locate,
|
|
166
|
-
`context_search may return incomplete or no results until symbol
|
|
167
|
-
`with local search (rg/grep) if a result looks suspiciously empty.`,
|
|
167
|
+
`Symbol-level tools (locate, outline_file_symbols, get_repository_map) and possibly ` +
|
|
168
|
+
`context_search/query_module_dependencies may return incomplete or no results until symbol ` +
|
|
169
|
+
`indexing finishes — verify with local search (rg/grep) if a result looks suspiciously empty.`,
|
|
168
170
|
};
|
|
169
171
|
}
|
|
170
172
|
if (indexStatus === "CORRUPTED") {
|
|
@@ -270,13 +272,29 @@ function makeSearchHandler(endpointPath, toolName) {
|
|
|
270
272
|
return async (args) => {
|
|
271
273
|
const workspaceId = resolveWorkspaceId(args);
|
|
272
274
|
const body = await callHarmonySearchEndpoint(endpointPath, args, workspaceId);
|
|
273
|
-
|
|
275
|
+
log(`[${toolName}] response ${body.length} chars`);
|
|
276
|
+
return textContent(body);
|
|
274
277
|
};
|
|
275
278
|
}
|
|
276
279
|
|
|
277
|
-
async function
|
|
280
|
+
async function handleModuleDependencies(args) {
|
|
278
281
|
const workspaceId = resolveWorkspaceId(args);
|
|
279
|
-
const body = await
|
|
282
|
+
const body = await callHarmonyModuleDependencies(args, workspaceId);
|
|
283
|
+
log(`[query_module_dependencies] response ${body.length} chars`);
|
|
284
|
+
return textContent(body);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
async function handleFileOutline(args) {
|
|
288
|
+
const workspaceId = resolveWorkspaceId(args);
|
|
289
|
+
const body = await callHarmonyFileOutline(args, workspaceId);
|
|
290
|
+
log(`[outline_file_symbols] response ${body.length} chars`);
|
|
291
|
+
return textContent(body);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
async function handleRepositoryMap(args) {
|
|
295
|
+
const workspaceId = resolveWorkspaceId(args);
|
|
296
|
+
const body = await callHarmonyRepositoryMap(args, workspaceId);
|
|
297
|
+
log(`[get_repository_map] response ${body.length} chars`);
|
|
280
298
|
return textContent(body);
|
|
281
299
|
}
|
|
282
300
|
|
|
@@ -286,13 +304,100 @@ const TOOL_HANDLERS = {
|
|
|
286
304
|
setup_workspace: handleSetupWorkspace,
|
|
287
305
|
context_search: makeSearchHandler("context-search", "context_search"),
|
|
288
306
|
locate: makeSearchHandler("locate-symbol", "locate"),
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
307
|
+
query_module_dependencies: handleModuleDependencies,
|
|
308
|
+
outline_file_symbols: handleFileOutline,
|
|
309
|
+
get_repository_map: handleRepositoryMap,
|
|
292
310
|
};
|
|
293
311
|
|
|
294
312
|
const AUTH_EXEMPT_TOOLS = new Set(["login", "confirm_login", "setup_workspace"]);
|
|
295
313
|
|
|
314
|
+
// Every tool call emits exactly one structured log record — mcp.tool.response, or mcp.tool.error
|
|
315
|
+
// when the handler throws — so a call can be reconstructed from OpenObserve without the local log
|
|
316
|
+
// file. Attribute names mirror the span attributes so a record and its trace line up.
|
|
317
|
+
|
|
318
|
+
// Max characters of the tool's own output kept on the log record. The full response still goes to
|
|
319
|
+
// the agent — this only bounds what is shipped to the log backend.
|
|
320
|
+
const MAX_LOGGED_RESPONSE_CHARS = Number(process.env.HARMONY_LOG_RESPONSE_CHARS) || 4000;
|
|
321
|
+
|
|
322
|
+
// Never throws: logging must not be able to fail a tool call that otherwise succeeded.
|
|
323
|
+
function workspaceIdForLog(args) {
|
|
324
|
+
try {
|
|
325
|
+
return args?.workspaceId || readMarker()?.workspaceId;
|
|
326
|
+
} catch {
|
|
327
|
+
return undefined;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
// The agent-supplied intent behind the call, whatever the tool names it.
|
|
332
|
+
function userPromptForLog(args) {
|
|
333
|
+
if (typeof args?.prompt === "string") return args.prompt;
|
|
334
|
+
if (typeof args?.file_path === "string") return args.file_path;
|
|
335
|
+
return undefined;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
function responseTextForLog(result) {
|
|
339
|
+
const parts = Array.isArray(result?.content) ? result.content : [];
|
|
340
|
+
return parts
|
|
341
|
+
.filter((part) => part?.type === "text" && typeof part.text === "string")
|
|
342
|
+
.map((part) => part.text)
|
|
343
|
+
.join("\n");
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
// Arguments minus the prompt, which is logged on its own field.
|
|
347
|
+
function toolArgsForLog(args) {
|
|
348
|
+
const { prompt, ...rest } = args || {};
|
|
349
|
+
return Object.keys(rest).length ? rest : undefined;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
function baseToolLogAttributes(name, args) {
|
|
353
|
+
return {
|
|
354
|
+
"mcp.tool.name": name,
|
|
355
|
+
"mcp.workspace.id": workspaceIdForLog(args),
|
|
356
|
+
"mcp.tool.prompt": userPromptForLog(args),
|
|
357
|
+
"mcp.tool.arguments": toolArgsForLog(args),
|
|
358
|
+
"mcp.server.version": packageJson.version,
|
|
359
|
+
"trace.id": getActiveTraceId(),
|
|
360
|
+
"session.id": SESSION_ID,
|
|
361
|
+
"user.name": getCurrentUsername(),
|
|
362
|
+
"repo.id": REPO_ID,
|
|
363
|
+
"project.name": getProjectName(),
|
|
364
|
+
"vcs.branch": getGitBranch(),
|
|
365
|
+
"vcs.commit": getGitCommitHash(),
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
function logToolResponse(name, args, result, durationMs) {
|
|
370
|
+
const responseText = responseTextForLog(result);
|
|
371
|
+
const isError = result?.isError === true;
|
|
372
|
+
logEvent("mcp.tool.response", {
|
|
373
|
+
...baseToolLogAttributes(name, args),
|
|
374
|
+
"mcp.tool.status": isError ? "error" : "ok",
|
|
375
|
+
"mcp.tool.is_error": isError,
|
|
376
|
+
"mcp.tool.duration_ms": durationMs,
|
|
377
|
+
"mcp.tool.response": responseText.slice(0, MAX_LOGGED_RESPONSE_CHARS),
|
|
378
|
+
"mcp.tool.response.chars": responseText.length,
|
|
379
|
+
"mcp.tool.response.truncated": responseText.length > MAX_LOGGED_RESPONSE_CHARS,
|
|
380
|
+
}, {
|
|
381
|
+
severity: isError ? SeverityNumber.ERROR : SeverityNumber.INFO,
|
|
382
|
+
summary: `tool ${name} ${isError ? "returned an error" : "responded"} in ${durationMs}ms`,
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
function logToolError(name, args, error, durationMs) {
|
|
387
|
+
logEvent("mcp.tool.error", {
|
|
388
|
+
...baseToolLogAttributes(name, args),
|
|
389
|
+
"mcp.tool.status": "exception",
|
|
390
|
+
"mcp.tool.is_error": true,
|
|
391
|
+
"mcp.tool.duration_ms": durationMs,
|
|
392
|
+
"error.type": error?.name || "Error",
|
|
393
|
+
"error.message": error?.message || String(error),
|
|
394
|
+
"error.stack": error?.stack,
|
|
395
|
+
}, {
|
|
396
|
+
severity: SeverityNumber.ERROR,
|
|
397
|
+
summary: `tool ${name} threw after ${durationMs}ms: ${error?.message || error}`,
|
|
398
|
+
});
|
|
399
|
+
}
|
|
400
|
+
|
|
296
401
|
// Build the MCP server: tool listing, and the tools/call dispatcher.
|
|
297
402
|
export function buildMcpServer() {
|
|
298
403
|
const server = new Server(
|
|
@@ -313,22 +418,31 @@ export function buildMcpServer() {
|
|
|
313
418
|
|
|
314
419
|
return tracer.startActiveSpan(`mcp.tool/${name}`, async (span) => {
|
|
315
420
|
span.setAttribute("mcp.tool.name", name);
|
|
421
|
+
const workspaceId = workspaceIdForLog(args);
|
|
422
|
+
const userPrompt = userPromptForLog(args);
|
|
423
|
+
if (workspaceId) span.setAttribute("mcp.workspace.id", workspaceId);
|
|
424
|
+
if (userPrompt) span.setAttribute("mcp.tool.prompt", userPrompt);
|
|
316
425
|
log(`[mcp] trace id ${getActiveTraceId()} for tool call "${name}"`);
|
|
317
426
|
const startedAt = Date.now();
|
|
427
|
+
let result;
|
|
318
428
|
try {
|
|
319
429
|
if (!AUTH_EXEMPT_TOOLS.has(name) && !isAuthenticated(args)) {
|
|
320
430
|
span.setAttribute("mcp.tool.authenticated", false);
|
|
321
|
-
|
|
431
|
+
result = NOT_AUTHENTICATED;
|
|
432
|
+
return result;
|
|
322
433
|
}
|
|
323
|
-
|
|
434
|
+
result = await handler(args, extra);
|
|
324
435
|
if (result?.isError) span.setStatus({ code: SpanStatusCode.ERROR });
|
|
325
436
|
return result;
|
|
326
437
|
} catch (error) {
|
|
327
438
|
span.recordException(error);
|
|
328
439
|
span.setStatus({ code: SpanStatusCode.ERROR, message: error?.message });
|
|
440
|
+
logToolError(name, args, error, Date.now() - startedAt);
|
|
329
441
|
throw error;
|
|
330
442
|
} finally {
|
|
331
443
|
const durationMs = Date.now() - startedAt;
|
|
444
|
+
// A thrown call already logged mcp.tool.error above; only responses land here.
|
|
445
|
+
if (result) logToolResponse(name, args, result, durationMs);
|
|
332
446
|
toolCallDuration.record(durationMs, { "mcp.tool.name": name });
|
|
333
447
|
toolCallCounter.add(1, { "mcp.tool.name": name });
|
|
334
448
|
span.end();
|
|
@@ -20,8 +20,11 @@ instead:
|
|
|
20
20
|
already see) — just Read it or Grep for the exact string; that's faster and skips network/auth/
|
|
21
21
|
indexing latency for no benefit.
|
|
22
22
|
- Small, local edits or reasoning fully contained in a file you already have open.
|
|
23
|
-
- The workspace isn't indexed yet
|
|
24
|
-
|
|
23
|
+
- The workspace isn't indexed yet — fall back to rg/grep/Read for that lookup.
|
|
24
|
+
- Harmony just returned empty/stale/irrelevant results for this specific lookup from one tool — don't
|
|
25
|
+
fall back to rg/grep/Read yet; try another Harmony tool suited to the same lookup first (see "Trust
|
|
26
|
+
but verify" below). Only fall back to local tools once that alternate Harmony tool also comes up
|
|
27
|
+
short.
|
|
25
28
|
- Writing new code, boilerplate, or general-purpose logic that doesn't depend on this repo's
|
|
26
29
|
existing implementation.
|
|
27
30
|
|
|
@@ -72,24 +75,27 @@ to act on — it doesn't replace them, and it doesn't apply to the setup/auth to
|
|
|
72
75
|
|
|
73
76
|
const ROUTING_RULES = `
|
|
74
77
|
Choosing among Harmony's tools — once Harmony is the right move for a lookup, pick the narrowest fit:
|
|
78
|
+
- \`get_repository_map\` — the FIRST call for an unfamiliar codebase or subsystem: a ranked,
|
|
79
|
+
token-budgeted architectural overview (the most structurally important files by call-graph
|
|
80
|
+
centrality and subsystem clustering, with their top symbols) in one call, instead of directory
|
|
81
|
+
traversals or a string of unscoped context_search calls just to build a mental model. Pass
|
|
82
|
+
focus_files when specific files are already known to be relevant (open in the editor, mentioned by
|
|
83
|
+
the user) to rank them first. This is orientation, not a substitute for the targeted lookups below
|
|
84
|
+
— move on to context_search/locate once you have specific symbols or files in mind.
|
|
75
85
|
- \`context_search\` — usually the best starting point for open-ended discovery/comprehension: ranked
|
|
76
86
|
matching symbols with code snippets, file paths, and relevance for a natural language query or
|
|
77
87
|
exact identifier.
|
|
78
88
|
- \`locate\` — "which file(s) handle X" / "where is X" for a task you're about to edit. Returns every
|
|
79
89
|
matching symbol occurrence (definitions and references) with exact line numbers, optionally scoped
|
|
80
90
|
to a file_path once you already know the file.
|
|
81
|
-
- \`
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
graph directly; needs two exact symbol names.
|
|
90
|
-
- \`explain_subsystem\` — "how does the billing/auth/whatever system work" when you want a whole
|
|
91
|
-
module's files at once rather than piecing it together from several context_search calls. Takes a
|
|
92
|
-
loose subsystem name, not an exact identifier.
|
|
91
|
+
- \`outline_file_symbols\` — a specific file's structural skeleton: every definition's signature line,
|
|
92
|
+
docstring, and line number, with implementation bodies omitted. Use this INSTEAD of Read() when you
|
|
93
|
+
only need to understand a file's interface and capabilities rather than its execution logic — far
|
|
94
|
+
cheaper than reading the whole file.
|
|
95
|
+
- \`query_module_dependencies\` — a file's directed import/inheritance dependencies: what it depends
|
|
96
|
+
on, and what depends on it, optionally one further transitive hop. Use this INSTEAD of manually
|
|
97
|
+
grepping import statements across files to check coupling or trace architectural boundaries before
|
|
98
|
+
touching a shared file.
|
|
93
99
|
|
|
94
100
|
If context_search's result is empty or insufficient, or you specifically need locate's line-number-
|
|
95
101
|
only anchors, fall back to that narrower tool rather than retrying context_search. Composing that
|
|
@@ -97,10 +103,7 @@ fallback: never just resend the same raw user query — carry forward the specif
|
|
|
97
103
|
identifiers, and file paths context_search's response already surfaced, and combine THOSE with the
|
|
98
104
|
user's original query when building the fallback tool's \`prompt\` (and \`file_path\` where
|
|
99
105
|
applicable). The fallback call should read as "user's intent, sharpened by what context_search
|
|
100
|
-
already found," not a blind retry of the same input.
|
|
101
|
-
are different from this fallback chain — reach for them directly, as the first call, whenever the
|
|
102
|
-
question is inherently about a call relationship or a whole subsystem rather than "find me the code
|
|
103
|
-
for X"; don't route through context_search first just to warm up.
|
|
106
|
+
already found," not a blind retry of the same input.
|
|
104
107
|
|
|
105
108
|
Carry forward a good result: once a Harmony response gives you a concrete file_path, symbol name, or
|
|
106
109
|
other specific detail relevant to the task, treat it as ground truth for every tool call that
|
|
@@ -110,32 +113,42 @@ move on to Read, an edit, or any other tool — use the exact path/identifier al
|
|
|
110
113
|
than deriving your own guess at that point.
|
|
111
114
|
|
|
112
115
|
Populate \`file_path\` whenever it's known: context_search and locate accept an optional \`file_path\`
|
|
113
|
-
field to scope results to a subdirectory, module, or specific file
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
user, or established earlier in the conversation — pass it into that call's \`file_path\`
|
|
119
|
-
(or \`from_file_path\`/\`to_file_path\`), don't leave it blank and rely on the \`prompt\` text alone to
|
|
120
|
-
imply scope. Only omit it when no such path is actually known yet; never fill it with a guessed path
|
|
121
|
-
(see refinement step 3 above).
|
|
116
|
+
field to scope results to a subdirectory, module, or specific file. Whenever a file path is already
|
|
117
|
+
known at call time — surfaced by an earlier context_search/locate result this task, stated explicitly
|
|
118
|
+
by the user, or established earlier in the conversation — pass it into that call's \`file_path\`,
|
|
119
|
+
don't leave it blank and rely on the \`prompt\` text alone to imply scope. Only omit it when no such
|
|
120
|
+
path is actually known yet; never fill it with a guessed path (see refinement step 3 above).
|
|
122
121
|
`.trim();
|
|
123
122
|
|
|
124
123
|
const TRUST_BUT_VERIFY = `
|
|
125
124
|
Trust but verify: Harmony's index can be stale, incomplete, or briefly out of date relative to the
|
|
126
125
|
working tree. If a result is empty, errors, looks stale (references code that no longer exists), or
|
|
127
|
-
is otherwise insufficient, don't retry the same call —
|
|
128
|
-
|
|
129
|
-
|
|
126
|
+
is otherwise insufficient, don't retry the same call — and don't jump straight to local tools either.
|
|
127
|
+
First try whichever other Harmony tool is the next-best fit for that same lookup, carrying forward
|
|
128
|
+
anything the failed call already surfaced (a symbol name, a file path) into the new call rather than
|
|
129
|
+
starting from scratch:
|
|
130
|
+
- \`context_search\` came up empty/insufficient → try \`locate\` with the same (or refined) prompt for
|
|
131
|
+
its line-number anchors, or \`get_repository_map\` if the ask was really about orientation in an
|
|
132
|
+
unfamiliar area.
|
|
133
|
+
- \`locate\` came up empty for a file you already know → try \`outline_file_symbols\` on it directly
|
|
134
|
+
instead of assuming the symbol isn't there.
|
|
135
|
+
- A coupling/"what depends on this" question came up empty from \`context_search\`/\`locate\` → try
|
|
136
|
+
\`query_module_dependencies\` on the file in question.
|
|
137
|
+
- Any symbol-shaped query came up empty as a natural-language \`prompt\` → retry it as \`locate\` with
|
|
138
|
+
the exact identifier instead, in case the phrasing (not the index) was the problem.
|
|
139
|
+
Only once that alternate Harmony tool has also failed to turn up anything relevant should you fall
|
|
140
|
+
back to local tools (rg, Read, etc.) for that specific lookup — this is a last resort, not the second
|
|
141
|
+
thing you try. After a good Harmony result (from either the first or the alternate tool), proceed
|
|
142
|
+
straight to the edit/answer — don't re-derive context you just fetched, and don't Read() a whole file
|
|
143
|
+
the tool already covered.
|
|
130
144
|
`.trim();
|
|
131
145
|
|
|
132
146
|
const EFFICIENCY_RULES = `
|
|
133
147
|
Efficiency — once a query is already well-formed (after refinement above), apply these to keep tool
|
|
134
148
|
calls fast and non-redundant:
|
|
135
|
-
- Don't repeat calls — before calling context_search/locate
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
calling again.
|
|
149
|
+
- Don't repeat calls — before calling context_search/locate, check whether this exact (prompt,
|
|
150
|
+
file_path, workspaceId) combination was already issued earlier in this task; if so, reuse that
|
|
151
|
+
earlier result instead of calling again.
|
|
139
152
|
- Fan out independent lookups in parallel — when a task needs context on two or more genuinely
|
|
140
153
|
unrelated things (e.g. "how does auth work and how does logging work"), or when refinement above
|
|
141
154
|
produced multiple plausible variant queries for one ambiguous category, issue those calls together
|
|
@@ -147,8 +160,8 @@ calls fast and non-redundant:
|
|
|
147
160
|
queries, where a small limit risks cutting off the right result.
|
|
148
161
|
- Skip redundant ranking on retries — if a symbol's existence and rough location were already
|
|
149
162
|
confirmed by an earlier context_search/locate result this task, a later lookup for that same
|
|
150
|
-
symbol can go straight to
|
|
151
|
-
|
|
163
|
+
symbol can go straight to locate for its line numbers instead of re-running context_search's
|
|
164
|
+
general-purpose ranking pass again.
|
|
152
165
|
`.trim();
|
|
153
166
|
|
|
154
167
|
const SETUP_INSTRUCTIONS = `
|
|
@@ -166,8 +179,7 @@ Workspace setup — before the first search/locate/context call in a project:
|
|
|
166
179
|
HTTP request succeeded. The response's \`ready\` field is only true once the backend confirms both
|
|
167
180
|
text and symbols are indexed.
|
|
168
181
|
- If \`ready\` is false, read \`indexStatus\` and the \`response\` text and relay them to the user in
|
|
169
|
-
plain language before relying on locate/context_search
|
|
170
|
-
explain_subsystem results. If it says indexing is still
|
|
182
|
+
plain language before relying on locate/context_search results. If it says indexing is still
|
|
171
183
|
running (the common case for large repos — the time budget ran out before the backend finished),
|
|
172
184
|
this is expected and not a failure: tell the user briefly, then call \`setup_workspace\` again
|
|
173
185
|
after a short wait to re-check — repeat until \`ready\` is true. If it instead reports only
|
|
@@ -176,7 +188,8 @@ Workspace setup — before the first search/locate/context call in a project:
|
|
|
176
188
|
`.trim();
|
|
177
189
|
|
|
178
190
|
const AUTH_INSTRUCTIONS = `
|
|
179
|
-
Auth gate — context_search, locate,
|
|
191
|
+
Auth gate — context_search, locate, query_module_dependencies, outline_file_symbols, and
|
|
192
|
+
get_repository_map all
|
|
180
193
|
return a "not authenticated" error until login has succeeded; run the login flow below before
|
|
181
194
|
using them. setup_workspace is the one exception: call it directly even before logging in — it
|
|
182
195
|
uses the login session when one exists, but some deployments authenticate the workspace
|
package/src/toolSchemas.js
CHANGED
|
@@ -45,7 +45,7 @@ export const TOOLS = [
|
|
|
45
45
|
"Set up AND fully index the current workspace on the backend in a single call (creates the workspace " +
|
|
46
46
|
"if needed, then zips and uploads the codebase). Safe to call repeatedly — already-completed steps are " +
|
|
47
47
|
"skipped, so calling it again after it has already succeeded is a cheap no-op. Required once per " +
|
|
48
|
-
"project before context_search
|
|
48
|
+
"project before context_search or locate will work. " +
|
|
49
49
|
"If it fails partway (e.g. the upload step " +
|
|
50
50
|
"times out) after the workspace was already created, just call it again — language/buildTool can be " +
|
|
51
51
|
"omitted on that retry, since they're remembered from the first call.",
|
|
@@ -77,27 +77,12 @@ export const TOOLS = [
|
|
|
77
77
|
"exact line range per symbol — deliberately WITHOUT embedded source code, the same way graphify's " +
|
|
78
78
|
"query/explain primitives work. Try this BEFORE locate; only fall back to locate if context_search's " +
|
|
79
79
|
"result is empty, insufficient, or you specifically need its line-number-only anchors for a targeted " +
|
|
80
|
-
"edit.
|
|
81
|
-
"'find me the code for X', reach directly for explain_symbol/path_between/explain_subsystem instead — " +
|
|
82
|
-
"don't route through context_search first just to warm up. Treat context_search as the always-on default " +
|
|
80
|
+
"edit. Treat context_search as the always-on default " +
|
|
83
81
|
"entry point for every new discovery/comprehension need that comes up during a task — call it again " +
|
|
84
82
|
"each time one arises, not just once. Whenever you do fall back to locate, don't " +
|
|
85
83
|
"discard what this call already found: carry its matched symbols, identifiers, and file paths forward " +
|
|
86
84
|
"and combine them with the user's original query to build that tool's input, rather than re-issuing " +
|
|
87
|
-
"the raw query alone
|
|
88
|
-
"RESPONSE SHAPE: the XML response has two separate top-level parts. <Hits><Hit>...</Hit></Hits> is the " +
|
|
89
|
-
"location index — each Hit's <codeSnippet> is a compact table of contents for that file (one line per " +
|
|
90
|
-
"symbol: decorators, kind, name, and its exact lines{start:end} range), and <lineNumbers> pins the " +
|
|
91
|
-
"specific symbol this Hit matched to its own exact range. NEITHER field contains real source lines. " +
|
|
92
|
-
"Once you've decided which hit(s) actually matter, use your own file-read tool on the given file path " +
|
|
93
|
-
"and line range to see the real code — do not answer the user's question from <codeSnippet> alone, " +
|
|
94
|
-
"and never present a lines{a:b} header line as if it were the method body. The sibling " +
|
|
95
|
-
"<harmony_telemetry> block (filesBundledCount, graphEdgesResolved, processingTimeMs, " +
|
|
96
|
-
"estimatedSecondsSaved, estimatedLoopsBypassed, estimatedTokensSaved) is just an operational efficiency " +
|
|
97
|
-
"snapshot of the search itself — not a search result and not code context. Never merge, count, or cite " +
|
|
98
|
-
"<harmony_telemetry> fields as if they were part of <Hits>. If you mention telemetry at all, present it " +
|
|
99
|
-
"separately and clearly labeled (e.g. as a short aside/footnote about how the search performed), and " +
|
|
100
|
-
"only when it's actually relevant to what the user asked — don't surface it by default on every call.",
|
|
85
|
+
"the raw query alone.",
|
|
101
86
|
inputSchema: {
|
|
102
87
|
type: "object",
|
|
103
88
|
properties: {
|
|
@@ -125,7 +110,7 @@ export const TOOLS = [
|
|
|
125
110
|
description:
|
|
126
111
|
"Given a natural language query or exact identifier, returns ultra-light symbol coordinate anchors " +
|
|
127
112
|
"(file path, symbol name, symbol kind/type, whether it's a definition, line numbers, primary role) — " +
|
|
128
|
-
"
|
|
113
|
+
"plus the declaration's own decorator — never source code. Use this to find WHICH FILE(S) and exact line(s) to look at or " +
|
|
129
114
|
"edit for a task, e.g. every occurrence of a name across the codebase, or (scoped with file_path) " +
|
|
130
115
|
"exact line numbers within a file you already know. It does not return full file content — Read() the " +
|
|
131
116
|
"file once you have the line numbers if you need surrounding context beyond what the anchor tells you. " +
|
|
@@ -157,7 +142,7 @@ export const TOOLS = [
|
|
|
157
142
|
},
|
|
158
143
|
limit: {
|
|
159
144
|
type: "number",
|
|
160
|
-
description: "Maximum number of results to return (default
|
|
145
|
+
description: "Maximum number of results to return (default 10). The result list is never padded to this size.",
|
|
161
146
|
},
|
|
162
147
|
workspaceId: WORKSPACE_ID_PROPERTY,
|
|
163
148
|
},
|
|
@@ -165,93 +150,83 @@ export const TOOLS = [
|
|
|
165
150
|
},
|
|
166
151
|
},
|
|
167
152
|
{
|
|
168
|
-
name: "
|
|
153
|
+
name: "query_module_dependencies",
|
|
169
154
|
description:
|
|
170
|
-
"Given
|
|
171
|
-
"
|
|
172
|
-
"
|
|
173
|
-
"
|
|
174
|
-
"without falling back to reading every file that might reference it.\n\n" +
|
|
175
|
-
"DISAMBIGUATION: common names (e.g. an interface method like 'processCommand' implemented by " +
|
|
176
|
-
"hundreds of classes) can match many definitions — the response is a list, one item per match. " +
|
|
177
|
-
"If you already know roughly where the symbol lives, pass file_path to narrow it to the exact one " +
|
|
178
|
-
"you mean instead of scanning every item in the list.",
|
|
155
|
+
"Given a file path, returns its directed import/inheritance dependencies: every in-workspace " +
|
|
156
|
+
"file it depends on, and every file that depends on it. Use this INSTEAD of manually grepping " +
|
|
157
|
+
"import statements across files to check coupling or trace architectural boundaries before " +
|
|
158
|
+
"touching a shared file.",
|
|
179
159
|
inputSchema: {
|
|
180
160
|
type: "object",
|
|
181
161
|
properties: {
|
|
182
|
-
prompt: {
|
|
183
|
-
type: "string",
|
|
184
|
-
description: "REQUIRED. The exact symbol name to explain (e.g. a method or class name).",
|
|
185
|
-
},
|
|
186
162
|
file_path: {
|
|
187
163
|
type: "string",
|
|
164
|
+
description: "REQUIRED. The relative file path whose dependencies should be resolved.",
|
|
165
|
+
},
|
|
166
|
+
depth: {
|
|
167
|
+
type: "number",
|
|
188
168
|
description:
|
|
189
|
-
"
|
|
190
|
-
"(e.g. \"DisburseWorkingCapitalLoanCommandHandler\" to pick that class's processCommand out of " +
|
|
191
|
-
"hundreds of others with the same name).",
|
|
169
|
+
"Traversal depth: 1 (default) for direct dependencies only, 2 for one further transitive hop.",
|
|
192
170
|
},
|
|
193
171
|
workspaceId: WORKSPACE_ID_PROPERTY,
|
|
194
172
|
},
|
|
195
|
-
required: ["
|
|
173
|
+
required: ["file_path"],
|
|
196
174
|
},
|
|
197
175
|
},
|
|
198
176
|
{
|
|
199
|
-
name: "
|
|
177
|
+
name: "outline_file_symbols",
|
|
200
178
|
description:
|
|
201
|
-
"
|
|
202
|
-
"
|
|
203
|
-
"
|
|
204
|
-
"
|
|
205
|
-
"definition you meant (common names like interface method implementations can have hundreds of " +
|
|
206
|
-
"matches — try again with from_file_path/to_file_path once you know roughly where each symbol " +
|
|
207
|
-
"lives), or that the call site was ambiguous and intentionally left unresolved at index time (see " +
|
|
208
|
-
"explain_symbol's unresolved_call_targets).",
|
|
179
|
+
"Extracts a file's structural skeleton — every definition's signature line, docstring, and " +
|
|
180
|
+
"line number, with implementation bodies omitted. Use this INSTEAD of reading the whole file " +
|
|
181
|
+
"with Read() when you only need to understand a file's interface and capabilities, not its " +
|
|
182
|
+
"execution logic.",
|
|
209
183
|
inputSchema: {
|
|
210
184
|
type: "object",
|
|
211
185
|
properties: {
|
|
212
|
-
|
|
213
|
-
type: "string",
|
|
214
|
-
description: "REQUIRED. The starting symbol's exact name.",
|
|
215
|
-
},
|
|
216
|
-
to: {
|
|
217
|
-
type: "string",
|
|
218
|
-
description: "REQUIRED. The target symbol's exact name to find a path to.",
|
|
219
|
-
},
|
|
220
|
-
from_file_path: {
|
|
186
|
+
file_path: {
|
|
221
187
|
type: "string",
|
|
222
|
-
description: "
|
|
188
|
+
description: "REQUIRED. Relative path to the source file (e.g. 'src/main/java/app/OrderService.java').",
|
|
223
189
|
},
|
|
224
|
-
|
|
225
|
-
type: "
|
|
226
|
-
description:
|
|
190
|
+
include_private: {
|
|
191
|
+
type: "boolean",
|
|
192
|
+
description:
|
|
193
|
+
"Whether to include symbols that look private/unexported. Default false (exported-only) " +
|
|
194
|
+
"to preserve token economy.",
|
|
227
195
|
},
|
|
228
196
|
workspaceId: WORKSPACE_ID_PROPERTY,
|
|
229
197
|
},
|
|
230
|
-
required: ["
|
|
198
|
+
required: ["file_path"],
|
|
231
199
|
},
|
|
232
200
|
},
|
|
233
201
|
{
|
|
234
|
-
name: "
|
|
202
|
+
name: "get_repository_map",
|
|
235
203
|
description:
|
|
236
|
-
"
|
|
237
|
-
"
|
|
238
|
-
"
|
|
239
|
-
"
|
|
240
|
-
"context_search calls.",
|
|
204
|
+
"Generates a ranked, token-budgeted architectural map of the repository: the most " +
|
|
205
|
+
"structurally important files (by call-graph centrality and subsystem clustering) and their " +
|
|
206
|
+
"top symbols. Use this tool FIRST when working in an unfamiliar codebase or subsystem, to " +
|
|
207
|
+
"understand project layout and find relevant modules, INSTEAD of manual directory traversals " +
|
|
208
|
+
"or a string of unscoped context_search calls.",
|
|
241
209
|
inputSchema: {
|
|
242
210
|
type: "object",
|
|
243
211
|
properties: {
|
|
244
|
-
|
|
245
|
-
type: "
|
|
246
|
-
|
|
212
|
+
focus_files: {
|
|
213
|
+
type: "array",
|
|
214
|
+
items: { type: "string" },
|
|
215
|
+
description:
|
|
216
|
+
"Optional list of relative file paths to prioritize (e.g. files currently open or " +
|
|
217
|
+
"mentioned in the user's prompt) — ranked ahead of everything else.",
|
|
247
218
|
},
|
|
248
|
-
|
|
219
|
+
max_tokens: {
|
|
249
220
|
type: "number",
|
|
250
|
-
description: "
|
|
221
|
+
description: "Maximum token budget for the returned map (default 1024).",
|
|
222
|
+
},
|
|
223
|
+
directory_filter: {
|
|
224
|
+
type: "string",
|
|
225
|
+
description: "Optional relative subdirectory to scope the map to (e.g. 'src/backend').",
|
|
251
226
|
},
|
|
252
227
|
workspaceId: WORKSPACE_ID_PROPERTY,
|
|
253
228
|
},
|
|
254
|
-
required: [
|
|
229
|
+
required: [],
|
|
255
230
|
},
|
|
256
231
|
},
|
|
257
232
|
];
|