@mcpc-tech/cli 0.1.13 → 0.1.15
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/bin/mcpc.mjs +147 -12
- package/package.json +2 -1
- package/types/src/config/loader.d.ts.map +1 -1
package/bin/mcpc.mjs
CHANGED
|
@@ -4391,12 +4391,84 @@ var createServer = async (config2) => {
|
|
|
4391
4391
|
import { readFile } from "node:fs/promises";
|
|
4392
4392
|
import { resolve as resolve2 } from "node:path";
|
|
4393
4393
|
import process7 from "node:process";
|
|
4394
|
+
function extractServerName(command, commandArgs) {
|
|
4395
|
+
for (const arg of commandArgs) {
|
|
4396
|
+
if (!arg.startsWith("-")) {
|
|
4397
|
+
const name2 = arg.replace(/[@.,/\\:;!?#$%^&*()[\]{}]/g, "_").substring(0, 64);
|
|
4398
|
+
if (name2) return name2;
|
|
4399
|
+
}
|
|
4400
|
+
}
|
|
4401
|
+
const name = command.replace(/[@.,/\\:;!?#$%^&*()[\]{}]/g, "_").substring(0, 64);
|
|
4402
|
+
return name || "agentic-tool";
|
|
4403
|
+
}
|
|
4404
|
+
function createProxyConfig(args) {
|
|
4405
|
+
if (!args.proxyCommand || args.proxyCommand.length === 0) {
|
|
4406
|
+
console.error("Error: --proxy requires a command after --");
|
|
4407
|
+
console.error("Example: mcpc --proxy --transport-type stdio -- npx -y @wonderwhy-er/desktop-commander");
|
|
4408
|
+
process7.exit(1);
|
|
4409
|
+
}
|
|
4410
|
+
if (!args.transportType) {
|
|
4411
|
+
console.error("Error: --proxy requires --transport-type to be specified");
|
|
4412
|
+
console.error("Supported types: stdio, streamable-http, sse");
|
|
4413
|
+
console.error("Example: mcpc --proxy --transport-type stdio -- npx -y @wonderwhy-er/desktop-commander");
|
|
4414
|
+
process7.exit(1);
|
|
4415
|
+
}
|
|
4416
|
+
const validTransports = [
|
|
4417
|
+
"stdio",
|
|
4418
|
+
"streamable-http",
|
|
4419
|
+
"sse"
|
|
4420
|
+
];
|
|
4421
|
+
if (!validTransports.includes(args.transportType)) {
|
|
4422
|
+
console.error(`Error: Invalid transport type '${args.transportType}'`);
|
|
4423
|
+
console.error(`Supported types: ${validTransports.join(", ")}`);
|
|
4424
|
+
process7.exit(1);
|
|
4425
|
+
}
|
|
4426
|
+
const command = args.proxyCommand[0];
|
|
4427
|
+
const commandArgs = args.proxyCommand.slice(1);
|
|
4428
|
+
const serverName = args.name || extractServerName(command, commandArgs);
|
|
4429
|
+
const config2 = {
|
|
4430
|
+
name: `${serverName}-proxy`,
|
|
4431
|
+
version: "0.1.0",
|
|
4432
|
+
capabilities: {
|
|
4433
|
+
tools: {},
|
|
4434
|
+
sampling: {}
|
|
4435
|
+
},
|
|
4436
|
+
agents: [
|
|
4437
|
+
{
|
|
4438
|
+
name: serverName,
|
|
4439
|
+
description: `Orchestrate ${serverName} MCP server tools`,
|
|
4440
|
+
deps: {
|
|
4441
|
+
mcpServers: {
|
|
4442
|
+
[serverName]: {
|
|
4443
|
+
command,
|
|
4444
|
+
args: commandArgs,
|
|
4445
|
+
transportType: args.transportType
|
|
4446
|
+
}
|
|
4447
|
+
}
|
|
4448
|
+
},
|
|
4449
|
+
options: {
|
|
4450
|
+
mode: args.mode || "agentic",
|
|
4451
|
+
refs: [
|
|
4452
|
+
`<tool name="${serverName}.__ALL__"/>`
|
|
4453
|
+
]
|
|
4454
|
+
}
|
|
4455
|
+
}
|
|
4456
|
+
]
|
|
4457
|
+
};
|
|
4458
|
+
console.error(`Created proxy configuration for ${serverName}`);
|
|
4459
|
+
console.error(`Transport: ${args.transportType}`);
|
|
4460
|
+
console.error(`Command: ${command} ${commandArgs.join(" ")}`);
|
|
4461
|
+
if (args.mode) {
|
|
4462
|
+
console.error(`Mode: ${args.mode}`);
|
|
4463
|
+
}
|
|
4464
|
+
return config2;
|
|
4465
|
+
}
|
|
4394
4466
|
function printHelp() {
|
|
4395
4467
|
console.log(`
|
|
4396
4468
|
MCPC CLI - Model Context Protocol Composer
|
|
4397
4469
|
|
|
4398
4470
|
USAGE:
|
|
4399
|
-
|
|
4471
|
+
mcpc [OPTIONS]
|
|
4400
4472
|
|
|
4401
4473
|
OPTIONS:
|
|
4402
4474
|
--help, -h Show this help message
|
|
@@ -4407,6 +4479,19 @@ OPTIONS:
|
|
|
4407
4479
|
Add custom HTTP header for URL fetching
|
|
4408
4480
|
Format: "Key: Value" or "Key=Value"
|
|
4409
4481
|
Can be used multiple times
|
|
4482
|
+
--mode <mode> Set execution mode for all agents
|
|
4483
|
+
Supported modes:
|
|
4484
|
+
- agentic: Fully autonomous agent mode (default)
|
|
4485
|
+
- agentic_workflow: Agent workflow mode with dynamic or predefined steps
|
|
4486
|
+
- agentic_sampling: Autonomous sampling mode for agentic execution
|
|
4487
|
+
- agentic_workflow_sampling: Autonomous sampling mode for workflow execution
|
|
4488
|
+
- code_execution: Code execution mode for most efficient token usage
|
|
4489
|
+
--proxy Proxy mode: automatically configure MCPC to wrap an MCP server
|
|
4490
|
+
Use with --transport-type to specify the transport
|
|
4491
|
+
Example: --proxy --transport-type stdio -- npx -y @wonderwhy-er/desktop-commander
|
|
4492
|
+
--transport-type <type> Transport type for proxy mode
|
|
4493
|
+
Supported types: stdio, streamable-http, sse
|
|
4494
|
+
--name <name> Custom server name for proxy mode (overrides auto-detection)
|
|
4410
4495
|
|
|
4411
4496
|
ENVIRONMENT VARIABLES:
|
|
4412
4497
|
MCPC_CONFIG Inline JSON configuration (same as --config)
|
|
@@ -4415,27 +4500,42 @@ ENVIRONMENT VARIABLES:
|
|
|
4415
4500
|
|
|
4416
4501
|
EXAMPLES:
|
|
4417
4502
|
# Show help
|
|
4418
|
-
|
|
4503
|
+
mcpc --help
|
|
4504
|
+
|
|
4505
|
+
# Proxy mode - wrap an existing MCP server (stdio)
|
|
4506
|
+
mcpc --proxy --transport-type stdio -- npx -y @wonderwhy-er/desktop-commander
|
|
4507
|
+
|
|
4508
|
+
# Proxy mode with custom server name
|
|
4509
|
+
mcpc --proxy --transport-type stdio --name my-server -- npx shadcn@latest mcp
|
|
4510
|
+
|
|
4511
|
+
# Proxy mode - wrap an MCP server (streamable-http)
|
|
4512
|
+
mcpc --proxy --transport-type streamable-http -- https://api.example.com/mcp
|
|
4513
|
+
|
|
4514
|
+
# Proxy mode - wrap an MCP server (sse)
|
|
4515
|
+
mcpc --proxy --transport-type sse -- https://api.example.com/sse
|
|
4419
4516
|
|
|
4420
4517
|
# Load from URL
|
|
4421
|
-
|
|
4518
|
+
mcpc --config-url \\
|
|
4422
4519
|
"https://raw.githubusercontent.com/mcpc-tech/mcpc/main/packages/cli/examples/configs/codex-fork.json"
|
|
4423
4520
|
|
|
4424
4521
|
# Load from URL with custom headers
|
|
4425
|
-
|
|
4522
|
+
mcpc \\
|
|
4426
4523
|
--config-url "https://api.example.com/config.json" \\
|
|
4427
4524
|
-H "Authorization: Bearer token123" \\
|
|
4428
4525
|
-H "X-Custom-Header: value"
|
|
4429
4526
|
|
|
4430
4527
|
# Load from file
|
|
4431
|
-
|
|
4528
|
+
mcpc --config-file ./my-config.json
|
|
4529
|
+
|
|
4530
|
+
# Override execution mode for all agents
|
|
4531
|
+
mcpc --config-file ./my-config.json --mode agentic_workflow
|
|
4432
4532
|
|
|
4433
4533
|
# Using environment variable
|
|
4434
4534
|
export MCPC_CONFIG='[{"name":"agent","description":"..."}]'
|
|
4435
|
-
|
|
4535
|
+
mcpc
|
|
4436
4536
|
|
|
4437
4537
|
# Use default configuration (./mcpc.config.json)
|
|
4438
|
-
|
|
4538
|
+
mcpc
|
|
4439
4539
|
|
|
4440
4540
|
CONFIGURATION:
|
|
4441
4541
|
Configuration files support environment variable substitution using $VAR_NAME syntax.
|
|
@@ -4476,6 +4576,17 @@ function parseArgs() {
|
|
|
4476
4576
|
}
|
|
4477
4577
|
} else if (arg === "--help" || arg === "-h") {
|
|
4478
4578
|
result.help = true;
|
|
4579
|
+
} else if (arg === "--proxy") {
|
|
4580
|
+
result.proxy = true;
|
|
4581
|
+
} else if (arg === "--transport-type" && i + 1 < args.length) {
|
|
4582
|
+
result.transportType = args[++i];
|
|
4583
|
+
} else if (arg === "--mode" && i + 1 < args.length) {
|
|
4584
|
+
result.mode = args[++i];
|
|
4585
|
+
} else if (arg === "--name" && i + 1 < args.length) {
|
|
4586
|
+
result.name = args[++i];
|
|
4587
|
+
} else if (arg === "--") {
|
|
4588
|
+
result.proxyCommand = args.slice(i + 1);
|
|
4589
|
+
break;
|
|
4479
4590
|
}
|
|
4480
4591
|
}
|
|
4481
4592
|
return result;
|
|
@@ -4486,10 +4597,13 @@ async function loadConfig() {
|
|
|
4486
4597
|
printHelp();
|
|
4487
4598
|
process7.exit(0);
|
|
4488
4599
|
}
|
|
4600
|
+
if (args.proxy) {
|
|
4601
|
+
return createProxyConfig(args);
|
|
4602
|
+
}
|
|
4489
4603
|
if (args.config) {
|
|
4490
4604
|
try {
|
|
4491
4605
|
const parsed = JSON.parse(args.config);
|
|
4492
|
-
return normalizeConfig(parsed);
|
|
4606
|
+
return applyModeOverride(normalizeConfig(parsed), args.mode);
|
|
4493
4607
|
} catch (error) {
|
|
4494
4608
|
console.error("Failed to parse --config argument:", error);
|
|
4495
4609
|
throw error;
|
|
@@ -4498,7 +4612,7 @@ async function loadConfig() {
|
|
|
4498
4612
|
if (process7.env.MCPC_CONFIG) {
|
|
4499
4613
|
try {
|
|
4500
4614
|
const parsed = JSON.parse(process7.env.MCPC_CONFIG);
|
|
4501
|
-
return normalizeConfig(parsed);
|
|
4615
|
+
return applyModeOverride(normalizeConfig(parsed), args.mode);
|
|
4502
4616
|
} catch (error) {
|
|
4503
4617
|
console.error("Failed to parse MCPC_CONFIG environment variable:", error);
|
|
4504
4618
|
throw error;
|
|
@@ -4519,7 +4633,7 @@ async function loadConfig() {
|
|
|
4519
4633
|
}
|
|
4520
4634
|
const content = await response.text();
|
|
4521
4635
|
const parsed = JSON.parse(content);
|
|
4522
|
-
return normalizeConfig(parsed);
|
|
4636
|
+
return applyModeOverride(normalizeConfig(parsed), args.mode);
|
|
4523
4637
|
} catch (error) {
|
|
4524
4638
|
console.error(`Failed to fetch config from ${configUrl}:`, error);
|
|
4525
4639
|
throw error;
|
|
@@ -4530,7 +4644,7 @@ async function loadConfig() {
|
|
|
4530
4644
|
try {
|
|
4531
4645
|
const content = await readFile(configFile, "utf-8");
|
|
4532
4646
|
const parsed = JSON.parse(content);
|
|
4533
|
-
return normalizeConfig(parsed);
|
|
4647
|
+
return applyModeOverride(normalizeConfig(parsed), args.mode);
|
|
4534
4648
|
} catch (error) {
|
|
4535
4649
|
if (error.code === "ENOENT") {
|
|
4536
4650
|
console.error(`Config file not found: ${configFile}`);
|
|
@@ -4545,7 +4659,7 @@ async function loadConfig() {
|
|
|
4545
4659
|
try {
|
|
4546
4660
|
const content = await readFile(defaultConfigPath, "utf-8");
|
|
4547
4661
|
const parsed = JSON.parse(content);
|
|
4548
|
-
return normalizeConfig(parsed);
|
|
4662
|
+
return applyModeOverride(normalizeConfig(parsed), args.mode);
|
|
4549
4663
|
} catch (error) {
|
|
4550
4664
|
if (error.code === "ENOENT") {
|
|
4551
4665
|
return null;
|
|
@@ -4576,6 +4690,14 @@ function replaceEnvVarsInConfig(obj) {
|
|
|
4576
4690
|
}
|
|
4577
4691
|
return obj;
|
|
4578
4692
|
}
|
|
4693
|
+
function applyModeOverride(config2, mode) {
|
|
4694
|
+
if (!mode) return config2;
|
|
4695
|
+
config2.agents.forEach((agent) => {
|
|
4696
|
+
if (!agent.options) agent.options = {};
|
|
4697
|
+
agent.options.mode = mode;
|
|
4698
|
+
});
|
|
4699
|
+
return config2;
|
|
4700
|
+
}
|
|
4579
4701
|
function normalizeConfig(config2) {
|
|
4580
4702
|
config2 = replaceEnvVarsInConfig(config2);
|
|
4581
4703
|
if (Array.isArray(config2)) {
|
|
@@ -4606,7 +4728,20 @@ function normalizeAgents(agents) {
|
|
|
4606
4728
|
}
|
|
4607
4729
|
|
|
4608
4730
|
// __mcpc__cli_latest/node_modules/@mcpc/cli/src/bin.ts
|
|
4731
|
+
import { createCodeExecutionPlugin } from "@mcpc-tech/plugin-code-execution";
|
|
4609
4732
|
var config = await loadConfig();
|
|
4733
|
+
config?.agents.forEach((agent) => {
|
|
4734
|
+
if (agent.plugins?.length ?? true) {
|
|
4735
|
+
agent.plugins = [];
|
|
4736
|
+
}
|
|
4737
|
+
agent.plugins?.push(
|
|
4738
|
+
createCodeExecutionPlugin({
|
|
4739
|
+
sandbox: {
|
|
4740
|
+
timeout: 3e5
|
|
4741
|
+
}
|
|
4742
|
+
})
|
|
4743
|
+
);
|
|
4744
|
+
});
|
|
4610
4745
|
if (config) {
|
|
4611
4746
|
console.error(`Loaded configuration with ${config.agents.length} agent(s)`);
|
|
4612
4747
|
} else {
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mcpc-tech/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.15",
|
|
4
4
|
"homepage": "https://jsr.io/@mcpc/cli",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@hono/zod-openapi": "^0.19.2",
|
|
8
|
+
"@mcpc-tech/plugin-code-execution": "^0.0.5",
|
|
8
9
|
"@modelcontextprotocol/sdk": "^1.8.0",
|
|
9
10
|
"zod": "^3.24.2",
|
|
10
11
|
"@mcpc-tech/ripgrep-napi": "^0.0.4",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader.d.ts","sources":["../../../src/config/loader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2CC,GAED,cAAc,iBAAiB,0BAAgC;AAK/D,iBAAiB;EACf;;GAEC,GACD,OAAO,MAAM;EACb;;GAEC,GACD,UAAU,MAAM;EAChB;;GAEC,GACD;IACE,QAAQ,OAAO,MAAM,EAAE,OAAO;IAC9B,WAAW,OAAO,MAAM,EAAE,OAAO;;EAEnC;;GAEC,GACD,QAAQ;;
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sources":["../../../src/config/loader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2CC,GAED,cAAc,iBAAiB,0BAAgC;AAK/D,iBAAiB;EACf;;GAEC,GACD,OAAO,MAAM;EACb;;GAEC,GACD,UAAU,MAAM;EAChB;;GAEC,GACD;IACE,QAAQ,OAAO,MAAM,EAAE,OAAO;IAC9B,WAAW,OAAO,MAAM,EAAE,OAAO;;EAEnC;;GAEC,GACD,QAAQ;;AAqRV;;;CAGC,GACD,OAAO,iBAAe,cAAc,QAAQ,aAAa,IAAI;AAqL7D;;CAEC,GACD,OAAO,iBAAS,eAAe,QAAQ,UAAU,GAAG,IAAI"}
|