fullcourtdefense-cli 1.3.4 → 1.3.5

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.
@@ -5,6 +5,8 @@ export declare const ALL_GATEWAY_CLIENTS: GatewayClient[];
5
5
  export interface McpGatewayArgs {
6
6
  mcpCommand?: string;
7
7
  mcpArgs?: string;
8
+ /** Working directory for the downstream MCP process (Codex config.toml cwd). */
9
+ mcpCwd?: string;
8
10
  agentName?: string;
9
11
  agentClient?: string;
10
12
  developerName?: string;
@@ -733,18 +733,42 @@ function removeTomlSection(content, tableName) {
733
733
  }
734
734
  return out.join('\n').replace(/\n{3,}/g, '\n\n').trim();
735
735
  }
736
- function writeCodexMcpServer(configPath, serverName, nodeExe, commandArgs) {
736
+ function writeCodexMcpServer(configPath, serverName, nodeExe, commandArgs, options = {}) {
737
737
  const existing = fs.existsSync(configPath) ? fs.readFileSync(configPath, 'utf8') : '';
738
738
  const cleaned = removeTomlSection(existing, `mcp_servers.${serverName}`);
739
739
  const argsToml = commandArgs.map(arg => JSON.stringify(arg)).join(', ');
740
- const block = [
740
+ const blockLines = [
741
741
  `[mcp_servers.${serverName}]`,
742
742
  `command = ${JSON.stringify(nodeExe)}`,
743
743
  `args = [${argsToml}]`,
744
- ].join('\n');
744
+ ];
745
+ if (options.cwd) {
746
+ blockLines.push(`cwd = ${JSON.stringify(options.cwd.replace(/\//g, path.sep))}`);
747
+ }
748
+ if (options.startupTimeoutSec && options.startupTimeoutSec > 0) {
749
+ blockLines.push(`startup_timeout_sec = ${options.startupTimeoutSec}`);
750
+ }
751
+ const block = blockLines.join('\n');
745
752
  fs.mkdirSync(path.dirname(configPath), { recursive: true });
746
753
  fs.writeFileSync(configPath, `${cleaned ? `${cleaned}\n\n` : ''}${block}\n`, 'utf8');
747
754
  }
755
+ function resolveMcpCwd(args) {
756
+ const explicit = args.mcpCwd || process.env.FCD_MCP_CWD;
757
+ if (explicit)
758
+ return path.resolve(explicit);
759
+ const pkg = path.join(process.cwd(), 'package.json');
760
+ if (fs.existsSync(pkg)) {
761
+ try {
762
+ const scripts = JSON.parse(fs.readFileSync(pkg, 'utf8')).scripts || {};
763
+ const mcpArgs = parseArgsList(args.mcpArgs || process.env.FCD_MCP_ARGS);
764
+ if (args.mcpCommand === 'npm' && mcpArgs[0] === 'run' && scripts[mcpArgs[1] || 'mcp']) {
765
+ return process.cwd();
766
+ }
767
+ }
768
+ catch { /* ignore */ }
769
+ }
770
+ return undefined;
771
+ }
748
772
  function codexConfigPath(projectScope) {
749
773
  return projectScope
750
774
  ? path.join(process.cwd(), '.codex', 'config.toml')
@@ -1034,7 +1058,10 @@ async function installCodexMcpGatewayCommand(args, config) {
1034
1058
  throw new Error('Pass --mcp-command for the real MCP server you want to protect.');
1035
1059
  const downstreamArgs = parseArgsList(args.mcpArgs || process.env.FCD_MCP_ARGS);
1036
1060
  const commandArgs = buildGatewayCommandArgs(gatewayConfig, downstreamCommand, downstreamArgs, INSTALL_GATEWAY_ARGS);
1037
- writeCodexMcpServer(file, serverName, nodeExe, commandArgs);
1061
+ writeCodexMcpServer(file, serverName, nodeExe, commandArgs, {
1062
+ cwd: resolveMcpCwd(args),
1063
+ startupTimeoutSec: 120,
1064
+ });
1038
1065
  console.log(`AgentGuard MCP Gateway installed for Codex (${projectScope ? 'project' : 'global'}).`);
1039
1066
  console.log(`Config: ${file}`);
1040
1067
  console.log(`Server: ${serverName}`);
package/dist/index.js CHANGED
@@ -295,6 +295,7 @@ async function main() {
295
295
  serverName: flags['server-name'],
296
296
  mcpCommand: flags['mcp-command'],
297
297
  mcpArgs: flags['mcp-args'],
298
+ mcpCwd: flags['mcp-cwd'],
298
299
  agentName: flags['agent-name'],
299
300
  developerName: flags['developer-name'],
300
301
  shieldId: flags['shield-id'],
@@ -314,6 +315,7 @@ async function main() {
314
315
  const buildGatewayArgs = () => ({
315
316
  mcpCommand: flags['mcp-command'],
316
317
  mcpArgs: flags['mcp-args'],
318
+ mcpCwd: flags['mcp-cwd'],
317
319
  agentName: flags['agent-name'],
318
320
  agentClient: flags['agent-client'],
319
321
  developerName: flags['developer-name'],
package/dist/version.json CHANGED
@@ -1,3 +1,3 @@
1
1
  {
2
- "version": "1.3.4"
2
+ "version": "1.3.5"
3
3
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fullcourtdefense-cli",
3
- "version": "1.3.4",
3
+ "version": "1.3.5",
4
4
  "description": "Full Court Defense CLI — security scanning for AI agents from your terminal",
5
5
  "main": "dist/index.js",
6
6
  "bin": {