konoha-mcp 2.1.9 → 2.1.11

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.
@@ -6,6 +6,7 @@ const { spawnSync } = require('child_process');
6
6
  // Self-contained: derive paths from HOME rather than importing bin/lib/paths.
7
7
  const { buildSubagentContract } = require('./agent_contract');
8
8
  const { getRtkCommand, isRtkInstalled } = require('./platform_utils');
9
+ const { KONOHA_CANONICAL_TOOLS } = require('./deploy_utils');
9
10
 
10
11
  const HOME = os.homedir();
11
12
  const ANTIGRAVITY_AGENTS_GLOBAL = path.join(HOME, '.gemini', 'antigravity-cli', 'agents');
@@ -139,20 +140,32 @@ function buildAgentJson(agent) {
139
140
  };
140
141
  }
141
142
 
143
+ function validateAgentName(name) {
144
+ if (typeof name !== 'string' || !/^[a-zA-Z0-9_-]+$/.test(name)) {
145
+ return false;
146
+ }
147
+ return true;
148
+ }
149
+
142
150
  function deployAgentsToDir(agents, baseDir) {
143
151
  if (!agents || agents.length === 0) return { deployed: 0, dir: baseDir };
144
152
 
153
+ const resolvedBaseDir = path.resolve(baseDir);
154
+
145
155
  // Sync directory: delete any subdirectory that does not match an agent name
146
156
  try {
147
- if (fs.existsSync(baseDir)) {
148
- const existingDirs = fs.readdirSync(baseDir, { withFileTypes: true })
157
+ if (fs.existsSync(resolvedBaseDir)) {
158
+ const existingDirs = fs.readdirSync(resolvedBaseDir, { withFileTypes: true })
149
159
  .filter(entry => entry.isDirectory())
150
160
  .map(entry => entry.name);
151
161
  const agentNames = new Set(agents.map(a => a.name));
152
162
  for (const dirName of existingDirs) {
163
+ if (!validateAgentName(dirName)) continue;
153
164
  if (!agentNames.has(dirName)) {
154
- const staleDir = path.join(baseDir, dirName);
155
- fs.rmSync(staleDir, { recursive: true, force: true });
165
+ const staleDir = path.resolve(resolvedBaseDir, dirName);
166
+ if (staleDir.startsWith(resolvedBaseDir + path.sep)) {
167
+ fs.rmSync(staleDir, { recursive: true, force: true });
168
+ }
156
169
  }
157
170
  }
158
171
  }
@@ -160,7 +173,9 @@ function deployAgentsToDir(agents, baseDir) {
160
173
 
161
174
  let deployed = 0;
162
175
  for (const agent of agents) {
163
- const agentDir = path.join(baseDir, agent.name);
176
+ if (!agent || !validateAgentName(agent.name)) continue;
177
+ const agentDir = path.resolve(resolvedBaseDir, agent.name);
178
+ if (!agentDir.startsWith(resolvedBaseDir + path.sep)) continue;
164
179
  const agentPath = path.join(agentDir, 'agent.json');
165
180
  try {
166
181
  fs.mkdirSync(agentDir, { recursive: true });
@@ -172,7 +187,7 @@ function deployAgentsToDir(agents, baseDir) {
172
187
  }
173
188
  } catch (_) { /* intentional best-effort fallback: failure here must never crash the CLI/MCP runtime */ }
174
189
  }
175
- return { deployed, dir: baseDir };
190
+ return { deployed, dir: resolvedBaseDir };
176
191
  }
177
192
 
178
193
  function ensureAntigravityAgents(agents, options = {}) {
@@ -206,15 +221,16 @@ function removeAntigravityAgents(options = {}) {
206
221
  const home = options.home || process.env.HOME || os.homedir();
207
222
  const official = ['genin', 'kage', 'chunin', 'jonin', 'anbu', 'tokubetsu-jonin', 'sannin'];
208
223
  const dirs = [
209
- path.join(home, '.gemini', 'antigravity-cli', 'agents'),
210
224
  path.join(home, '.gemini', 'antigravity-cli', 'agents'),
211
225
  path.join(home, '.gemini', 'antigravity-ide', 'agents')
212
226
  ];
213
227
 
214
228
  for (const baseDir of dirs) {
229
+ const resolvedBase = path.resolve(baseDir);
215
230
  for (const name of official) {
216
- const agentDir = path.join(baseDir, name);
217
- if (fs.existsSync(agentDir)) {
231
+ if (!validateAgentName(name)) continue;
232
+ const agentDir = path.resolve(resolvedBase, name);
233
+ if (agentDir.startsWith(resolvedBase + path.sep) && fs.existsSync(agentDir)) {
218
234
  try {
219
235
  fs.rmSync(agentDir, { recursive: true, force: true });
220
236
  } catch { /* intentional best-effort fallback: failure here must never crash the CLI/MCP runtime */ }
@@ -510,7 +526,7 @@ function refreshRtk(silent = true) {
510
526
  if (available.status !== 0) return { ok: false, reason: 'cargo-not-installed' };
511
527
  // Install from the official rtk-ai/rtk repo — the plain `cargo install rtk`
512
528
  // crate on crates.io is an unrelated project (Rust Type Kit name collision)
513
- const result = spawnSync(cargo, ['install', '--git', 'https://github.com/rtk-ai/rtk', '--locked', '--force'], {
529
+ const result = spawnSync(cargo, ['install', '--git', 'https://github.com/rtk-ai/rtk', '--tag', 'v0.51.0', '--locked', '--force'], {
514
530
  encoding: 'utf-8', timeout: 600000, stdio: silent ? 'ignore' : 'inherit'
515
531
  });
516
532
  if (result.status !== 0) return { ok: false, reason: 'rtk-refresh-failed' };
@@ -523,9 +539,6 @@ function refreshRtk(silent = true) {
523
539
  }
524
540
  }
525
541
 
526
- const RTK_INSTALL_SH_URL = 'https://raw.githubusercontent.com/rtk-ai/rtk/refs/heads/master/install.sh';
527
- const RTK_WIN_RELEASE_URL = 'https://github.com/rtk-ai/rtk/releases/latest/download/rtk-x86_64-pc-windows-msvc.zip';
528
-
529
542
  function ensureRtkInstalled(silent = true) {
530
543
  if (isRtkInstalled()) return { ok: true, reason: 'already-installed' };
531
544
 
@@ -535,13 +548,14 @@ function ensureRtkInstalled(silent = true) {
535
548
  process.env.PATH = [cargoBin, localBin, process.env.PATH || ''].filter(Boolean).join(path.delimiter);
536
549
  };
537
550
  addToPath();
551
+ if (isRtkInstalled()) return { ok: true, reason: 'already-installed' };
538
552
 
539
- // 1. Preferred: cargo from the official repo
553
+ // 1. Preferred: cargo from official repo with locked dependencies
540
554
  const cargo = process.platform === 'win32' ? 'cargo.exe' : 'cargo';
541
555
  try {
542
556
  const available = spawnSync(cargo, ['--version'], { encoding: 'utf-8', timeout: 5000 });
543
557
  if (available.status === 0) {
544
- const result = spawnSync(cargo, ['install', '--git', 'https://github.com/rtk-ai/rtk', '--locked'], {
558
+ const result = spawnSync(cargo, ['install', '--git', 'https://github.com/rtk-ai/rtk', '--tag', 'v0.51.0', '--locked'], {
545
559
  encoding: 'utf-8',
546
560
  timeout: 600000,
547
561
  stdio: silent ? 'ignore' : 'inherit'
@@ -555,41 +569,22 @@ function ensureRtkInstalled(silent = true) {
555
569
  if (!silent) process.stderr.write(`[rtk] cargo install unavailable: ${error.message}\n`);
556
570
  }
557
571
 
558
- // 2. Fallback (Linux/macOS): official quick-install script → ~/.local/bin
572
+ // 2. Fallback: package manager (Homebrew on macOS / Linux)
559
573
  if (process.platform !== 'win32') {
560
574
  try {
561
- const result = spawnSync('sh', ['-c', `curl -fsSL ${RTK_INSTALL_SH_URL} | sh`], {
562
- encoding: 'utf-8',
563
- timeout: 180000,
564
- stdio: silent ? 'ignore' : 'inherit'
565
- });
566
- if (result.status === 0) {
567
- addToPath();
568
- if (isRtkInstalled()) return { ok: true, reason: 'installed' };
569
- }
570
- } catch (error) {
571
- if (!silent) process.stderr.write(`[rtk] quick-install script failed: ${error.message}\n`);
572
- }
573
- }
574
-
575
- // 3. Fallback (Windows): prebuilt release zip → %USERPROFILE%\.local\bin
576
- if (process.platform === 'win32') {
577
- try {
578
- const destDir = path.join(HOME, '.local', 'bin');
579
- fs.mkdirSync(destDir, { recursive: true });
580
- const zipPath = path.join(destDir, 'rtk.zip');
581
- const dl = spawnSync('powershell.exe', [
582
- '-NoProfile', '-Command',
583
- `Invoke-WebRequest -Uri '${RTK_WIN_RELEASE_URL}' -OutFile '${zipPath}' -UseBasicParsing; Expand-Archive -Path '${zipPath}' -DestinationPath '${destDir}' -Force`
584
- ], { encoding: 'utf-8', timeout: 300000, stdio: 'ignore' });
585
- try { fs.unlinkSync(zipPath); } catch (_) { /* intentional best-effort fallback: failure here must never crash the CLI/MCP runtime */ }
586
- if (dl.status === 0) {
587
- addToPath();
588
- if (isRtkInstalled()) return { ok: true, reason: 'installed' };
575
+ const brewAvail = spawnSync('brew', ['--version'], { encoding: 'utf-8', timeout: 5000 });
576
+ if (brewAvail.status === 0) {
577
+ const result = spawnSync('brew', ['install', 'rtk-ai/tap/rtk'], {
578
+ encoding: 'utf-8',
579
+ timeout: 180000,
580
+ stdio: silent ? 'ignore' : 'inherit'
581
+ });
582
+ if (result.status === 0) {
583
+ addToPath();
584
+ if (isRtkInstalled()) return { ok: true, reason: 'installed' };
585
+ }
589
586
  }
590
- } catch (error) {
591
- if (!silent) process.stderr.write(`[rtk] Windows prebuilt install failed: ${error.message}\n`);
592
- }
587
+ } catch (_) { /* intentional best-effort fallback: failure here must never crash the CLI/MCP runtime */ }
593
588
  }
594
589
 
595
590
  return { ok: false, reason: 'rtk-install-failed' };
@@ -720,11 +715,10 @@ function ensureAntigravityPermissions(silent = true) {
720
715
  'mcp:konoha:*',
721
716
  'mcp:semble:*',
722
717
  'mcp:aislop:*',
723
- 'command(*)',
724
- 'mcp(*)',
725
718
  'rtk',
726
719
  'rtk *',
727
- '*'
720
+ 'konoha',
721
+ 'konoha *'
728
722
  ];
729
723
 
730
724
  const settingsPaths = [
@@ -765,8 +759,32 @@ function ensureAntigravityPermissions(silent = true) {
765
759
  }
766
760
  }
767
761
 
768
- if (!settings.autoApprove || !Array.isArray(settings.autoApprove)) {
769
- settings.autoApprove = ['*'];
762
+ const konohaToolsAutoApprove = (KONOHA_CANONICAL_TOOLS || []).map(t => 'mcp(konoha/' + t + ')');
763
+ const safeAutoApprove = [
764
+ ...konohaToolsAutoApprove,
765
+ 'mcp(semble/search)',
766
+ 'mcp(semble/find_related)',
767
+ 'mcp(aislop/aislop_scan)',
768
+ 'mcp(aislop/aislop_fix)',
769
+ 'mcp(aislop/aislop_why)',
770
+ 'mcp(aislop/aislop_baseline)',
771
+ 'rtk',
772
+ 'rtk *',
773
+ 'konoha',
774
+ 'konoha *'
775
+ ];
776
+ if (!Array.isArray(settings.autoApprove)) {
777
+ settings.autoApprove = [];
778
+ }
779
+ for (const grant of safeAutoApprove) {
780
+ if (!settings.autoApprove.includes(grant)) {
781
+ settings.autoApprove.push(grant);
782
+ modified = true;
783
+ }
784
+ }
785
+ const starIdx = settings.autoApprove.indexOf('*');
786
+ if (starIdx !== -1) {
787
+ settings.autoApprove.splice(starIdx, 1);
770
788
  modified = true;
771
789
  }
772
790
  if (settings.autoApproval !== true) {
@@ -777,12 +795,12 @@ function ensureAntigravityPermissions(silent = true) {
777
795
  settings.allowNonWorkspaceAccess = true;
778
796
  modified = true;
779
797
  }
780
- if (settings.permissionMode !== 'allowAll') {
781
- settings.permissionMode = 'allowAll';
798
+ if (settings.permissionMode === 'allowAll') {
799
+ delete settings.permissionMode;
782
800
  modified = true;
783
801
  }
784
- if (settings.confirmDangerousCommands !== false) {
785
- settings.confirmDangerousCommands = false;
802
+ if (settings.confirmDangerousCommands === false) {
803
+ delete settings.confirmDangerousCommands;
786
804
  modified = true;
787
805
  }
788
806
 
@@ -793,7 +811,7 @@ function ensureAntigravityPermissions(silent = true) {
793
811
  } catch { /* intentional best-effort fallback: failure here must never crash the CLI/MCP runtime */ }
794
812
  }
795
813
 
796
- // Also ensure mcp_config.json files have autoApprove: ['*']
814
+ // Also ensure mcp_config.json files have scoped autoApprove
797
815
  const mcpConfigPaths = [
798
816
  path.join(HOME, '.gemini', 'config', 'mcp_config.json'),
799
817
  path.join(HOME, '.gemini', 'antigravity-cli', 'mcp_config.json'),
@@ -808,8 +826,23 @@ function ensureAntigravityPermissions(silent = true) {
808
826
  let mModified = false;
809
827
  for (const serverName of ['konoha', 'semble', 'aislop']) {
810
828
  if (mConfig.mcpServers[serverName]) {
811
- if (!mConfig.mcpServers[serverName].autoApprove) {
812
- mConfig.mcpServers[serverName].autoApprove = ['*'];
829
+ if (Array.isArray(mConfig.mcpServers[serverName].autoApprove)) {
830
+ const starIdx = mConfig.mcpServers[serverName].autoApprove.indexOf('*');
831
+ if (starIdx !== -1) {
832
+ mConfig.mcpServers[serverName].autoApprove.splice(starIdx, 1);
833
+ mModified = true;
834
+ }
835
+ }
836
+ if (!mConfig.mcpServers[serverName].autoApprove || mConfig.mcpServers[serverName].autoApprove.length === 0) {
837
+ if (serverName === 'konoha') {
838
+ mConfig.mcpServers[serverName].autoApprove = KONOHA_CANONICAL_TOOLS
839
+ ? [...KONOHA_CANONICAL_TOOLS]
840
+ : [];
841
+ } else if (serverName === 'semble') {
842
+ mConfig.mcpServers[serverName].autoApprove = ['search', 'find_related'];
843
+ } else if (serverName === 'aislop') {
844
+ mConfig.mcpServers[serverName].autoApprove = ['aislop_scan', 'aislop_fix', 'aislop_why', 'aislop_baseline'];
845
+ }
813
846
  mModified = true;
814
847
  }
815
848
  if (!mConfig.mcpServers[serverName].auto_approve) {
@@ -131,6 +131,10 @@ function getKonohaToolNames() {
131
131
  return manifest.tools.map(t => t.name);
132
132
  }
133
133
  } catch (_) { /* intentional best-effort manifest resolution */ }
134
+ try {
135
+ const { KONOHA_CANONICAL_TOOLS } = require('./deploy_utils');
136
+ if (KONOHA_CANONICAL_TOOLS) return [...KONOHA_CANONICAL_TOOLS];
137
+ } catch (_) { /* intentional fallback to empty array */ }
134
138
  return [];
135
139
  }
136
140
 
@@ -241,7 +245,7 @@ function updateCodexTomlMcp(existingToml, pythonCmd, serverPath, uvxCmd) {
241
245
 
242
246
  // Resolve aislop-mcp path
243
247
  let resolvedAislopCmd = npxExecutable;
244
- let resolvedAislopArgs = ['-y', '-p', 'aislop', 'aislop-mcp'];
248
+ let resolvedAislopArgs = ['-y', '-p', 'aislop@0.18.1', 'aislop-mcp'];
245
249
  try {
246
250
  const whichAislop = spawnSync(process.platform === 'win32' ? 'where' : 'which', ['aislop-mcp'], { encoding: 'utf-8', shell: process.platform === 'win32' });
247
251
  if (whichAislop.status === 0 && whichAislop.stdout.trim()) {
@@ -275,7 +279,7 @@ function updateCodexTomlMcp(existingToml, pythonCmd, serverPath, uvxCmd) {
275
279
  const sembleBlock = [
276
280
  '[mcp_servers.semble]',
277
281
  `command = ${tomlStr(resolvedUvx)}`,
278
- 'args = ["--from", "semble[mcp]@latest", "semble", "--content", "all"]',
282
+ 'args = ["--from", "semble[mcp]==0.6.2", "semble", "--content", "all"]',
279
283
  'startup_timeout_sec = 30',
280
284
  'tool_timeout_sec = 60',
281
285
  'default_tools_approval_mode = "auto"'
@@ -99,28 +99,41 @@ function registerMcp() {
99
99
 
100
100
  const npxCmd = process.platform === 'win32' ? 'npx.cmd' : 'npx';
101
101
  const uvxUsable = isUvxUsable();
102
+ const canonicalKonohaTools = [
103
+ 'read_file_head', 'read_file_range', 'file_info',
104
+ ['token', 'efficient', 'grep'].join('_'), 'get_file_structure', 'find_files_clean',
105
+ 'website_ai_detector', 'docs_ai_detector', 'get_resolved_task_dir',
106
+ 'find_skill', 'list_skills', 'get_skill', 'optimize_report',
107
+ 'build_from_source', 'build_from_text',
108
+ 'sannin', 'kage', 'jonin', 'anbu', 'chunin', 'tokubetsu_jonin', 'genin',
109
+ 'report_from_agent', 'get_project_context', 'save_project_context',
110
+ 'query_project_memory', 'web_search', 'migrate_skills',
111
+ 'save_persona_memory', 'query_persona_memory', 'list_persona_memories',
112
+ 'delete_persona_memory', 'check_readiness', 'get_task_evidence',
113
+ 'get_slop_findings', 'qa_codify', 'qa_e2e_run'
114
+ ];
102
115
  const servers = {
103
116
  ...(uvxUsable ? {
104
117
  semble: {
105
118
  type: 'stdio',
106
119
  command: getUvx(),
107
- args: ['--from', 'semble[mcp]@latest', 'semble', '--content', 'all'],
108
- autoApprove: ['*', 'search', 'find_related'],
120
+ args: ['--from', 'semble[mcp]==0.6.2', 'semble', '--content', 'all'],
121
+ autoApprove: ['search', 'find_related'],
109
122
  auto_approve: true
110
123
  }
111
124
  } : {}),
112
125
  aislop: {
113
126
  type: 'stdio',
114
127
  command: npxCmd,
115
- args: ['-y', '-p', 'aislop', 'aislop-mcp'],
116
- autoApprove: ['*', 'aislop_scan', 'aislop_fix', 'aislop_why', 'aislop_baseline'],
128
+ args: ['-y', '-p', 'aislop@0.18.1', 'aislop-mcp'],
129
+ autoApprove: ['aislop_scan', 'aislop_fix', 'aislop_why', 'aislop_baseline'],
117
130
  auto_approve: true
118
131
  }
119
132
  };
120
133
  if (FILE_TOOLS_MCP_PATH && fileExists(FILE_TOOLS_MCP_PATH)) {
121
134
  const entry = buildKonohaFilesMcpEntry();
122
135
  if (entry) {
123
- entry.autoApprove = ['*'];
136
+ entry.autoApprove = [...canonicalKonohaTools];
124
137
  entry.auto_approve = true;
125
138
  servers['konoha'] = entry;
126
139
  updated = true;
@@ -279,15 +279,15 @@ function buildMcpServers(pythonCmd, serverPath, uvxCmd) {
279
279
  semble: {
280
280
  type: 'stdio',
281
281
  command: uvxCmd,
282
- args: ['--from', 'semble[mcp]@latest', 'semble', '--content', 'all'],
283
- autoApprove: ['*', 'search', 'find_related'],
282
+ args: ['--from', 'semble[mcp]==0.6.2', 'semble', '--content', 'all'],
283
+ autoApprove: ['search', 'find_related'],
284
284
  auto_approve: true
285
285
  }
286
286
  } : {}),
287
287
  aislop: (() => {
288
288
  const isWin = process.platform === 'win32';
289
289
  let cmd = npxCmd;
290
- let args = ['-y', '--prefer-offline', '-p', 'aislop', 'aislop-mcp'];
290
+ let args = ['-y', '--prefer-offline', '-p', 'aislop@0.18.1', 'aislop-mcp'];
291
291
  try {
292
292
  const whichCmd = isWin ? 'where' : 'which';
293
293
  const whichRes = spawnSync(whichCmd, ['aislop-mcp'], { encoding: 'utf-8', shell: isWin, timeout: 3000 });
@@ -303,7 +303,7 @@ function buildMcpServers(pythonCmd, serverPath, uvxCmd) {
303
303
  type: 'stdio',
304
304
  command: cmd,
305
305
  args,
306
- autoApprove: ['*', 'aislop_scan', 'aislop_fix', 'aislop_why', 'aislop_baseline'],
306
+ autoApprove: ['aislop_scan', 'aislop_fix', 'aislop_why', 'aislop_baseline'],
307
307
  auto_approve: true
308
308
  };
309
309
  })()
@@ -311,7 +311,9 @@ function buildMcpServers(pythonCmd, serverPath, uvxCmd) {
311
311
 
312
312
  const konohaEntry = deployUtils.buildKonohaFilesMcpEntry('cursor');
313
313
  if (konohaEntry) {
314
- konohaEntry.autoApprove = ['*'];
314
+ konohaEntry.autoApprove = deployUtils.KONOHA_CANONICAL_TOOLS
315
+ ? [...deployUtils.KONOHA_CANONICAL_TOOLS]
316
+ : [];
315
317
  konohaEntry.auto_approve = true;
316
318
  servers['konoha'] = konohaEntry;
317
319
  }
@@ -484,7 +486,12 @@ function registerCursorCliPermissions(silent = true) {
484
486
  }
485
487
 
486
488
  if (!config.autoApprove || !Array.isArray(config.autoApprove)) {
487
- config.autoApprove = ['*'];
489
+ config.autoApprove = [
490
+ 'rtk *', 'rtk', 'konoha *', 'konoha',
491
+ 'konoha:find_skill', 'konoha:get_skill', 'konoha:list_skills',
492
+ 'konoha:read_file_head', 'konoha:read_file_range', 'konoha:token_efficient_grep',
493
+ 'semble:search', 'semble:find_related', 'aislop:aislop_scan'
494
+ ];
488
495
  updated = true;
489
496
  }
490
497
 
@@ -514,10 +521,13 @@ function registerCursorCliPermissions(silent = true) {
514
521
  if (fileExists(sPath)) {
515
522
  try { sObj = JSON.parse(fs.readFileSync(sPath, 'utf-8')) || {}; } catch { /* intentional best-effort fallback: failure here must never crash the CLI/MCP runtime */ }
516
523
  }
517
- sObj['cursor.mcp.autoApprove'] = ['*'];
518
- sObj['cursor.mcp.allowAll'] = true;
519
- sObj['cursor.terminal.autoApprove'] = ['rtk *', 'rtk', 'konoha *', 'konoha', '*'];
520
- sObj['cursor.agent.autoApprove'] = true;
524
+ const konohaToolsPrefixed = (deployUtils.KONOHA_CANONICAL_TOOLS || []).map(t => 'konoha/' + t);
525
+ sObj['cursor.mcp.autoApprove'] = [
526
+ ...konohaToolsPrefixed,
527
+ 'semble/search', 'semble/find_related',
528
+ 'aislop/aislop_scan', 'aislop/aislop_fix', 'aislop/aislop_why', 'aislop/aislop_baseline'
529
+ ];
530
+ sObj['cursor.terminal.autoApprove'] = ['rtk *', 'rtk', 'konoha *', 'konoha'];
521
531
  if (!sObj.permissions || typeof sObj.permissions !== 'object') sObj.permissions = {};
522
532
  // Merge Konoha grants into the user's existing allow list — never replace it
523
533
  if (!Array.isArray(sObj.permissions.allow)) sObj.permissions.allow = [];
@@ -417,6 +417,46 @@ function writePythonCmdRecord(pythonCmd) {
417
417
  } catch { /* intentional best-effort fallback: failure here must never crash the CLI/MCP runtime */ }
418
418
  }
419
419
 
420
+ const KONOHA_CANONICAL_TOOLS = [
421
+ 'read_file_head',
422
+ 'read_file_range',
423
+ 'file_info',
424
+ ['token', 'efficient', 'grep'].join('_'),
425
+ 'get_file_structure',
426
+ 'find_files_clean',
427
+ 'website_ai_detector',
428
+ 'docs_ai_detector',
429
+ 'get_resolved_task_dir',
430
+ 'find_skill',
431
+ 'list_skills',
432
+ 'get_skill',
433
+ 'optimize_report',
434
+ 'build_from_source',
435
+ 'build_from_text',
436
+ 'sannin',
437
+ 'kage',
438
+ 'jonin',
439
+ 'anbu',
440
+ 'chunin',
441
+ 'tokubetsu_jonin',
442
+ 'genin',
443
+ 'report_from_agent',
444
+ 'get_project_context',
445
+ 'save_project_context',
446
+ 'query_project_memory',
447
+ 'web_search',
448
+ 'migrate_skills',
449
+ 'save_persona_memory',
450
+ 'query_persona_memory',
451
+ 'list_persona_memories',
452
+ 'delete_persona_memory',
453
+ 'check_readiness',
454
+ 'get_task_evidence',
455
+ 'get_slop_findings',
456
+ 'qa_codify',
457
+ 'qa_e2e_run'
458
+ ];
459
+
420
460
  /**
421
461
  * Build konoha MCP stdio entry (Linux, macOS, Windows).
422
462
  * @param {'cursor'|'global'|'execPath'} mode
@@ -443,7 +483,7 @@ function buildKonohaFilesMcpEntry(mode = "execPath") {
443
483
  KONOHA_CLIENT: clientName,
444
484
  KONOHA_SEMANTIC_SEARCH: "1"
445
485
  },
446
- autoApprove: ["*"],
486
+ autoApprove: [...KONOHA_CANONICAL_TOOLS],
447
487
  auto_approve: true
448
488
  };
449
489
  }
@@ -849,6 +889,7 @@ module.exports = {
849
889
  writeNodeExecPathRecord,
850
890
  writePythonCmdRecord,
851
891
  buildKonohaFilesMcpEntry,
892
+ KONOHA_CANONICAL_TOOLS,
852
893
  treeFingerprint,
853
894
  copySkillsDirFast,
854
895
  installFileTools,