@mcpc-tech/cli 0.1.51 → 0.1.52

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/server.mjs CHANGED
@@ -509,7 +509,7 @@ var require_cross_spawn = __commonJS({
509
509
  var cp = __require("child_process");
510
510
  var parse2 = require_parse();
511
511
  var enoent = require_enoent();
512
- function spawn2(command, args, options) {
512
+ function spawn3(command, args, options) {
513
513
  const parsed = parse2(command, args, options);
514
514
  const spawned = cp.spawn(parsed.command, parsed.args, parsed.options);
515
515
  enoent.hookChildProcess(spawned, parsed);
@@ -521,8 +521,8 @@ var require_cross_spawn = __commonJS({
521
521
  result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
522
522
  return result;
523
523
  }
524
- module.exports = spawn2;
525
- module.exports.spawn = spawn2;
524
+ module.exports = spawn3;
525
+ module.exports.spawn = spawn3;
526
526
  module.exports.sync = spawnSync;
527
527
  module.exports._parse = parse2;
528
528
  module.exports._enoent = enoent;
@@ -3877,7 +3877,7 @@ function parseArgs(args, options) {
3877
3877
  import { mkdir, readFile as readFile3, writeFile as writeFile2 } from "node:fs/promises";
3878
3878
  import { homedir } from "node:os";
3879
3879
  import { dirname, join as join3, resolve as resolve4 } from "node:path";
3880
- import process4 from "node:process";
3880
+ import process5 from "node:process";
3881
3881
 
3882
3882
  // __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/plugins/large-result.js
3883
3883
  import { mkdtemp, writeFile } from "node:fs/promises";
@@ -4438,6 +4438,152 @@ Skill path: ${meta.basePath}
4438
4438
  };
4439
4439
  }
4440
4440
 
4441
+ // __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/plugins/bash.js
4442
+ import { spawn } from "node:child_process";
4443
+ import process2 from "node:process";
4444
+ var DEFAULT_MAX_BYTES = 1e5;
4445
+ var DEFAULT_MAX_LINES = 2e3;
4446
+ var DEFAULT_TIMEOUT_MS = 6e4;
4447
+ function truncateOutput(stdout, stderr, maxBytes = DEFAULT_MAX_BYTES, maxLines = DEFAULT_MAX_LINES) {
4448
+ const fullOutput = (stderr ? `STDERR:
4449
+ ${stderr}
4450
+
4451
+ STDOUT:
4452
+ ` : "") + stdout;
4453
+ const lines = fullOutput.split("\n");
4454
+ if (lines.length > maxLines) {
4455
+ const truncatedLines = lines.slice(-maxLines);
4456
+ return {
4457
+ output: `[OUTPUT TRUNCATED] Showing last ${maxLines} lines of ${lines.length} total
4458
+
4459
+ ` + truncatedLines.join("\n"),
4460
+ truncated: true
4461
+ };
4462
+ }
4463
+ if (fullOutput.length > maxBytes) {
4464
+ const truncatedBytes = fullOutput.slice(-maxBytes);
4465
+ return {
4466
+ output: `[OUTPUT TRUNCATED] Showing last ${maxBytes} bytes of ${fullOutput.length} total
4467
+
4468
+ ` + truncatedBytes,
4469
+ truncated: true
4470
+ };
4471
+ }
4472
+ return {
4473
+ output: fullOutput,
4474
+ truncated: false
4475
+ };
4476
+ }
4477
+ function executeBash(command, cwd2, timeoutMs) {
4478
+ return new Promise((resolve5) => {
4479
+ const stdout = [];
4480
+ const stderr = [];
4481
+ const proc = spawn("bash", [
4482
+ "-c",
4483
+ command
4484
+ ], {
4485
+ cwd: cwd2,
4486
+ stdio: [
4487
+ "ignore",
4488
+ "pipe",
4489
+ "pipe"
4490
+ ]
4491
+ });
4492
+ proc.stdout?.on("data", (data) => {
4493
+ stdout.push(data.toString());
4494
+ });
4495
+ proc.stderr?.on("data", (data) => {
4496
+ stderr.push(data.toString());
4497
+ });
4498
+ proc.on("close", (code) => {
4499
+ resolve5({
4500
+ stdout: stdout.join(""),
4501
+ stderr: stderr.join(""),
4502
+ exitCode: code
4503
+ });
4504
+ });
4505
+ proc.on("error", (err) => {
4506
+ resolve5({
4507
+ stdout: "",
4508
+ stderr: err.message,
4509
+ exitCode: null
4510
+ });
4511
+ });
4512
+ setTimeout(() => {
4513
+ proc.kill("SIGTERM");
4514
+ resolve5({
4515
+ stdout: stdout.join(""),
4516
+ stderr: stderr.join("") + "\n\n[TIMEOUT] Command execution timed out",
4517
+ exitCode: null
4518
+ });
4519
+ }, timeoutMs);
4520
+ });
4521
+ }
4522
+ function createBashPlugin(options = {}) {
4523
+ const { maxBytes, maxLines, timeoutMs } = {
4524
+ maxBytes: DEFAULT_MAX_BYTES,
4525
+ maxLines: DEFAULT_MAX_LINES,
4526
+ timeoutMs: DEFAULT_TIMEOUT_MS,
4527
+ ...options
4528
+ };
4529
+ let serverRef = null;
4530
+ return {
4531
+ name: "plugin-bash",
4532
+ version: "1.0.0",
4533
+ // Store server reference for tool registration
4534
+ configureServer: (server) => {
4535
+ serverRef = server;
4536
+ },
4537
+ // Register bash tool with agent name prefix
4538
+ composeStart: (context2) => {
4539
+ if (!serverRef) return;
4540
+ const agentName = context2.serverName;
4541
+ const toolName = `${agentName}__bash`;
4542
+ serverRef.tool(toolName, "Execute a bash command and return its output.\n\nUse this for:\n- Running shell commands\n- Executing scripts\n- System operations\n\nNote: Output is truncated if too large.", {
4543
+ type: "object",
4544
+ properties: {
4545
+ command: {
4546
+ type: "string",
4547
+ description: "The bash command to execute"
4548
+ },
4549
+ cwd: {
4550
+ type: "string",
4551
+ description: "Optional: Working directory for the command (defaults to current directory)"
4552
+ }
4553
+ },
4554
+ required: [
4555
+ "command"
4556
+ ]
4557
+ }, async (args) => {
4558
+ const cwd2 = args.cwd || process2.cwd();
4559
+ const result = await executeBash(args.command, cwd2, timeoutMs);
4560
+ const { output, truncated } = truncateOutput(result.stdout, result.stderr, maxBytes, maxLines);
4561
+ let finalOutput = output;
4562
+ if (result.exitCode !== null && result.exitCode !== 0) {
4563
+ finalOutput = `[EXIT CODE: ${result.exitCode}]
4564
+ ` + finalOutput;
4565
+ }
4566
+ if (truncated) {
4567
+ finalOutput += `
4568
+
4569
+ [Note: Output was truncated]`;
4570
+ }
4571
+ return {
4572
+ content: [
4573
+ {
4574
+ type: "text",
4575
+ text: finalOutput
4576
+ }
4577
+ ],
4578
+ isError: result.exitCode !== null && result.exitCode !== 0
4579
+ };
4580
+ }, {
4581
+ internal: true
4582
+ });
4583
+ }
4584
+ };
4585
+ }
4586
+
4441
4587
  // __mcpc__cli_latest/node_modules/@mcpc/cli/src/defaults.js
4442
4588
  import { createCodeExecutionPlugin } from "@mcpc-tech/plugin-code-execution";
4443
4589
 
@@ -6417,10 +6563,10 @@ function parse(content, options = {}) {
6417
6563
  }
6418
6564
 
6419
6565
  // __mcpc__cli_latest/node_modules/@jsr/mcpc__plugin-markdown-loader/src/markdown-loader.js
6420
- import process2 from "node:process";
6566
+ import process3 from "node:process";
6421
6567
  function replaceEnvVars(str2) {
6422
6568
  return str2.replace(/\$([A-Za-z_][A-Za-z0-9_]*)(?!\s*\()/g, (match, varName) => {
6423
- const value = process2.env[varName];
6569
+ const value = process3.env[varName];
6424
6570
  if (value !== void 0) {
6425
6571
  return value;
6426
6572
  }
@@ -6519,18 +6665,19 @@ var defaultPlugin = markdownLoaderPlugin();
6519
6665
 
6520
6666
  // __mcpc__cli_latest/node_modules/@mcpc/cli/src/defaults.js
6521
6667
  import { resolve as resolve3 } from "node:path";
6522
- import process3 from "node:process";
6668
+ import process4 from "node:process";
6523
6669
  var DEFAULT_SKILLS_PATHS = [
6524
6670
  ".agent/skills"
6525
6671
  ];
6526
6672
  var DEFAULT_CODE_EXECUTION_TIMEOUT = 3e5;
6527
6673
  function getGlobalPlugins(skillsPaths) {
6528
- const resolvedPaths = skillsPaths.map((p2) => resolve3(process3.cwd(), p2));
6674
+ const resolvedPaths = skillsPaths.map((p2) => resolve3(process4.cwd(), p2));
6529
6675
  return [
6530
6676
  markdownLoaderPlugin(),
6531
6677
  createSkillsPlugin({
6532
6678
  paths: resolvedPaths
6533
- })
6679
+ }),
6680
+ createBashPlugin()
6534
6681
  ];
6535
6682
  }
6536
6683
  function getAgentPlugins() {
@@ -6559,7 +6706,7 @@ function getDefaultAgents() {
6559
6706
  }
6560
6707
 
6561
6708
  // __mcpc__cli_latest/node_modules/@mcpc/cli/src/config/loader.js
6562
- var CLI_VERSION = "0.1.51";
6709
+ var CLI_VERSION = "0.1.52";
6563
6710
  function extractServerName(command, commandArgs) {
6564
6711
  for (const arg of commandArgs) {
6565
6712
  if (!arg.startsWith("-")) {
@@ -6619,7 +6766,7 @@ async function saveUserConfig(config, newAgentName) {
6619
6766
  async function createWrapConfig(args) {
6620
6767
  if (!args.mcpServers || args.mcpServers.length === 0) {
6621
6768
  console.error("Error: --wrap/--add requires at least one MCP server\nExample: mcpc --wrap --mcp-stdio 'npx -y @wonderwhy-er/desktop-commander'\nMultiple: mcpc --add --mcp-stdio 'npx -y server1' --mcp-http 'https://api.example.com'");
6622
- process4.exit(1);
6769
+ process5.exit(1);
6623
6770
  }
6624
6771
  const mcpServers = {};
6625
6772
  const serverNames = [];
@@ -6742,7 +6889,7 @@ function parseMcpServer(cmdString, transportType) {
6742
6889
  };
6743
6890
  }
6744
6891
  function parseCLIArgs() {
6745
- const args = parseArgs(process4.argv.slice(2), {
6892
+ const args = parseArgs(process5.argv.slice(2), {
6746
6893
  boolean: [
6747
6894
  "help",
6748
6895
  "version",
@@ -6831,15 +6978,15 @@ async function loadConfig() {
6831
6978
  const args = parseCLIArgs();
6832
6979
  if (args.version) {
6833
6980
  printVersion();
6834
- process4.exit(0);
6981
+ process5.exit(0);
6835
6982
  }
6836
6983
  if (args.help) {
6837
6984
  printHelp();
6838
- process4.exit(0);
6985
+ process5.exit(0);
6839
6986
  }
6840
6987
  if (args.cwd) {
6841
- const targetCwd = resolve4(process4.cwd(), args.cwd);
6842
- process4.chdir(targetCwd);
6988
+ const targetCwd = resolve4(process5.cwd(), args.cwd);
6989
+ process5.chdir(targetCwd);
6843
6990
  console.error(`Changed working directory to: ${targetCwd}`);
6844
6991
  }
6845
6992
  const mergeSkills = (config) => {
@@ -6851,7 +6998,7 @@ async function loadConfig() {
6851
6998
  ...args,
6852
6999
  saveConfig: true
6853
7000
  });
6854
- process4.exit(0);
7001
+ process5.exit(0);
6855
7002
  }
6856
7003
  if (args.wrap) {
6857
7004
  return mergeSkills(await createWrapConfig({
@@ -6868,16 +7015,16 @@ async function loadConfig() {
6868
7015
  throw error;
6869
7016
  }
6870
7017
  }
6871
- if (process4.env.MCPC_CONFIG) {
7018
+ if (process5.env.MCPC_CONFIG) {
6872
7019
  try {
6873
- const parsed = JSON.parse(process4.env.MCPC_CONFIG);
7020
+ const parsed = JSON.parse(process5.env.MCPC_CONFIG);
6874
7021
  return mergeSkills(applyModeOverride(normalizeConfig(parsed), args.mode));
6875
7022
  } catch (error) {
6876
7023
  console.error("Failed to parse MCPC_CONFIG environment variable:", error);
6877
7024
  throw error;
6878
7025
  }
6879
7026
  }
6880
- const configUrl = args.configUrl || process4.env.MCPC_CONFIG_URL;
7027
+ const configUrl = args.configUrl || process5.env.MCPC_CONFIG_URL;
6881
7028
  if (configUrl) {
6882
7029
  try {
6883
7030
  const headers = {
@@ -6898,7 +7045,7 @@ async function loadConfig() {
6898
7045
  throw error;
6899
7046
  }
6900
7047
  }
6901
- const configFile = args.configFile || process4.env.MCPC_CONFIG_FILE;
7048
+ const configFile = args.configFile || process5.env.MCPC_CONFIG_FILE;
6902
7049
  if (configFile) {
6903
7050
  try {
6904
7051
  const config = await loadConfigFromFile(configFile);
@@ -6923,7 +7070,7 @@ async function loadConfig() {
6923
7070
  throw error;
6924
7071
  }
6925
7072
  }
6926
- const defaultJsonConfigPath = resolve4(process4.cwd(), "mcpc.config.json");
7073
+ const defaultJsonConfigPath = resolve4(process5.cwd(), "mcpc.config.json");
6927
7074
  try {
6928
7075
  const config = await loadConfigFromFile(defaultJsonConfigPath);
6929
7076
  return mergeSkills(applyModeOverride(config, args.mode));
@@ -6938,7 +7085,7 @@ async function loadConfig() {
6938
7085
  }
6939
7086
  function replaceEnvVars2(str2) {
6940
7087
  return str2.replace(/\$([A-Z_][A-Z0-9_]*)/g, (_match, varName) => {
6941
- return process4.env[varName] || "";
7088
+ return process5.env[varName] || "";
6942
7089
  });
6943
7090
  }
6944
7091
  function isMarkdownFile2(path) {
@@ -9569,7 +9716,7 @@ var Client = class extends Protocol {
9569
9716
 
9570
9717
  // __mcpc__cli_latest/node_modules/@modelcontextprotocol/sdk/dist/esm/client/stdio.js
9571
9718
  var import_cross_spawn = __toESM(require_cross_spawn(), 1);
9572
- import process5 from "node:process";
9719
+ import process6 from "node:process";
9573
9720
  import { PassThrough } from "node:stream";
9574
9721
 
9575
9722
  // __mcpc__cli_latest/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js
@@ -9601,7 +9748,7 @@ function serializeMessage(message) {
9601
9748
  }
9602
9749
 
9603
9750
  // __mcpc__cli_latest/node_modules/@modelcontextprotocol/sdk/dist/esm/client/stdio.js
9604
- var DEFAULT_INHERITED_ENV_VARS = process5.platform === "win32" ? [
9751
+ var DEFAULT_INHERITED_ENV_VARS = process6.platform === "win32" ? [
9605
9752
  "APPDATA",
9606
9753
  "HOMEDRIVE",
9607
9754
  "HOMEPATH",
@@ -9621,7 +9768,7 @@ var DEFAULT_INHERITED_ENV_VARS = process5.platform === "win32" ? [
9621
9768
  function getDefaultEnvironment() {
9622
9769
  const env = {};
9623
9770
  for (const key of DEFAULT_INHERITED_ENV_VARS) {
9624
- const value = process5.env[key];
9771
+ const value = process6.env[key];
9625
9772
  if (value === void 0) {
9626
9773
  continue;
9627
9774
  }
@@ -9657,7 +9804,7 @@ var StdioClientTransport = class {
9657
9804
  },
9658
9805
  stdio: ["pipe", "pipe", this._serverParams.stderr ?? "inherit"],
9659
9806
  shell: false,
9660
- windowsHide: process5.platform === "win32" && isElectron(),
9807
+ windowsHide: process6.platform === "win32" && isElectron(),
9661
9808
  cwd: this._serverParams.cwd
9662
9809
  });
9663
9810
  this._process.on("error", (error) => {
@@ -9765,7 +9912,7 @@ var StdioClientTransport = class {
9765
9912
  }
9766
9913
  };
9767
9914
  function isElectron() {
9768
- return "type" in process5;
9915
+ return "type" in process6;
9769
9916
  }
9770
9917
 
9771
9918
  // __mcpc__cli_latest/node_modules/eventsource-parser/dist/index.js
@@ -11689,8 +11836,8 @@ var InMemoryTransport = class _InMemoryTransport {
11689
11836
  };
11690
11837
 
11691
11838
  // __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/utils/common/config.js
11692
- import process6 from "node:process";
11693
- var GEMINI_PREFERRED_FORMAT = process6.env.GEMINI_PREFERRED_FORMAT === "0" ? false : true;
11839
+ import process7 from "node:process";
11840
+ var GEMINI_PREFERRED_FORMAT = process7.env.GEMINI_PREFERRED_FORMAT === "0" ? false : true;
11694
11841
 
11695
11842
  // __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/utils/common/json.js
11696
11843
  import { jsonrepair as jsonrepair2 } from "jsonrepair";
@@ -11763,7 +11910,7 @@ var cleanToolSchema = (schema) => {
11763
11910
 
11764
11911
  // __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/utils/common/mcp.js
11765
11912
  import { cwd } from "node:process";
11766
- import process7 from "node:process";
11913
+ import process8 from "node:process";
11767
11914
  import { createHash } from "node:crypto";
11768
11915
  function createTransport(def) {
11769
11916
  const defAny = def;
@@ -11804,7 +11951,7 @@ function createTransport(def) {
11804
11951
  command: defAny.command,
11805
11952
  args: defAny.args,
11806
11953
  env: {
11807
- ...process7.env,
11954
+ ...process8.env,
11808
11955
  ...defAny.env ?? {}
11809
11956
  },
11810
11957
  cwd: cwd()
@@ -12454,7 +12601,7 @@ function endSpan(span, error) {
12454
12601
  }
12455
12602
 
12456
12603
  // __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/executors/agentic/agentic-executor.js
12457
- import process8 from "node:process";
12604
+ import process9 from "node:process";
12458
12605
  var AgenticExecutor = class {
12459
12606
  name;
12460
12607
  allToolNames;
@@ -12474,13 +12621,13 @@ var AgenticExecutor = class {
12474
12621
  this.logger = createLogger(`mcpc.agentic.${name}`, server);
12475
12622
  this.toolSchemaMap = new Map(toolNameToDetailList);
12476
12623
  try {
12477
- this.tracingEnabled = process8.env.MCPC_TRACING_ENABLED === "true";
12624
+ this.tracingEnabled = process9.env.MCPC_TRACING_ENABLED === "true";
12478
12625
  if (this.tracingEnabled) {
12479
12626
  initializeTracing({
12480
12627
  enabled: true,
12481
12628
  serviceName: `mcpc-agentic-${name}`,
12482
- exportTo: process8.env.MCPC_TRACING_EXPORT ?? "otlp",
12483
- otlpEndpoint: process8.env.MCPC_TRACING_OTLP_ENDPOINT ?? "http://localhost:4318/v1/traces"
12629
+ exportTo: process9.env.MCPC_TRACING_EXPORT ?? "otlp",
12630
+ otlpEndpoint: process9.env.MCPC_TRACING_OTLP_ENDPOINT ?? "http://localhost:4318/v1/traces"
12484
12631
  });
12485
12632
  }
12486
12633
  } catch {
@@ -15194,12 +15341,12 @@ var ComposableMCPServer = class extends Server {
15194
15341
  };
15195
15342
 
15196
15343
  // __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/utils/common/env.js
15197
- import process9 from "node:process";
15198
- var isSCF = () => Boolean(process9.env.SCF_RUNTIME || process9.env.PROD_SCF);
15344
+ import process10 from "node:process";
15345
+ var isSCF = () => Boolean(process10.env.SCF_RUNTIME || process10.env.PROD_SCF);
15199
15346
  if (isSCF()) {
15200
15347
  console.log({
15201
15348
  isSCF: isSCF(),
15202
- SCF_RUNTIME: process9.env.SCF_RUNTIME
15349
+ SCF_RUNTIME: process10.env.SCF_RUNTIME
15203
15350
  });
15204
15351
  }
15205
15352
 
@@ -15281,8 +15428,8 @@ var createApp = (config) => {
15281
15428
  };
15282
15429
 
15283
15430
  // __mcpc__cli_latest/node_modules/@mcpc/cli/src/server.ts
15284
- import process10 from "node:process";
15285
- var port = Number(process10.env.PORT || "3002");
15431
+ import process11 from "node:process";
15432
+ var port = Number(process11.env.PORT || "3002");
15286
15433
  var hostname = "0.0.0.0";
15287
15434
  async function main() {
15288
15435
  const config = await loadConfig();