Skip to content

Commit 529676b

Browse files
committed
feat(cli): Add --name flag for proxied agents and increase timeout
Additionally, the default timeout for the code execution plugin's sandbox has been increased to 5 minutes (300,000 ms) to better accommodate long-running tasks and prevent premature termination. This required updating the `@mcpc-tech/plugin-code-execution` dependency.
1 parent eaa61af commit 529676b

File tree

4 files changed

+51
-24
lines changed

4 files changed

+51
-24
lines changed

deno.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/cli/deno.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@mcpc/cli",
3-
"version": "0.1.14",
3+
"version": "0.1.15",
44
"repository": {
55
"type": "git",
66
"url": "git+https://github.com/mcpc-tech/mcpc.git"
@@ -12,7 +12,7 @@
1212
"./app": "./src/app.ts"
1313
},
1414
"imports": {
15-
"@mcpc-tech/plugin-code-execution": "npm:@mcpc-tech/plugin-code-execution@^0.0.4",
15+
"@mcpc-tech/plugin-code-execution": "npm:@mcpc-tech/plugin-code-execution@^0.0.5",
1616
"@mcpc/core": "jsr:@mcpc/core@^0.3.4",
1717
"@mcpc/utils": "jsr:@mcpc/utils@^0.2.2",
1818
"@modelcontextprotocol/sdk": "npm:@modelcontextprotocol/sdk@^1.8.0",

packages/cli/src/bin.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,13 @@ config?.agents.forEach((agent) => {
4848
if (agent.plugins?.length ?? 0 === 0) {
4949
agent.plugins = [];
5050
}
51-
agent.plugins?.push(createCodeExecutionPlugin());
51+
agent.plugins?.push(
52+
createCodeExecutionPlugin({
53+
sandbox: {
54+
timeout: 300_000,
55+
},
56+
}),
57+
);
5258
});
5359

5460
if (config) {

packages/cli/src/config/loader.ts

Lines changed: 38 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,28 @@ export interface MCPCConfig {
7070
agents: ComposeDefinition[];
7171
}
7272

73+
/**
74+
* Extract server name from command and arguments
75+
* Simply sanitizes the first non-flag argument or command name
76+
*/
77+
function extractServerName(command: string, commandArgs: string[]): string {
78+
// Try first non-flag argument
79+
for (const arg of commandArgs) {
80+
if (!arg.startsWith("-")) {
81+
const name = arg
82+
.replace(/[@.,/\\:;!?#$%^&*()[\]{}]/g, "_")
83+
.substring(0, 64);
84+
if (name) return name;
85+
}
86+
}
87+
88+
// Fall back to command itself
89+
const name = command
90+
.replace(/[@.,/\\:;!?#$%^&*()[\]{}]/g, "_")
91+
.substring(0, 64);
92+
return name || "agentic-tool";
93+
}
94+
7395
/**
7496
* Create proxy configuration from command-line arguments
7597
* This generates an MCPC config that wraps an existing MCP server
@@ -78,6 +100,7 @@ function createProxyConfig(args: {
78100
transportType?: string;
79101
proxyCommand?: string[];
80102
mode?: string;
103+
name?: string;
81104
}): MCPCConfig {
82105
if (!args.proxyCommand || args.proxyCommand.length === 0) {
83106
console.error("Error: --proxy requires a command after --");
@@ -106,19 +129,8 @@ function createProxyConfig(args: {
106129
const command = args.proxyCommand[0];
107130
const commandArgs = args.proxyCommand.slice(1);
108131

109-
// Extract server name from command (e.g., "@wonderwhy-er/desktop-commander" -> "desktop-commander")
110-
let serverName = "mcp-server";
111-
const npmPackageMatch = command.match(/@[\w-]+\/([\w-]+)/) ||
112-
commandArgs.join(" ").match(/@[\w-]+\/([\w-]+)/);
113-
if (npmPackageMatch) {
114-
serverName = npmPackageMatch[1];
115-
} else {
116-
// Try to get name from command itself
117-
const baseName = command.split("/").pop()?.replace(/\.js$/, "");
118-
if (baseName && baseName !== "npx" && baseName !== "node") {
119-
serverName = baseName;
120-
}
121-
}
132+
// Use custom name if provided, otherwise extract from command
133+
const serverName = args.name || extractServerName(command, commandArgs);
122134

123135
// Create configuration
124136
const config: MCPCConfig = {
@@ -131,9 +143,7 @@ function createProxyConfig(args: {
131143
agents: [
132144
{
133145
name: serverName,
134-
description:
135-
`Agentic tool to orchestrate ${serverName} MCP server tools:
136-
<tool name="${serverName}.__ALL__"/>`,
146+
description: `Orchestrate ${serverName} MCP server tools`,
137147
deps: {
138148
mcpServers: {
139149
[serverName]: {
@@ -147,7 +157,10 @@ function createProxyConfig(args: {
147157
},
148158
},
149159
options: {
150-
mode: (args.mode || "agentic") as any,
160+
mode: (args.mode || "agentic"),
161+
refs: [
162+
`<tool name="${serverName}.__ALL__"/>`,
163+
],
151164
},
152165
},
153166
],
@@ -194,6 +207,7 @@ OPTIONS:
194207
Example: --proxy --transport-type stdio -- npx -y @wonderwhy-er/desktop-commander
195208
--transport-type <type> Transport type for proxy mode
196209
Supported types: stdio, streamable-http, sse
210+
--name <name> Custom server name for proxy mode (overrides auto-detection)
197211
198212
ENVIRONMENT VARIABLES:
199213
MCPC_CONFIG Inline JSON configuration (same as --config)
@@ -207,6 +221,9 @@ EXAMPLES:
207221
# Proxy mode - wrap an existing MCP server (stdio)
208222
mcpc --proxy --transport-type stdio -- npx -y @wonderwhy-er/desktop-commander
209223
224+
# Proxy mode with custom server name
225+
mcpc --proxy --transport-type stdio --name my-server -- npx shadcn@latest mcp
226+
210227
# Proxy mode - wrap an MCP server (streamable-http)
211228
mcpc --proxy --transport-type streamable-http -- https://api.example.com/mcp
212229
@@ -263,6 +280,7 @@ function parseArgs(): {
263280
transportType?: string;
264281
proxyCommand?: string[];
265282
mode?: string;
283+
name?: string;
266284
} {
267285
const args = process.argv.slice(2);
268286
const result: {
@@ -275,6 +293,7 @@ function parseArgs(): {
275293
transportType?: string;
276294
proxyCommand?: string[];
277295
mode?: string;
296+
name?: string;
278297
} = {};
279298

280299
for (let i = 0; i < args.length; i++) {
@@ -313,6 +332,8 @@ function parseArgs(): {
313332
result.transportType = args[++i];
314333
} else if (arg === "--mode" && i + 1 < args.length) {
315334
result.mode = args[++i];
335+
} else if (arg === "--name" && i + 1 < args.length) {
336+
result.name = args[++i];
316337
} else if (arg === "--") {
317338
// Everything after -- is the proxy command
318339
result.proxyCommand = args.slice(i + 1);

0 commit comments

Comments
 (0)