@tacitai/mcp-server 0.6.45 → 0.6.47
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.
- package/dist/cli.js +32 -10
- package/dist/setup.js +83 -34
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -8,7 +8,7 @@ import { deviceAuthFlow, loginFlow, deriveAppUrl, workspaceNameToProfile } from
|
|
|
8
8
|
const PROFILES_DIR = path.join(os.homedir(), '.tacit', 'profiles');
|
|
9
9
|
const DEFAULT_FILE = path.join(os.homedir(), '.tacit', 'default');
|
|
10
10
|
const PROFILE_REGEX = /^[a-z0-9][a-z0-9-]{0,63}$/;
|
|
11
|
-
const RESERVED_NAMES = new Set(['login', 'ls', 'use', 'rm', 'status', 'install', 'help', 'setup', 'version']);
|
|
11
|
+
const RESERVED_NAMES = new Set(['login', 'ls', 'use', 'rm', 'status', 'install', 'help', 'setup', 'version', 'launch']);
|
|
12
12
|
const DEFAULT_API_URL = 'https://api-beta.tacitai.app';
|
|
13
13
|
function listV2Profiles() {
|
|
14
14
|
if (!fs.existsSync(PROFILES_DIR))
|
|
@@ -128,7 +128,21 @@ async function cmdLaunch(name, extraArgs) {
|
|
|
128
128
|
process.stderr.write(`[TACIT] Token expires in ${daysLeft} day${daysLeft === 1 ? '' : 's'}.\n`);
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
|
-
|
|
131
|
+
// Parse --model from extraArgs; pass remaining args to claude
|
|
132
|
+
let model = null;
|
|
133
|
+
const claudeArgs = [];
|
|
134
|
+
for (let i = 0; i < extraArgs.length; i++) {
|
|
135
|
+
if ((extraArgs[i] === '--model' || extraArgs[i] === '-m') && extraArgs[i + 1]) {
|
|
136
|
+
model = extraArgs[++i];
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
claudeArgs.push(extraArgs[i]);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
if (model) {
|
|
143
|
+
claudeArgs.push('--model', model);
|
|
144
|
+
}
|
|
145
|
+
const child = spawn('claude', claudeArgs, {
|
|
132
146
|
stdio: 'inherit',
|
|
133
147
|
env: { ...process.env, TACIT_PROFILE: name },
|
|
134
148
|
});
|
|
@@ -420,6 +434,9 @@ async function main() {
|
|
|
420
434
|
const args = process.argv.slice(2);
|
|
421
435
|
const cmd = args[0] ?? '';
|
|
422
436
|
switch (cmd) {
|
|
437
|
+
case 'launch':
|
|
438
|
+
await cmdLaunch(args[1], args.slice(2));
|
|
439
|
+
break;
|
|
423
440
|
case 'login':
|
|
424
441
|
await cmdLogin(args.slice(1));
|
|
425
442
|
break;
|
|
@@ -445,14 +462,19 @@ async function main() {
|
|
|
445
462
|
'tacit — workspace launcher for Claude Code + TACIT',
|
|
446
463
|
'',
|
|
447
464
|
'Commands:',
|
|
448
|
-
' tacit
|
|
449
|
-
' tacit <name>
|
|
450
|
-
' tacit
|
|
451
|
-
' tacit
|
|
452
|
-
' tacit
|
|
453
|
-
' tacit
|
|
454
|
-
' tacit
|
|
455
|
-
' tacit
|
|
465
|
+
' tacit Interactive workspace picker',
|
|
466
|
+
' tacit <name> Launch Claude Code connected to <name>',
|
|
467
|
+
' tacit <name> --model opus Launch with a specific model',
|
|
468
|
+
' tacit launch <name> Same as tacit <name>',
|
|
469
|
+
' tacit login Authenticate and create a profile',
|
|
470
|
+
' tacit ls List workspace profiles',
|
|
471
|
+
' tacit use <name> Set the default profile',
|
|
472
|
+
' tacit rm <name> Remove a profile',
|
|
473
|
+
' tacit status Show connection info',
|
|
474
|
+
' tacit install Add generic entry to .mcp.json',
|
|
475
|
+
'',
|
|
476
|
+
'Options:',
|
|
477
|
+
' --model, -m <model> Claude model (opus, sonnet, haiku, etc.)',
|
|
456
478
|
'',
|
|
457
479
|
].join('\n'));
|
|
458
480
|
break;
|
package/dist/setup.js
CHANGED
|
@@ -537,9 +537,8 @@ export async function setup(argv) {
|
|
|
537
537
|
}
|
|
538
538
|
}
|
|
539
539
|
}
|
|
540
|
-
|
|
541
|
-
let
|
|
542
|
-
let workspaceDisplayName = '';
|
|
540
|
+
let allWorkspaces = [];
|
|
541
|
+
let activeWorkspaceId = '';
|
|
543
542
|
if (token) {
|
|
544
543
|
try {
|
|
545
544
|
const wsResp = await fetch(apiUrl.endsWith('/api/v1')
|
|
@@ -547,33 +546,53 @@ export async function setup(argv) {
|
|
|
547
546
|
: `${apiUrl}/api/v1/workspaces/mine`, { headers: { 'Authorization': `Bearer ${token}`, 'Accept': 'application/json' } });
|
|
548
547
|
if (wsResp.ok) {
|
|
549
548
|
const wsData = await wsResp.json();
|
|
550
|
-
|
|
549
|
+
activeWorkspaceId = typeof wsData['active_workspace_id'] === 'string' ? wsData['active_workspace_id'] : '';
|
|
551
550
|
if (Array.isArray(wsData['workspaces'])) {
|
|
552
|
-
const
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
551
|
+
for (const w of wsData['workspaces']) {
|
|
552
|
+
const wsId = typeof w['workspace_id'] === 'string' ? w['workspace_id']
|
|
553
|
+
: typeof w['id'] === 'string' ? w['id'] : '';
|
|
554
|
+
const wsName = typeof w['display_name'] === 'string' ? w['display_name']
|
|
555
|
+
: typeof w['name'] === 'string' ? w['name'] : '';
|
|
556
|
+
if (wsId && wsName) {
|
|
557
|
+
allWorkspaces.push({
|
|
558
|
+
id: wsId,
|
|
559
|
+
name: wsName,
|
|
560
|
+
profileName: workspaceNameToProfile(wsName),
|
|
561
|
+
});
|
|
562
|
+
}
|
|
557
563
|
}
|
|
558
564
|
}
|
|
559
|
-
if (!opts.profileExplicit && workspaceDisplayName) {
|
|
560
|
-
profile = workspaceNameToProfile(workspaceDisplayName);
|
|
561
|
-
}
|
|
562
565
|
}
|
|
563
566
|
}
|
|
564
|
-
catch { /* workspace resolution failed —
|
|
567
|
+
catch { /* workspace resolution failed — will fall back to single-profile mode */ }
|
|
568
|
+
}
|
|
569
|
+
// If explicit --profile was given, use only the active workspace with that name.
|
|
570
|
+
// Otherwise derive profile name per workspace.
|
|
571
|
+
const activeWs = allWorkspaces.find(w => w.id === activeWorkspaceId);
|
|
572
|
+
if (opts.profileExplicit) {
|
|
573
|
+
// Explicit profile: write one profile for the active workspace.
|
|
574
|
+
if (activeWs) {
|
|
575
|
+
allWorkspaces = [{ ...activeWs, profileName: profile }];
|
|
576
|
+
}
|
|
565
577
|
}
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
//
|
|
578
|
+
else if (activeWs) {
|
|
579
|
+
profile = activeWs.profileName;
|
|
580
|
+
}
|
|
581
|
+
// The MCP server is always registered as "tacit" — one generic server that
|
|
582
|
+
// resolves workspace identity via the profile system at runtime.
|
|
583
|
+
const mcpServerName = 'tacit';
|
|
570
584
|
const resolvedToken = token ?? null;
|
|
571
|
-
|
|
585
|
+
// Build the MCP server entry without embedding a token — the server resolves
|
|
586
|
+
// credentials from the default profile (~/.tacit/default → profile file).
|
|
587
|
+
const profileEntry = buildProfileEntry(apiUrl, 'TACIT_TOKEN', null);
|
|
588
|
+
// Remove the placeholder token — the server should resolve via profiles, not env vars.
|
|
589
|
+
// Keep TACIT_API_URL as a fallback hint.
|
|
590
|
+
delete profileEntry.env['TACIT_TOKEN'];
|
|
572
591
|
// D10: emit confirmation string BEFORE writing (also printed in dry-run).
|
|
573
|
-
process.stdout.write(`\n Registering MCP server "${
|
|
592
|
+
process.stdout.write(`\n Registering MCP server "${mcpServerName}" with Claude Code...\n`);
|
|
574
593
|
if (opts.dryRun) {
|
|
575
594
|
process.stdout.write(' (dry-run) Would register:\n');
|
|
576
|
-
const redactedEntry = buildProfileEntry(apiUrl,
|
|
595
|
+
const redactedEntry = buildProfileEntry(apiUrl, 'TACIT_TOKEN', null);
|
|
577
596
|
process.stdout.write(` ${JSON.stringify(redactedEntry, null, 2)}\n`);
|
|
578
597
|
process.exit(0);
|
|
579
598
|
return;
|
|
@@ -582,7 +601,7 @@ export async function setup(argv) {
|
|
|
582
601
|
// Writing ~/.claude/mcp.json directly does NOT work (Claude Code ignores that file).
|
|
583
602
|
const jsonConfig = JSON.stringify(profileEntry);
|
|
584
603
|
const registered = await new Promise((resolve) => {
|
|
585
|
-
execFile('claude', ['mcp', 'add-json', '--scope', 'user',
|
|
604
|
+
execFile('claude', ['mcp', 'add-json', '--scope', 'user', mcpServerName, jsonConfig], {
|
|
586
605
|
timeout: 15_000,
|
|
587
606
|
}, (err, stdout, stderr) => {
|
|
588
607
|
if (err) {
|
|
@@ -601,24 +620,47 @@ export async function setup(argv) {
|
|
|
601
620
|
fs.mkdirSync(dir, { recursive: true, mode: 0o700 });
|
|
602
621
|
}
|
|
603
622
|
const existing = readExistingConfig();
|
|
604
|
-
const merged = mergeConfig(existing,
|
|
623
|
+
const merged = mergeConfig(existing, mcpServerName, profileEntry);
|
|
605
624
|
const output = configToBytes(merged);
|
|
606
625
|
const dest = mcpJsonPath();
|
|
607
626
|
fs.writeFileSync(dest, output, { encoding: 'utf-8', mode: 0o600 });
|
|
608
627
|
fs.chmodSync(dest, 0o600);
|
|
609
|
-
// Write
|
|
610
|
-
|
|
628
|
+
// Write v2 profiles for ALL workspaces the user has access to.
|
|
629
|
+
const writtenProfiles = [];
|
|
630
|
+
if (resolvedToken && allWorkspaces.length > 0) {
|
|
631
|
+
for (const ws of allWorkspaces) {
|
|
632
|
+
writeV2Profile(ws.profileName, {
|
|
633
|
+
version: 2,
|
|
634
|
+
workspace_id: ws.id,
|
|
635
|
+
workspace_name: ws.name,
|
|
636
|
+
api_url: apiUrl,
|
|
637
|
+
app_url: deriveAppUrl(apiUrl),
|
|
638
|
+
token: resolvedToken,
|
|
639
|
+
created_at: new Date().toISOString(),
|
|
640
|
+
expires_at: expiresAt || undefined,
|
|
641
|
+
});
|
|
642
|
+
writtenProfiles.push(ws.profileName);
|
|
643
|
+
}
|
|
644
|
+
// Set the active workspace as default profile.
|
|
645
|
+
const defaultFile = path.join(os.homedir(), '.tacit', 'default');
|
|
646
|
+
const defaultProfile = activeWs ? activeWs.profileName : allWorkspaces[0].profileName;
|
|
647
|
+
const dir = path.dirname(defaultFile);
|
|
648
|
+
fs.mkdirSync(dir, { recursive: true, mode: 0o700 });
|
|
649
|
+
fs.writeFileSync(defaultFile, defaultProfile + '\n', { mode: 0o600 });
|
|
650
|
+
}
|
|
651
|
+
else if (resolvedToken) {
|
|
652
|
+
// Fallback: no workspace list available — write a single profile.
|
|
611
653
|
writeV2Profile(profile, {
|
|
612
654
|
version: 2,
|
|
613
|
-
workspace_id:
|
|
614
|
-
workspace_name:
|
|
655
|
+
workspace_id: '',
|
|
656
|
+
workspace_name: profile,
|
|
615
657
|
api_url: apiUrl,
|
|
616
658
|
app_url: deriveAppUrl(apiUrl),
|
|
617
659
|
token: resolvedToken,
|
|
618
660
|
created_at: new Date().toISOString(),
|
|
619
661
|
expires_at: expiresAt || undefined,
|
|
620
662
|
});
|
|
621
|
-
|
|
663
|
+
writtenProfiles.push(profile);
|
|
622
664
|
const defaultFile = path.join(os.homedir(), '.tacit', 'default');
|
|
623
665
|
if (!fs.existsSync(defaultFile)) {
|
|
624
666
|
const dir = path.dirname(defaultFile);
|
|
@@ -635,19 +677,26 @@ export async function setup(argv) {
|
|
|
635
677
|
else if (resolvedToken) {
|
|
636
678
|
process.stdout.write(`\n Config written to ~/.claude/mcp.json (fallback).\n` +
|
|
637
679
|
` If Claude Code doesn't pick it up, run:\n` +
|
|
638
|
-
` claude mcp add-json --scope user ${
|
|
680
|
+
` claude mcp add-json --scope user ${mcpServerName} '${jsonConfig}'\n` +
|
|
639
681
|
` Then start a new Claude Code session.\n`);
|
|
640
682
|
}
|
|
641
683
|
else {
|
|
642
684
|
process.stdout.write(`\n Setup complete. Add this to your shell profile:\n` +
|
|
643
|
-
` export
|
|
685
|
+
` export TACIT_TOKEN=<your-token>\n` +
|
|
644
686
|
`\n Then start a new Claude Code session to connect.\n`);
|
|
645
687
|
}
|
|
646
|
-
// Show
|
|
647
|
-
if (
|
|
648
|
-
process.stdout.write(`\n
|
|
649
|
-
|
|
650
|
-
|
|
688
|
+
// Show all profiles that were written.
|
|
689
|
+
if (writtenProfiles.length > 0) {
|
|
690
|
+
process.stdout.write(`\n Profiles saved:\n`);
|
|
691
|
+
for (const p of writtenProfiles) {
|
|
692
|
+
const isDefault = activeWs ? p === activeWs.profileName : p === writtenProfiles[0];
|
|
693
|
+
process.stdout.write(` ${isDefault ? '* ' : ' '}${p}\n`);
|
|
694
|
+
}
|
|
695
|
+
process.stdout.write(`\n Launch Claude Code with a workspace:\n` +
|
|
696
|
+
` tacit launch ${writtenProfiles[0]}` +
|
|
697
|
+
(writtenProfiles.length > 1 ? ` # or: tacit launch ${writtenProfiles[1]}` : '') +
|
|
698
|
+
`\n\n List profiles: tacit ls\n` +
|
|
699
|
+
` Set default: tacit use <name>\n`);
|
|
651
700
|
}
|
|
652
701
|
if (opts.smoke) {
|
|
653
702
|
await runSmoke(apiUrl, token);
|