agent-gate-installer 1.1.1 → 1.3.0

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.
Files changed (2) hide show
  1. package/bin/install.mjs +61 -3
  2. package/package.json +1 -1
package/bin/install.mjs CHANGED
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  import { execSync } from "node:child_process";
4
- import { existsSync, mkdirSync, readFileSync, writeFileSync, rmSync } from "node:fs";
4
+ import { existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync, rmSync } from "node:fs";
5
5
  import { createInterface } from "node:readline";
6
6
  import { join } from "node:path";
7
- import { homedir, platform } from "node:os";
7
+ import { homedir, platform, tmpdir } from "node:os";
8
8
 
9
9
  const CLAUDE_HOME = join(homedir(), ".claude");
10
10
  const INSTALL_DIR = join(CLAUDE_HOME, "agent-gate");
@@ -122,6 +122,21 @@ function mergeHooks(settings, venvPython) {
122
122
  }
123
123
  }
124
124
 
125
+ function writeMcpJson(venvPython, directory) {
126
+ const mcpJsonPath = join(directory, ".mcp.json");
127
+ const config = {
128
+ mcpServers: {
129
+ "agent-gate": {
130
+ type: "stdio",
131
+ command: venvPython,
132
+ args: [join(INSTALL_DIR, "src", "agent_gate", "server.py")],
133
+ },
134
+ },
135
+ };
136
+ writeFileSync(mcpJsonPath, JSON.stringify(config, null, 4) + "\n", "utf8");
137
+ log(` + Wrote .mcp.json to ${directory}`);
138
+ }
139
+
125
140
  function registerMcpServer(settings, venvPython) {
126
141
  settings.mcpServers = settings.mcpServers || {};
127
142
  settings.mcpServers["agent-gate"] = {
@@ -129,7 +144,39 @@ function registerMcpServer(settings, venvPython) {
129
144
  command: venvPython,
130
145
  args: [join(INSTALL_DIR, "src", "agent_gate", "server.py")],
131
146
  };
132
- log(" + Registered agent-gate MCP server");
147
+ log(" + Registered agent-gate MCP server in settings.json");
148
+ }
149
+
150
+ function patchWebMcpConfigs(venvPython) {
151
+ const tmp = tmpdir();
152
+ let patched = 0;
153
+ let files;
154
+ try {
155
+ files = readdirSync(tmp);
156
+ } catch {
157
+ return patched;
158
+ }
159
+
160
+ for (const file of files) {
161
+ if (!file.startsWith("mcp-config-") || !file.endsWith(".json")) continue;
162
+ const filePath = join(tmp, file);
163
+ try {
164
+ const raw = readFileSync(filePath, "utf8");
165
+ const config = JSON.parse(raw);
166
+ if (config.mcpServers?.["agent-gate"]) continue;
167
+ config.mcpServers = config.mcpServers || {};
168
+ config.mcpServers["agent-gate"] = {
169
+ type: "stdio",
170
+ command: venvPython,
171
+ args: [join(INSTALL_DIR, "src", "agent_gate", "server.py")],
172
+ };
173
+ writeFileSync(filePath, JSON.stringify(config) + "\n", "utf8");
174
+ patched++;
175
+ } catch {
176
+ continue;
177
+ }
178
+ }
179
+ return patched;
133
180
  }
134
181
 
135
182
  async function promptForToken() {
@@ -221,6 +268,17 @@ async function install() {
221
268
  registerMcpServer(settings, venvPython);
222
269
  writeSettings(settings);
223
270
 
271
+ writeMcpJson(venvPython, INSTALL_DIR);
272
+ const cwd = process.cwd();
273
+ if (cwd !== INSTALL_DIR && existsSync(join(cwd, "src", "agent_gate"))) {
274
+ writeMcpJson(venvPython, cwd);
275
+ }
276
+
277
+ const webPatched = patchWebMcpConfigs(venvPython);
278
+ if (webPatched > 0) {
279
+ log(` + Patched ${webPatched} web session MCP config(s) in ${tmpdir()}`);
280
+ }
281
+
224
282
  log(" + Verifying installation...");
225
283
  try {
226
284
  run(`"${venvPython}" -c "from agent_gate.server import create_mcp; print('OK')"`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-gate-installer",
3
- "version": "1.1.1",
3
+ "version": "1.3.0",
4
4
  "description": "One-command installer for agent-gate prompt evaluation gate",
5
5
  "type": "module",
6
6
  "bin": {