@super-hands/connect 0.1.5 → 0.1.6

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/client.mjs +53 -27
  2. package/package.json +1 -1
package/client.mjs CHANGED
@@ -94,6 +94,12 @@ function stop(message) {
94
94
  `);
95
95
  process.exit(1);
96
96
  }
97
+ function cursorServerEntry(args) {
98
+ return {
99
+ url: args.endpoint,
100
+ headers: { Authorization: mcpAuthorizationHeader(args.token) }
101
+ };
102
+ }
97
103
  function mergedCursorConfig(existing, args) {
98
104
  let config = {};
99
105
  if (existing !== null && existing.trim() !== "") {
@@ -111,10 +117,7 @@ function mergedCursorConfig(existing, args) {
111
117
  const serversRaw = config.mcpServers;
112
118
  const servers = typeof serversRaw === "object" && serversRaw !== null && !Array.isArray(serversRaw) ? serversRaw : {};
113
119
  const replaced = MCP_SERVER_KEY in servers;
114
- servers[MCP_SERVER_KEY] = {
115
- url: args.endpoint,
116
- headers: { Authorization: mcpAuthorizationHeader(args.token) }
117
- };
120
+ servers[MCP_SERVER_KEY] = cursorServerEntry(args);
118
121
  config.mcpServers = servers;
119
122
  return { text: `${JSON.stringify(config, null, 2)}
120
123
  `, replaced };
@@ -198,26 +201,40 @@ async function main() {
198
201
  } catch {
199
202
  existing = null;
200
203
  }
204
+ let merged = null;
201
205
  try {
202
- const merged = mergedCursorConfig(existing, { endpoint, token });
203
- mkdirSync(dirname(configPath), { recursive: true });
204
- writeFileSync(configPath, merged.text);
205
- say(
206
- merged.replaced ? `Cursor \u2014 updated the ${MCP_SERVER_KEY} server in ${configPath}.` : `Cursor \u2014 added the ${MCP_SERVER_KEY} server to ${configPath}.`
207
- );
208
- if (openCursor()) {
209
- say(
210
- ` Cursor is opening \u2014 enable ${MCP_SERVER_KEY} under Settings \u2192 MCP. If it was already running, restart it first.`
211
- );
212
- } else {
213
- say(` Open Cursor (restart it if it was running), then enable ${MCP_SERVER_KEY} under Settings \u2192 MCP.`);
214
- }
215
- writeSkill(cursorDir);
216
- connected += 1;
206
+ merged = mergedCursorConfig(existing, { endpoint, token });
217
207
  } catch {
218
208
  say(`Cursor \u2014 ${configPath} is not valid JSON, so it was left untouched.`);
219
209
  say(" Fix or remove that file, then run this command again.");
220
210
  }
211
+ if (merged) {
212
+ try {
213
+ mkdirSync(dirname(configPath), { recursive: true });
214
+ writeFileSync(configPath, merged.text);
215
+ say(
216
+ merged.replaced ? `Cursor \u2014 updated the ${MCP_SERVER_KEY} server in ${configPath}.` : `Cursor \u2014 added the ${MCP_SERVER_KEY} server to ${configPath}.`
217
+ );
218
+ if (openCursor()) {
219
+ say(
220
+ ` Cursor is opening \u2014 enable ${MCP_SERVER_KEY} under Settings \u2192 MCP. If it was already running, restart it first.`
221
+ );
222
+ } else {
223
+ say(` Open Cursor (restart it if it was running), then enable ${MCP_SERVER_KEY} under Settings \u2192 MCP.`);
224
+ }
225
+ writeSkill(cursorDir);
226
+ connected += 1;
227
+ } catch {
228
+ say(`Cursor \u2014 ${configPath} could not be written, so it was left as it was.`);
229
+ say(
230
+ ' A sandboxed agent usually cannot write outside its workspace. Run this same command in a regular terminal, or add this under "mcpServers" in that file (or in .cursor/mcp.json inside the project, which connects this project alone):'
231
+ );
232
+ process.stdout.write(
233
+ `${JSON.stringify({ [MCP_SERVER_KEY]: cursorServerEntry({ endpoint, token }) }, null, 2)}
234
+ `
235
+ );
236
+ }
237
+ }
221
238
  }
222
239
  if (onlyClaude || autodetect && hasCli("claude")) {
223
240
  attempted += 1;
@@ -269,14 +286,23 @@ async function main() {
269
286
  writeSkill(codexDir);
270
287
  connected += 1;
271
288
  } else {
272
- mkdirSync(dirname(configPath), { recursive: true });
273
- writeFileSync(configPath, result.text);
274
- say(
275
- result.repaired ? `Codex \u2014 replaced the ${MCP_SERVER_KEY} entry in ${configPath}: its old bearer_token spelling makes current Codex reject the whole config.` : `Codex \u2014 added the ${MCP_SERVER_KEY} server to ${configPath}.`
276
- );
277
- say(" The app and the CLI both read this config \u2014 open either and it connects when a session starts.");
278
- writeSkill(codexDir);
279
- connected += 1;
289
+ try {
290
+ mkdirSync(dirname(configPath), { recursive: true });
291
+ writeFileSync(configPath, result.text);
292
+ say(
293
+ result.repaired ? `Codex \u2014 replaced the ${MCP_SERVER_KEY} entry in ${configPath}: its old bearer_token spelling makes current Codex reject the whole config.` : `Codex \u2014 added the ${MCP_SERVER_KEY} server to ${configPath}.`
294
+ );
295
+ say(" The app and the CLI both read this config \u2014 open either and it connects when a session starts.");
296
+ writeSkill(codexDir);
297
+ connected += 1;
298
+ } catch {
299
+ say(`Codex \u2014 ${configPath} could not be written, so it was left as it was.`);
300
+ say(
301
+ " A sandboxed agent usually cannot write outside its workspace. Run this same command in a regular terminal, or append this block to that file yourself:"
302
+ );
303
+ process.stdout.write(`${codexConfigBlock({ endpoint, token })}
304
+ `);
305
+ }
280
306
  }
281
307
  }
282
308
  if (connected === 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@super-hands/connect",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "Connect the coding agents on this machine to your team's Superhands MCP server. Writes each client's own config; reads no repository, uploads nothing.",
5
5
  "bin": {
6
6
  "superhands-connect": "client.mjs"