parallelsandbox-mcp 0.2.0 → 0.2.1

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/index.mjs +19 -2
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -28,8 +28,11 @@ if (!API_KEY) {
28
28
  }
29
29
 
30
30
  const remote = new Client({ name: "parallelsandbox-mcp", version: "0.1.0" });
31
+ // 同一個 headers 物件每次請求都會被讀到,所以握手拿到對方是誰之後直接塞進去。
32
+ // 沒有這個,control 只知道「某個 API key 開了箱子」,人在 app 裡看不出是 Claude 還是 Codex 在用。
33
+ const remoteHeaders = { Authorization: `Bearer ${API_KEY}` };
31
34
  const transport = new StreamableHTTPClientTransport(new URL(MCP_URL), {
32
- requestInit: { headers: { Authorization: `Bearer ${API_KEY}` } },
35
+ requestInit: { headers: remoteHeaders },
33
36
  });
34
37
 
35
38
  async function connectRemote() {
@@ -117,7 +120,12 @@ async function sync(args) {
117
120
  }
118
121
  const mb = Number((uploaded / 1024 / 1024).toFixed(1));
119
122
  const how = mode === "git" ? "git tracked + untracked files, honouring .gitignore" : `denylist: ${SYNC_EXCLUDES.join(", ")}`;
120
- return textResult(JSON.stringify({ ok: true, dest, uploadedMB: mb, selected: how }, null, 2));
123
+ // uploadedMB 對小專案永遠是 0,看起來像什麼都沒傳;bytes 與檔數才看得出成功。
124
+ const out = { ok: true, dest, uploadedBytes: uploaded, uploadedMB: mb, selected: how };
125
+ // fileList 是 git ls-files -z 的原始 bytes(不是字串:檔名不一定是合法 UTF-8,轉字串會壞掉),
126
+ // 所以檔數用數 NUL 分隔符算,不要用 split。
127
+ if (fileList) out.files = fileList.reduce((n, b) => (b === 0 ? n + 1 : n), 0);
128
+ return textResult(JSON.stringify(out, null, 2));
121
129
  }
122
130
 
123
131
  const server = new Server({ name: "parallelsandbox", version: "0.1.0" }, { capabilities: { tools: {} } });
@@ -127,7 +135,16 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
127
135
  return { tools };
128
136
  });
129
137
 
138
+ // tellRemoteWhoIsCalling:把呼叫端 initialize 時報的名字轉給 control(X-Psbx-Client)。
139
+ // 報不出來就不帶,control 那邊就不顯示,不猜。
140
+ function tellRemoteWhoIsCalling() {
141
+ const who = server.getClientVersion?.();
142
+ if (!who?.name) return;
143
+ remoteHeaders["X-Psbx-Client"] = who.version ? `${who.name}/${who.version}` : who.name;
144
+ }
145
+
130
146
  server.setRequestHandler(CallToolRequestSchema, async (req) => {
147
+ tellRemoteWhoIsCalling();
131
148
  const { name, arguments: args } = req.params;
132
149
  if (name === "sandbox_sync") {
133
150
  return sync(args);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "parallelsandbox-mcp",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "stdio adapter for the ParallelSandbox MCP server: runs locally so sandbox_sync can upload your working directory",
5
5
  "type": "module",
6
6
  "bin": {