@rvry/mcp 0.1.4 → 0.1.5

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/setup.js +272 -123
  2. package/package.json +2 -2
package/dist/setup.js CHANGED
@@ -180,9 +180,6 @@ function openBrowser(url) {
180
180
  return false;
181
181
  }
182
182
  }
183
- /**
184
- * Check if the `claude` CLI is available in PATH.
185
- */
186
183
  function isClaudeCLIAvailable() {
187
184
  try {
188
185
  const cmd = platform() === 'win32' ? 'where claude' : 'which claude';
@@ -193,9 +190,6 @@ function isClaudeCLIAvailable() {
193
190
  return false;
194
191
  }
195
192
  }
196
- /**
197
- * Get the platform-specific Claude Desktop config file path.
198
- */
199
193
  function getDesktopConfigPath() {
200
194
  const plat = platform();
201
195
  if (plat === 'darwin') {
@@ -206,19 +200,10 @@ function getDesktopConfigPath() {
206
200
  }
207
201
  return join(homedir(), '.config', 'Claude', 'claude_desktop_config.json');
208
202
  }
209
- /**
210
- * Check if Claude Desktop config directory exists (app is installed).
211
- */
212
203
  function isClaudeDesktopInstalled() {
213
204
  const configPath = getDesktopConfigPath();
214
- const configDir = dirname(configPath);
215
- return existsSync(configDir);
205
+ return existsSync(dirname(configPath));
216
206
  }
217
- /**
218
- * Configure Claude Desktop by merging RVRY into the existing config.
219
- * Creates the config file if it doesn't exist. Preserves other MCP servers.
220
- * Returns 'created' | 'updated' | 'unchanged' | 'error'.
221
- */
222
207
  function configureDesktop(token) {
223
208
  const configPath = getDesktopConfigPath();
224
209
  try {
@@ -235,29 +220,23 @@ function configureDesktop(token) {
235
220
  config = {};
236
221
  }
237
222
  }
238
- // Ensure mcpServers object exists
239
223
  if (!config.mcpServers || typeof config.mcpServers !== 'object') {
240
224
  config.mcpServers = {};
241
225
  }
242
226
  const servers = config.mcpServers;
243
- const newEntry = RVRY_SERVER_ENTRY(token);
244
- // Check if RVRY is already configured with the same token
245
227
  const existing = servers.RVRY;
246
228
  if (existing) {
247
229
  const existingEnv = existing.env;
248
- if (existingEnv?.RVRY_TOKEN === token) {
230
+ if (existingEnv?.RVRY_TOKEN === token)
249
231
  return 'unchanged';
250
- }
251
232
  }
252
233
  const wasNew = !existing;
253
- servers.RVRY = newEntry;
254
- // Write config with clean formatting
234
+ servers.RVRY = RVRY_SERVER_ENTRY(token);
255
235
  const configDir = dirname(configPath);
256
- if (!existsSync(configDir)) {
236
+ if (!existsSync(configDir))
257
237
  mkdirSync(configDir, { recursive: true });
258
- }
259
238
  writeFileSync(configPath, JSON.stringify(config, null, 2) + '\n', 'utf-8');
260
- return wasNew ? 'created' : 'updated';
239
+ return wasNew ? 'ok' : 'updated';
261
240
  }
262
241
  catch (err) {
263
242
  const msg = err instanceof Error ? err.message : String(err);
@@ -265,27 +244,221 @@ function configureDesktop(token) {
265
244
  return 'error';
266
245
  }
267
246
  }
268
- /**
269
- * Register RVRY as an MCP server in Claude Code.
270
- * Removes existing registration first for idempotency.
271
- */
272
247
  function registerClaudeCode(token) {
273
248
  try {
274
- // Remove existing (ignore error if not registered)
275
249
  try {
276
250
  execSync('claude mcp remove rvry', { stdio: 'pipe' });
277
251
  }
278
- catch {
279
- // Not registered yet, that's fine
280
- }
281
- // Add with token
252
+ catch { /* not registered */ }
282
253
  execSync(`claude mcp add -e RVRY_TOKEN="${token}" -s user rvry -- npx @rvry/mcp`, { stdio: 'inherit' });
283
- return true;
254
+ return 'ok';
284
255
  }
285
256
  catch {
286
- return false;
257
+ return 'error';
258
+ }
259
+ }
260
+ /**
261
+ * Write RVRY server entry into a generic MCP JSON config file.
262
+ * Used by clients that follow the Desktop-style config format (Codex, Gemini, etc.)
263
+ */
264
+ function configureJsonMcp(configPath, token) {
265
+ try {
266
+ let config = {};
267
+ if (existsSync(configPath)) {
268
+ const raw = readFileSync(configPath, 'utf-8');
269
+ try {
270
+ config = JSON.parse(raw);
271
+ }
272
+ catch {
273
+ writeFileSync(configPath + '.backup', raw, 'utf-8');
274
+ config = {};
275
+ }
276
+ }
277
+ if (!config.mcpServers || typeof config.mcpServers !== 'object') {
278
+ config.mcpServers = {};
279
+ }
280
+ const servers = config.mcpServers;
281
+ const existing = servers.RVRY;
282
+ if (existing) {
283
+ const existingEnv = existing.env;
284
+ if (existingEnv?.RVRY_TOKEN === token)
285
+ return 'unchanged';
286
+ }
287
+ const wasNew = !existing;
288
+ servers.RVRY = RVRY_SERVER_ENTRY(token);
289
+ const dir = dirname(configPath);
290
+ if (!existsSync(dir))
291
+ mkdirSync(dir, { recursive: true });
292
+ writeFileSync(configPath, JSON.stringify(config, null, 2) + '\n', 'utf-8');
293
+ return wasNew ? 'ok' : 'updated';
294
+ }
295
+ catch (err) {
296
+ const msg = err instanceof Error ? err.message : String(err);
297
+ console.log(` Error writing config: ${msg}`);
298
+ return 'error';
287
299
  }
288
300
  }
301
+ /** All supported clients. Add new clients here. */
302
+ const CLIENT_REGISTRY = [
303
+ {
304
+ name: 'Claude Code',
305
+ id: 'code',
306
+ detect: isClaudeCLIAvailable,
307
+ configure: registerClaudeCode,
308
+ notInstalledHint: 'CLI not found (https://docs.anthropic.com/en/docs/claude-code)',
309
+ },
310
+ {
311
+ name: 'Claude Desktop / Claude Co-Work',
312
+ id: 'desktop',
313
+ detect: isClaudeDesktopInstalled,
314
+ configure: (token) => configureDesktop(token),
315
+ notInstalledHint: 'Not installed',
316
+ },
317
+ {
318
+ name: 'Anti-Gravity',
319
+ id: 'antigravity',
320
+ detect: () => {
321
+ // OR-logic: binary (agy or antigravity), config dir, or macOS app bundle
322
+ try {
323
+ const cmd = platform() === 'win32' ? 'where agy' : 'which agy';
324
+ execSync(cmd, { stdio: 'pipe' });
325
+ return true;
326
+ }
327
+ catch { /* not on PATH */ }
328
+ if (platform() !== 'win32') {
329
+ try {
330
+ execSync('which antigravity', { stdio: 'pipe' });
331
+ return true;
332
+ }
333
+ catch { /* not on PATH */ }
334
+ }
335
+ if (existsSync(join(homedir(), '.gemini', 'antigravity')))
336
+ return true;
337
+ if (platform() === 'darwin' && existsSync('/Applications/Google Antigravity.app'))
338
+ return true;
339
+ return false;
340
+ },
341
+ configure: (token) => configureJsonMcp(join(homedir(), '.gemini', 'antigravity', 'mcp_config.json'), token),
342
+ notInstalledHint: 'Not installed (https://antigravity.google)',
343
+ },
344
+ ];
345
+ /**
346
+ * Interactive multi-select picker with arrow keys + space + enter.
347
+ * Returns indices of selected items.
348
+ */
349
+ function multiSelect(items) {
350
+ return new Promise((resolve) => {
351
+ const stdin = process.stdin;
352
+ const wasRaw = stdin.isRaw;
353
+ if (typeof stdin.setRawMode === 'function')
354
+ stdin.setRawMode(true);
355
+ stdin.resume();
356
+ stdin.setEncoding('utf8');
357
+ let cursor = items.findIndex((i) => i.available);
358
+ if (cursor === -1)
359
+ cursor = 0;
360
+ const render = () => {
361
+ // Move cursor up to overwrite previous render (except first render)
362
+ for (let i = 0; i < items.length; i++) {
363
+ process.stdout.write('\x1b[2K'); // clear line
364
+ if (i < items.length - 1)
365
+ process.stdout.write('\x1b[1A'); // move up
366
+ }
367
+ process.stdout.write('\r');
368
+ for (let i = 0; i < items.length; i++) {
369
+ const item = items[i];
370
+ const pointer = i === cursor ? '›' : ' ';
371
+ const checkbox = !item.available
372
+ ? '\x1b[2m[ ]\x1b[0m'
373
+ : item.selected
374
+ ? '\x1b[32m[x]\x1b[0m'
375
+ : '[ ]';
376
+ const label = !item.available
377
+ ? `\x1b[2m${item.label}\x1b[0m`
378
+ : item.label;
379
+ const hint = !item.available && item.hint
380
+ ? ` \x1b[2m${item.hint}\x1b[0m`
381
+ : '';
382
+ process.stdout.write(` ${pointer} ${checkbox} ${label}${hint}`);
383
+ if (i < items.length - 1)
384
+ process.stdout.write('\n');
385
+ }
386
+ };
387
+ // Initial render: print blank lines then render
388
+ for (let i = 0; i < items.length; i++) {
389
+ process.stdout.write(i < items.length - 1 ? '\n' : '');
390
+ }
391
+ render();
392
+ const cleanup = () => {
393
+ if (typeof stdin.setRawMode === 'function')
394
+ stdin.setRawMode(wasRaw ?? false);
395
+ stdin.removeListener('data', onData);
396
+ stdin.pause();
397
+ };
398
+ const onData = (key) => {
399
+ // Ctrl+C
400
+ if (key === '\x03') {
401
+ cleanup();
402
+ process.stdout.write('\n');
403
+ process.exit(1);
404
+ }
405
+ // Enter — confirm selection
406
+ if (key === '\r' || key === '\n') {
407
+ cleanup();
408
+ process.stdout.write('\n');
409
+ const selected = [];
410
+ for (let i = 0; i < items.length; i++) {
411
+ if (items[i].selected && items[i].available)
412
+ selected.push(i);
413
+ }
414
+ resolve(selected);
415
+ return;
416
+ }
417
+ // Space — toggle current item
418
+ if (key === ' ') {
419
+ if (items[cursor].available) {
420
+ items[cursor].selected = !items[cursor].selected;
421
+ render();
422
+ }
423
+ return;
424
+ }
425
+ // Arrow keys (escape sequences)
426
+ if (key === '\x1b[A' || key === 'k') {
427
+ // Up
428
+ let next = cursor - 1;
429
+ while (next >= 0 && !items[next].available)
430
+ next--;
431
+ if (next >= 0) {
432
+ cursor = next;
433
+ render();
434
+ }
435
+ return;
436
+ }
437
+ if (key === '\x1b[B' || key === 'j') {
438
+ // Down
439
+ let next = cursor + 1;
440
+ while (next < items.length && !items[next].available)
441
+ next++;
442
+ if (next < items.length) {
443
+ cursor = next;
444
+ render();
445
+ }
446
+ return;
447
+ }
448
+ // 'a' — select all available
449
+ if (key === 'a') {
450
+ const allSelected = items.filter((i) => i.available).every((i) => i.selected);
451
+ for (const item of items) {
452
+ if (item.available)
453
+ item.selected = !allSelected;
454
+ }
455
+ render();
456
+ return;
457
+ }
458
+ };
459
+ stdin.on('data', onData);
460
+ });
461
+ }
289
462
  /**
290
463
  * Verify token by hitting the engine /api/usage endpoint.
291
464
  * Returns tier info on success, null on failure.
@@ -522,93 +695,68 @@ export async function runSetup() {
522
695
  }
523
696
  console.log('');
524
697
  // ── Step 2: Detect clients ──────────────────────────────────────
525
- console.log('[2/4] Detecting Claude clients');
526
- const hasClaudeCode = isClaudeCLIAvailable();
527
- const hasDesktop = isClaudeDesktopInstalled();
528
- const desktopConfigPath = getDesktopConfigPath();
529
- const wantCode = !clientFilter || clientFilter === 'code';
530
- const wantDesktop = !clientFilter || clientFilter === 'desktop';
531
- if (hasClaudeCode && wantCode) {
532
- console.log(' Found: Claude Code (claude CLI)');
533
- }
534
- if (hasDesktop && wantDesktop) {
535
- console.log(` Found: Claude Desktop (${desktopConfigPath})`);
698
+ console.log('[2/4] Detecting clients');
699
+ // Filter registry if --client was passed
700
+ const clients = clientFilter
701
+ ? CLIENT_REGISTRY.filter((c) => c.id === clientFilter)
702
+ : CLIENT_REGISTRY;
703
+ const detected = clients.map((c) => ({
704
+ client: c,
705
+ available: c.detect(),
706
+ }));
707
+ const anyDetected = detected.some((d) => d.available);
708
+ for (const d of detected) {
709
+ if (d.available) {
710
+ console.log(` Found: ${d.client.name}`);
711
+ }
536
712
  }
537
- if (!hasClaudeCode && !hasDesktop) {
538
- console.log(' No Claude clients detected.');
713
+ if (!anyDetected) {
714
+ console.log(' No supported clients detected.');
539
715
  }
540
716
  console.log('');
541
717
  // ── Step 3: Configure clients ───────────────────────────────────
542
- console.log('[3/4] Client Configuration');
543
- let codeConfigured = false;
544
- let desktopConfigured = 'skipped';
545
- let neitherConfigured = true;
546
- // Claude Code
547
- if (hasClaudeCode && wantCode) {
548
- const rl = createRL();
549
- const answer = await ask(rl, ' Install for Claude Code? [Y/n] ');
550
- rl.close();
551
- if (answer.toLowerCase() !== 'n') {
552
- const success = registerClaudeCode(token);
553
- if (success) {
554
- codeConfigured = true;
555
- neitherConfigured = false;
556
- console.log(' Claude Code: Registered (user scope -- works in all projects)');
557
- }
558
- else {
559
- console.log(' Claude Code: Failed to register via CLI');
560
- }
561
- }
562
- else {
563
- console.log(' Claude Code: Skipped');
564
- }
565
- }
566
- else if (wantCode && !hasClaudeCode) {
567
- console.log(' Claude Code: CLI not found (install: https://docs.anthropic.com/en/docs/claude-code)');
568
- }
569
- // Claude Desktop / Co-Work
570
- if (hasDesktop && wantDesktop) {
571
- const rl = createRL();
572
- const answer = await ask(rl, ' Install for Claude Desktop / Co-Work? [Y/n] ');
573
- rl.close();
574
- if (answer.toLowerCase() !== 'n') {
575
- desktopConfigured = configureDesktop(token);
576
- switch (desktopConfigured) {
577
- case 'created':
578
- neitherConfigured = false;
579
- console.log(' Claude Desktop: Added RVRY to config');
580
- break;
581
- case 'updated':
582
- neitherConfigured = false;
583
- console.log(' Claude Desktop: Updated RVRY token in config');
584
- break;
585
- case 'unchanged':
586
- neitherConfigured = false;
587
- console.log(' Claude Desktop: Already configured with this token');
588
- break;
589
- case 'error':
590
- console.log(' Claude Desktop: Failed to write config (see error above)');
591
- break;
592
- }
593
- }
594
- else {
595
- console.log(' Claude Desktop: Skipped');
596
- }
718
+ console.log('[3/4] Select apps to add RVRY MCP configuration');
719
+ console.log(' Use \x1b[1m↑↓\x1b[0m to navigate, \x1b[1mspace\x1b[0m to toggle, \x1b[1ma\x1b[0m to toggle all, \x1b[1menter\x1b[0m to confirm');
720
+ console.log('');
721
+ const pickerItems = detected.map((d) => ({
722
+ label: d.client.name,
723
+ selected: d.available, // pre-select detected clients
724
+ available: d.available,
725
+ hint: d.available ? undefined : d.client.notInstalledHint,
726
+ }));
727
+ const selectedIndices = await multiSelect(pickerItems);
728
+ const configuredClients = [];
729
+ let anyConfigured = false;
730
+ console.log('');
731
+ for (const idx of selectedIndices) {
732
+ const { client } = detected[idx];
733
+ const result = client.configure(token);
734
+ const statusMap = {
735
+ ok: 'Configured',
736
+ updated: 'Updated token',
737
+ unchanged: 'Already configured',
738
+ error: 'Failed',
739
+ };
740
+ const status = statusMap[result] ?? result;
741
+ const icon = result === 'error' ? '✗' : '✓';
742
+ console.log(` ${icon} ${client.name}: ${status}`);
743
+ configuredClients.push({ name: client.name, status });
744
+ if (result !== 'error')
745
+ anyConfigured = true;
597
746
  }
598
- else if (wantDesktop && !hasDesktop) {
599
- console.log(' Claude Desktop: Not installed');
747
+ if (selectedIndices.length === 0) {
748
+ console.log(' No clients selected.');
600
749
  }
601
750
  // Fallback: print manual config if nothing was configured
602
- if (neitherConfigured) {
751
+ if (!anyConfigured) {
603
752
  console.log('');
604
753
  console.log(' Manual configuration:');
605
754
  console.log('');
606
755
  console.log(' Option A — Claude Code (if you install it later):');
607
756
  console.log(` claude mcp add -e RVRY_TOKEN="${token}" -s user rvry -- npx @rvry/mcp`);
608
757
  console.log('');
609
- console.log(' Option B — Claude Desktop config JSON:');
758
+ console.log(' Option B — JSON config (Claude Desktop, Codex, etc.):');
610
759
  const manualConfig = { mcpServers: { RVRY: RVRY_SERVER_ENTRY(token) } };
611
- console.log(` File: ${desktopConfigPath}`);
612
760
  console.log('');
613
761
  for (const line of JSON.stringify(manualConfig, null, 2).split('\n')) {
614
762
  console.log(` ${line}`);
@@ -631,35 +779,36 @@ export async function runSetup() {
631
779
  console.log('RVRY Setup Complete');
632
780
  console.log('');
633
781
  console.log(` Token: ${maskToken(token)}${usage ? ` (${usage.tier})` : ''}`);
634
- if (codeConfigured) {
635
- console.log(' Claude Code: Configured');
636
- }
637
- if (desktopConfigured !== 'skipped' && desktopConfigured !== 'error') {
638
- console.log(' Claude Desktop: Configured');
782
+ for (const c of configuredClients) {
783
+ const pad = ' '.repeat(Math.max(1, 16 - c.name.length));
784
+ console.log(` ${c.name}:${pad}${c.status}`);
639
785
  }
640
786
  console.log(` Commands: ${commandCount} installed`);
641
787
  console.log('');
642
788
  // Client-specific next steps
789
+ const configuredNames = new Set(configuredClients.map((c) => c.name));
790
+ const hasDesktopStyle = configuredNames.has('Claude Desktop / Claude Co-Work')
791
+ || configuredNames.has('Anti-Gravity');
792
+ const hasCodeStyle = configuredNames.has('Claude Code');
643
793
  console.log('Next steps:');
644
- const desktopOk = desktopConfigured !== 'skipped' && desktopConfigured !== 'error';
645
794
  let step = 1;
646
- if (desktopOk) {
647
- console.log(` ${step}. Restart Claude Desktop for the new MCP server to load`);
795
+ if (hasDesktopStyle) {
796
+ console.log(` ${step}. Restart desktop apps for the new MCP server to load`);
648
797
  step++;
649
798
  }
650
- if (codeConfigured) {
799
+ if (hasCodeStyle) {
651
800
  console.log(` ${step}. In Claude Code, try:`);
652
801
  console.log(' /deepthink "your question"');
653
802
  console.log(' /problem-solve "your decision"');
654
803
  step++;
655
804
  }
656
- if (desktopOk) {
657
- console.log(` ${step}. In Claude Desktop, use natural language:`);
805
+ if (hasDesktopStyle) {
806
+ console.log(` ${step}. In desktop clients, use natural language:`);
658
807
  console.log(' "Use deepthink to analyze..." or "Use problem-solve for..."');
659
808
  step++;
660
809
  }
661
- if (!codeConfigured && !desktopOk) {
662
- console.log(' 1. Configure a Claude client using the manual instructions above');
810
+ if (!anyConfigured) {
811
+ console.log(' 1. Configure a client using the manual instructions above');
663
812
  console.log(' 2. Then try: /deepthink "your question"');
664
813
  }
665
814
  console.log('');
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@rvry/mcp",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "RVRY reasoning depth enforcement (RDE) engine client.",
5
5
  "type": "module",
6
6
  "bin": {
7
- "rvry-mcp": "./dist/index.js"
7
+ "rvry-mcp": "dist/index.js"
8
8
  },
9
9
  "main": "./dist/index.js",
10
10
  "files": [