@papercraneai/sandbox-agent 0.1.7 → 0.1.9

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.
Files changed (2) hide show
  1. package/dist/index.js +18 -6
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -76,6 +76,10 @@ function parseArgs() {
76
76
  }
77
77
  result.hostMode = mode;
78
78
  }
79
+ else if (arg === "--version" || arg === "-v") {
80
+ console.log(pkg.version);
81
+ process.exit(0);
82
+ }
79
83
  else if (arg === "--help" || arg === "-h") {
80
84
  console.log(`
81
85
  sandbox-agent - Claude Agent SDK server for environments
@@ -383,11 +387,14 @@ const showPreviewTool = tool("ShowPreview", "Shows the preview iframe for a spec
383
387
  }]
384
388
  };
385
389
  });
386
- // Create MCP server for client-side tools
387
- const clientToolsServer = createSdkMcpServer({
388
- name: "client-tools",
389
- tools: [showPreviewTool]
390
- });
390
+ // Factory to create a fresh MCP server per chat session
391
+ // (each Protocol instance can only be connected to one transport at a time)
392
+ function createClientToolsServer() {
393
+ return createSdkMcpServer({
394
+ name: "client-tools",
395
+ tools: [showPreviewTool]
396
+ });
397
+ }
391
398
  // Recursively build file tree
392
399
  async function buildFileTree(dirPath) {
393
400
  const entries = await readdir(dirPath, { withFileTypes: true });
@@ -1180,13 +1187,14 @@ app.post("/chat", async (req, res) => {
1180
1187
  "KillShell",
1181
1188
  "mcp__client-tools__ShowPreview"
1182
1189
  ];
1190
+ const clientTools = createClientToolsServer();
1183
1191
  const options = {
1184
1192
  maxTurns,
1185
1193
  cwd,
1186
1194
  permissionMode: "bypassPermissions",
1187
1195
  allowDangerouslySkipPermissions: true,
1188
1196
  mcpServers: {
1189
- "client-tools": clientToolsServer
1197
+ "client-tools": clientTools
1190
1198
  },
1191
1199
  allowedTools: allowedTools || defaultTools,
1192
1200
  settingSources: ["project"],
@@ -1267,6 +1275,10 @@ app.post("/chat", async (req, res) => {
1267
1275
  res.end();
1268
1276
  }
1269
1277
  }
1278
+ finally {
1279
+ // Close the per-session MCP server to free resources
1280
+ await clientTools.instance?.close().catch(() => { });
1281
+ }
1270
1282
  });
1271
1283
  // =============================================================================
1272
1284
  // Registration & Heartbeat
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@papercraneai/sandbox-agent",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
4
4
  "description": "Claude Agent SDK server for sandbox environments",
5
5
  "license": "MIT",
6
6
  "type": "module",