consult-mcp 1.2.2 → 1.2.3
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 +18 -10
- package/dist/adapters/agy.js +82 -111
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@ npx -y consult-mcp@latest install
|
|
|
23
23
|
|
|
24
24
|
This registers consult with every agent CLI it finds on your `PATH` (`claude`, `codex`, `grok`), at user scope. Restart running agent sessions afterwards.
|
|
25
25
|
|
|
26
|
-
Antigravity (`agy`) is an advisor only. consult doesn't register itself with agy, because agy
|
|
26
|
+
Antigravity (`agy`) is an advisor only. consult doesn't register itself with agy, because agy advisors run with every MCP tool denied ([details](#how-advisors-are-contained)). If you install agy after consult, re-run `install` so the server's `PATH` includes it.
|
|
27
27
|
|
|
28
28
|
**It stays up to date.** Hosts launch the server with `npx -y consult-mcp@latest serve`, so each new agent session runs the latest release. Re-running `install` is safe: it replaces an existing registration, including ones written by older versions.
|
|
29
29
|
|
|
@@ -37,7 +37,7 @@ Requirements: Node 22 or later on macOS, Linux or Windows, and at least one of t
|
|
|
37
37
|
|
|
38
38
|
On Windows, everything except [live sessions](#live-sessions) and [session messages](#session-messages) works: those find sessions with `ps` and `lsof` and deliver messages through POSIX shell hooks, so they stay off there. consult never runs an advisor through `cmd.exe`, which would reinterpret characters like `&` and `%` in a question: for a CLI installed as an npm `.cmd` shim it runs the script or binary the shim points at directly.
|
|
39
39
|
|
|
40
|
-
Check the setup with `npx -y consult-mcp@latest doctor`. It reports each agent CLI and its version, whether consult is registered with it, your settings, the message hooks and whether agy
|
|
40
|
+
Check the setup with `npx -y consult-mcp@latest doctor`. It reports each agent CLI and its version, whether consult is registered with it, your settings, the message hooks and whether agy can run read-only (its version and any repository hooks), with a fix for each problem. `doctor --ask` also sends each advisor a one-word question, which shows that its CLI is signed in and can answer.
|
|
41
41
|
|
|
42
42
|
<details>
|
|
43
43
|
<summary>What install changes</summary>
|
|
@@ -180,23 +180,31 @@ Turn it on with `npx -y consult-mcp@latest settings`; it applies to agent sessio
|
|
|
180
180
|
|
|
181
181
|
## How advisors are contained
|
|
182
182
|
|
|
183
|
-
Every advisor runs headless and read-only, and
|
|
183
|
+
Every advisor runs headless and read-only, and can't use MCP servers. So an advisor can't call consult again, which prevents loops.
|
|
184
184
|
|
|
185
185
|
| CLI | Flags |
|
|
186
186
|
| --- | --- |
|
|
187
187
|
| claude | `-p --restricted --tools Read,Grep,Glob --strict-mcp-config` |
|
|
188
188
|
| codex | `exec`, `sandbox_mode="read-only"`, `approval_policy="never"`, plugins off, and every enabled MCP server disabled by name (Codex runs MCP tools outside its sandbox) |
|
|
189
189
|
| grok | `--tools read_file,grep,list_dir --disallowed-tools Agent,search_tool,use_tool` (the MCP helper tools can reach servers that write files) |
|
|
190
|
-
| agy | `-p --output-format stream-json --disable-slash-commands
|
|
190
|
+
| agy | `-p --output-format stream-json --disable-slash-commands --settings` with the permission rules below, on agy 1.5.14 or later |
|
|
191
191
|
|
|
192
|
-
agy has no flags
|
|
192
|
+
agy has no flags that remove tools (`--mode plan` and `--sandbox` leave write, shell, browser and MCP tools on). It does have `--settings`, which overrides `settings.json` for one session, and permission deny rules, which win over `toolPermission`, allow rules and hooks that approve a tool call. So every call passes:
|
|
193
193
|
|
|
194
|
-
|
|
195
|
-
-
|
|
196
|
-
|
|
197
|
-
|
|
194
|
+
```json
|
|
195
|
+
{"toolPermission": "request-review", "permissions": {"allow": [], "deny": ["command(*)", "write_file(*)", "mcp(*)", "read_url(*)", "download_url(*)", "execute_url(*)"]}}
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
This denies shell commands and the Python that `run_workflow` runs, file writes and edits, every MCP tool (including plugin servers), and URL reads, downloads and opens. Subagents inherit it. The browser needs the `/browser` slash command, which `--disable-slash-commands` turns off. It doesn't depend on your own agy config: `always-proceed`, allow rules, MCP servers and plugins can stay as they are. MCP servers still start, but agy can't call their tools, and your global hooks still run their commands. `request-review` alone isn't enough: headless agy still writes files in the workspace under it.
|
|
199
|
+
|
|
200
|
+
consult also refuses to run agy:
|
|
201
|
+
|
|
202
|
+
- older than 1.5.14, the version these rules were first checked against (they were rechecked on 1.5.15);
|
|
203
|
+
- where the repository has agy hooks or plugins: `hooks.json`, `plugins.json` or `plugins/` in a `.agents`, `.agent`, `_agents` or `_agent` directory from `cwd` up to the repository root. `--settings` can't switch hooks off, and a repository's hooks would run its commands. Skills, rules and workflows there are fine.
|
|
204
|
+
|
|
205
|
+
Your own global hooks in `~/.gemini/config/hooks.json` still run, but can't approve past the deny rules. A `PreToolUse` hook that prints `{}` makes agy deny every tool, reads included; when no read gets through, consult reports the hook rather than an answer written blind. A hook should print nothing to leave the decision to agy.
|
|
198
206
|
|
|
199
|
-
|
|
207
|
+
agy is told it is read-only and to avoid `schedule` and background waits, which would hold a headless turn open until the timeout. Its web search tool is not blocked, so search queries go to Google, the same provider that already receives the question. agy can't fork sessions, so it has no live sessions or task dispatch. Resume with `session_id` works through `--conversation`, but agy starts a new conversation if the id is unknown; the reply's `session_id` then differs from the one you passed.
|
|
200
208
|
|
|
201
209
|
`ask_session` copies use the same flags, plus `--resume <id> --fork-session` (claude, grok) or `exec fork <id>` (codex), so the live session's own transcript is only read.
|
|
202
210
|
|
package/dist/adapters/agy.js
CHANGED
|
@@ -1,132 +1,80 @@
|
|
|
1
|
-
import { existsSync, readdirSync,
|
|
2
|
-
import { homedir } from "node:os";
|
|
1
|
+
import { existsSync, readdirSync, realpathSync, statSync } from "node:fs";
|
|
3
2
|
import { dirname, join, resolve } from "node:path";
|
|
4
3
|
import { AdvisorError } from "../types.js";
|
|
5
4
|
import { parseJsonLines } from "../jsonl.js";
|
|
6
|
-
// agy (Google Antigravity CLI) has no
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
//
|
|
12
|
-
//
|
|
13
|
-
// -
|
|
14
|
-
const
|
|
15
|
-
export const
|
|
16
|
-
/**
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
];
|
|
23
|
-
/** Customization roots agy honours in every directory from the cwd up to the project root. */
|
|
5
|
+
// agy (Google Antigravity CLI) has no flags that remove tools, but --settings overrides settings.json for one
|
|
6
|
+
// session, and permission deny rules beat everything else: toolPermission, allow rules (global or ours) and
|
|
7
|
+
// PreToolUse hooks that answer "allow". Every call passes these rules, so containment does not depend on the
|
|
8
|
+
// user's own agy config. Covered: shell commands and run_workflow's Python (command), file writes and edits
|
|
9
|
+
// (write_file), MCP tools including plugin servers (mcp), and URL reads, downloads and opens; subagents inherit them.
|
|
10
|
+
// MCP servers still start, but none of their tools can be called. agy rejects "unsandboxed" rules from users, and
|
|
11
|
+
// the browser needs the /browser slash command, which --disable-slash-commands turns off. toolPermission
|
|
12
|
+
// "request-review" and an empty allow list are belt and braces: request-review alone lets headless agy write files.
|
|
13
|
+
const DENY = ["command(*)", "write_file(*)", "mcp(*)", "read_url(*)", "download_url(*)", "execute_url(*)"];
|
|
14
|
+
export const CONTAINMENT_SETTINGS = JSON.stringify({ toolPermission: "request-review", permissions: { allow: [], deny: DENY } });
|
|
15
|
+
/** The oldest agy these deny rules were verified against. Older versions are refused rather than trusted. */
|
|
16
|
+
export const MIN_AGY_VERSION = "1.5.14";
|
|
17
|
+
// Hooks still run their commands for every tool call, and --settings cannot switch them off. The user's own global
|
|
18
|
+
// hooks are theirs to run, but a repository's hooks and plugins would run code from whatever repo the advisor is
|
|
19
|
+
// pointed at, so consult refuses to run agy where they exist. agy reads them from these roots in every directory
|
|
20
|
+
// from the cwd up to the project root.
|
|
24
21
|
const WORKSPACE_ROOTS = [".agents", ".agent", "_agents", "_agent"];
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
const NO_PLUGINS = /^No imported plugins\.?$/;
|
|
29
|
-
function settingsProblems(text) {
|
|
30
|
-
let settings = {};
|
|
31
|
-
if (text !== undefined) {
|
|
32
|
-
try {
|
|
33
|
-
settings = JSON.parse(text);
|
|
34
|
-
}
|
|
35
|
-
catch {
|
|
36
|
-
return [`could not parse ${AGY_SETTINGS}`];
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
if (typeof settings !== "object" || settings === null || Array.isArray(settings))
|
|
40
|
-
return [`${AGY_SETTINGS} is not a JSON object`];
|
|
41
|
-
const { toolPermission, permissions } = settings;
|
|
42
|
-
const allow = permissions?.allow;
|
|
43
|
-
return [
|
|
44
|
-
...(toolPermission === undefined || REVIEWED.includes(toolPermission)
|
|
45
|
-
? []
|
|
46
|
-
: [`toolPermission is ${JSON.stringify(toolPermission)}, not "request-review"`]),
|
|
47
|
-
...(allow === undefined || (Array.isArray(allow) && allow.length === 0) ? [] : ["permissions.allow is not empty"]),
|
|
48
|
-
];
|
|
49
|
-
}
|
|
50
|
-
/** Names of MCP servers in an `agy mcp list` table whose status is not "disabled"; undefined if there is no table. */
|
|
51
|
-
function enabledMcpServers(out) {
|
|
52
|
-
const [header, ...rows] = out.split("\n").filter((l) => l.trim());
|
|
53
|
-
const typeCol = header?.indexOf("TYPE") ?? -1;
|
|
54
|
-
const statusCol = header?.indexOf("STATUS") ?? -1;
|
|
55
|
-
if (!header?.startsWith("NAME") || typeCol < 0 || statusCol < 0)
|
|
56
|
-
return undefined;
|
|
57
|
-
return rows.filter((row) => row.slice(statusCol).trim().split(/\s+/)[0] !== "disabled").map((row) => row.slice(0, typeCol).trim());
|
|
58
|
-
}
|
|
59
|
-
/** Why agy would not run read-only and MCP-free with this config. Empty when it would. */
|
|
60
|
-
export function containmentProblems(config) {
|
|
61
|
-
const servers = enabledMcpServers(config.mcpList);
|
|
62
|
-
return [
|
|
63
|
-
...settingsProblems(config.settings),
|
|
64
|
-
...(servers === undefined ? ["could not read the output of `agy mcp list`"] : []),
|
|
65
|
-
...(servers?.length ? [`MCP servers enabled: ${servers.join(", ")}`] : []),
|
|
66
|
-
...(NO_PLUGINS.test(config.pluginList.trim()) ? [] : ["plugins are imported (see `agy plugin list`)"]),
|
|
67
|
-
...(config.customizations.length ? [`hooks or plugins could load from ${config.customizations.join(", ")}`] : []),
|
|
68
|
-
];
|
|
69
|
-
}
|
|
70
|
-
function readIfExists(file) {
|
|
71
|
-
try {
|
|
72
|
-
return readFileSync(file, "utf8");
|
|
73
|
-
}
|
|
74
|
-
catch (err) {
|
|
75
|
-
if (err.code === "ENOENT")
|
|
76
|
-
return undefined;
|
|
77
|
-
throw new AdvisorError(`could not read ${file}: ${err instanceof Error ? err.message : String(err)}`);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
/** A file with content, or a directory with entries. Unreadable paths count as present, so the check fails closed. */
|
|
22
|
+
const WORKSPACE_HOOKS = ["hooks.json", "plugins.json", "plugins"];
|
|
23
|
+
const VERSION_OPTS = { timeoutMs: 30_000 };
|
|
24
|
+
/** A non-empty file, or a directory with entries. Unreadable paths count as present, so the check fails closed. */
|
|
81
25
|
function present(path) {
|
|
82
26
|
try {
|
|
83
|
-
|
|
27
|
+
const stat = statSync(path);
|
|
28
|
+
return stat.isDirectory() ? readdirSync(path).length > 0 : stat.size > 0;
|
|
84
29
|
}
|
|
85
30
|
catch (err) {
|
|
86
31
|
return err.code !== "ENOENT";
|
|
87
32
|
}
|
|
88
33
|
}
|
|
89
|
-
/** The cwd and its parents up to the nearest directory holding .git, or just the cwd outside a repository. */
|
|
34
|
+
/** The real cwd and its parents up to the nearest directory holding .git, or just the cwd outside a repository. */
|
|
90
35
|
function projectDirs(cwd) {
|
|
36
|
+
// agy runs in the real directory, so walk its parents rather than those of a symlink pointing into a repository.
|
|
37
|
+
const start = realpathSync(resolve(cwd));
|
|
91
38
|
const dirs = [];
|
|
92
|
-
for (let dir =
|
|
39
|
+
for (let dir = start;; dir = dirname(dir)) {
|
|
93
40
|
dirs.push(dir);
|
|
94
41
|
if (existsSync(join(dir, ".git")))
|
|
95
42
|
return dirs;
|
|
96
43
|
if (dirname(dir) === dir)
|
|
97
|
-
return [
|
|
44
|
+
return [start];
|
|
98
45
|
}
|
|
99
46
|
}
|
|
100
|
-
/**
|
|
101
|
-
export function
|
|
102
|
-
|
|
103
|
-
|
|
47
|
+
/** Repository hook and plugin paths agy would load for a call in `cwd`. */
|
|
48
|
+
export function findWorkspaceHooks(cwd) {
|
|
49
|
+
return projectDirs(cwd)
|
|
50
|
+
.flatMap((dir) => WORKSPACE_ROOTS.flatMap((root) => WORKSPACE_HOOKS.map((name) => join(dir, root, name))))
|
|
51
|
+
.filter(present);
|
|
104
52
|
}
|
|
105
|
-
/**
|
|
106
|
-
export function
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
const problems = containmentProblems({
|
|
115
|
-
settings: readIfExists(settingsFile),
|
|
116
|
-
mcpList: await list("mcp"),
|
|
117
|
-
pluginList: await list("plugin"),
|
|
118
|
-
customizations: findCustomizations(cwd, globals),
|
|
119
|
-
});
|
|
120
|
-
if (problems.length > 0) {
|
|
121
|
-
throw new AdvisorError(`agy's config is not read-only, so consult will not run it: ${problems.join("; ")}. ` +
|
|
122
|
-
`Set "toolPermission": "request-review" and remove permissions.allow in ${settingsFile}, ` +
|
|
123
|
-
"disable MCP servers with `agy mcp disable <name>`, and remove hooks and plugins.");
|
|
124
|
-
}
|
|
125
|
-
return [];
|
|
126
|
-
};
|
|
53
|
+
/** True when `version` (e.g. "1.5.14" or "agy 1.5.14", a release, not a prerelease) is at least `min`. */
|
|
54
|
+
export function versionAtLeast(version, min) {
|
|
55
|
+
const parse = (v) => v.trim().match(/^(?:agy\s+)?(\d+)\.(\d+)\.(\d+)$/)?.slice(1).map(Number);
|
|
56
|
+
const have = parse(version);
|
|
57
|
+
const want = parse(min);
|
|
58
|
+
if (!have)
|
|
59
|
+
return false;
|
|
60
|
+
const diff = have.map((n, i) => n - want[i]).find((d) => d !== 0) ?? 0;
|
|
61
|
+
return diff >= 0;
|
|
127
62
|
}
|
|
128
|
-
|
|
129
|
-
const
|
|
63
|
+
/** Throws unless agy is new enough for the deny rules and no repository hooks or plugins would load. Adds no args. */
|
|
64
|
+
const prepare = async (run, cwd, signal) => {
|
|
65
|
+
const res = await run("agy", ["--version"], { cwd, signal, ...VERSION_OPTS });
|
|
66
|
+
const version = res.stdout.trim();
|
|
67
|
+
if (res.code !== 0 || !versionAtLeast(version, MIN_AGY_VERSION)) {
|
|
68
|
+
throw new AdvisorError(`consult needs agy ${MIN_AGY_VERSION} or later to keep it read-only (found ${version || "no version"}); run \`agy update\``);
|
|
69
|
+
}
|
|
70
|
+
const hooks = findWorkspaceHooks(cwd);
|
|
71
|
+
if (hooks.length > 0) {
|
|
72
|
+
throw new AdvisorError(`consult will not run agy here: this repository has agy hooks or plugins, which would run its commands (${hooks.join(", ")})`);
|
|
73
|
+
}
|
|
74
|
+
return [];
|
|
75
|
+
};
|
|
76
|
+
// The model cannot see the deny rules, and `schedule` or background waits hold a headless turn open until timeout.
|
|
77
|
+
const TOOLS_NOTE = "You are advising read-only. Use read_file to read files and directories. Shell commands, file writes and edits, URL reads and MCP tools are denied here. Do not use schedule, wait or background tasks.";
|
|
130
78
|
function invocation(request, prompt) {
|
|
131
79
|
return {
|
|
132
80
|
command: "agy",
|
|
@@ -134,20 +82,43 @@ function invocation(request, prompt) {
|
|
|
134
82
|
"-p", `${TOOLS_NOTE}\n\n${prompt}`,
|
|
135
83
|
"--output-format", "stream-json",
|
|
136
84
|
"--disable-slash-commands",
|
|
85
|
+
"--settings", CONTAINMENT_SETTINGS,
|
|
137
86
|
...(request.sessionId ? ["--conversation", request.sessionId] : []),
|
|
138
87
|
...(request.model ? ["--model", request.model] : []),
|
|
139
88
|
...(request.effort ? ["--effort", request.effort] : []),
|
|
140
89
|
],
|
|
141
90
|
};
|
|
142
91
|
}
|
|
92
|
+
const HOOK_DENIAL = "denied by pre-tool hook";
|
|
93
|
+
const READ_TOOLS = new Set(["read_file", "view_file", "list_dir", "grep_search", "find_by_name"]);
|
|
94
|
+
/**
|
|
95
|
+
* Read tools a PreToolUse hook denied, when no read got through. A hook that prints `{}` denies every tool call,
|
|
96
|
+
* reads included; an answer written after that was written blind. A hook that blocks only some files is left alone.
|
|
97
|
+
*/
|
|
98
|
+
function blindedByHook(events) {
|
|
99
|
+
const reads = events.flatMap((e) => {
|
|
100
|
+
const step = e.step_update;
|
|
101
|
+
return step?.step_type === "tool" && step.tool_name && READ_TOOLS.has(step.tool_name) ? [step] : [];
|
|
102
|
+
});
|
|
103
|
+
if (reads.some((step) => step.state === "DONE"))
|
|
104
|
+
return [];
|
|
105
|
+
const denied = reads.filter((step) => step.tool_info?.error?.message?.includes(HOOK_DENIAL)).map((step) => step.tool_name);
|
|
106
|
+
return [...new Set(denied)];
|
|
107
|
+
}
|
|
143
108
|
function parse(stdout) {
|
|
144
|
-
const
|
|
109
|
+
const events = parseJsonLines(stdout);
|
|
110
|
+
const result = events.findLast((e) => e.event === "result")?.result;
|
|
145
111
|
if (!result)
|
|
146
112
|
throw new AdvisorError(`agy returned no result: ${stdout.slice(0, 500)}`);
|
|
147
113
|
if (result.status !== "SUCCESS")
|
|
148
114
|
throw new AdvisorError(`agy reported an error: ${String(result.error || result.status || "unknown error")}`);
|
|
115
|
+
const hooked = blindedByHook(events);
|
|
116
|
+
if (hooked.length > 0) {
|
|
117
|
+
// The answer would be written without the files it tried to read, so it is not worth returning.
|
|
118
|
+
throw new AdvisorError(`an agy hook denied ${hooked.join(", ")}, so agy could not read the repository. ` +
|
|
119
|
+
"Check the PreToolUse hooks in ~/.gemini/config/hooks.json and agy plugins: a hook that prints {} denies every tool; it should print nothing to leave the decision to agy.");
|
|
120
|
+
}
|
|
149
121
|
if (typeof result.response !== "string" || !result.response.trim() || typeof result.conversation_id !== "string" || !result.conversation_id) {
|
|
150
|
-
// agy ends the turn without an answer when it is denied a tool, so say which.
|
|
151
122
|
const denied = (result.denied_actions ?? []).map((d) => String(d.action));
|
|
152
123
|
throw new AdvisorError(denied.length ? `agy stopped without an answer after being denied: ${denied.join(", ")}` : "agy returned no answer");
|
|
153
124
|
}
|
|
@@ -172,7 +143,7 @@ function describe(event) {
|
|
|
172
143
|
export const agy = {
|
|
173
144
|
name: "agy",
|
|
174
145
|
command: "agy",
|
|
175
|
-
prepare
|
|
146
|
+
prepare,
|
|
176
147
|
build(request, prompt) {
|
|
177
148
|
return invocation(request, prompt);
|
|
178
149
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "consult-mcp",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.3",
|
|
4
4
|
"mcpName": "io.github.neelsatyavolu/consult",
|
|
5
5
|
"description": "Get a second opinion on your code from every coding agent you have. Claude Code, Codex and Grok review each other's diffs and answer each other's questions, even inside a session that's already running. Uses the CLIs you're signed in to, no API keys.",
|
|
6
6
|
"keywords": [
|