@tacitai/mcp-server 0.6.42 → 0.6.43
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 +16 -0
- package/dist/client.js +3 -3
- package/dist/index.js +13 -0
- package/dist/setup.js +16 -3
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -66,6 +66,12 @@ function loadProfile(name) {
|
|
|
66
66
|
process.stderr.write(`Profile '${name}' was created by setup and lacks credentials. Re-run: npx -p @tacitai/mcp-server tacit login\n`);
|
|
67
67
|
process.exit(1);
|
|
68
68
|
}
|
|
69
|
+
for (const field of ['workspace_id', 'token', 'api_url']) {
|
|
70
|
+
if (!data[field] || typeof data[field] !== 'string') {
|
|
71
|
+
process.stderr.write(`Profile '${name}' is missing required field '${field}'. Re-run: npx -p @tacitai/mcp-server tacit login\n`);
|
|
72
|
+
process.exit(1);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
69
75
|
return data;
|
|
70
76
|
}
|
|
71
77
|
function writeProfile(name, data) {
|
|
@@ -98,6 +104,10 @@ function tryLoadProfile(name) {
|
|
|
98
104
|
const data = JSON.parse(fs.readFileSync(filePath, 'utf-8'));
|
|
99
105
|
if (data.version !== 2)
|
|
100
106
|
return null;
|
|
107
|
+
for (const field of ['workspace_id', 'token', 'api_url']) {
|
|
108
|
+
if (!data[field] || typeof data[field] !== 'string')
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
101
111
|
return data;
|
|
102
112
|
}
|
|
103
113
|
catch {
|
|
@@ -329,6 +339,12 @@ function cmdStatus() {
|
|
|
329
339
|
else if (wsId && token) {
|
|
330
340
|
process.stdout.write('\nResolved via env vars (TACIT_WORKSPACE_ID + TACIT_TOKEN)\n');
|
|
331
341
|
}
|
|
342
|
+
else if (token && !wsId) {
|
|
343
|
+
process.stdout.write('\nTACIT_TOKEN is set but TACIT_WORKSPACE_ID is missing — workspace cannot be resolved.\n');
|
|
344
|
+
}
|
|
345
|
+
else if (wsId && !token) {
|
|
346
|
+
process.stdout.write('\nTACIT_WORKSPACE_ID is set but TACIT_TOKEN is missing — authentication will fail.\n');
|
|
347
|
+
}
|
|
332
348
|
else if (defaultName) {
|
|
333
349
|
const p = tryLoadProfile(defaultName);
|
|
334
350
|
if (p) {
|
package/dist/client.js
CHANGED
|
@@ -475,13 +475,13 @@ export function loadProfile(name) {
|
|
|
475
475
|
* Throws on set-but-invalid states (profile missing, WORKSPACE_ID without TOKEN).
|
|
476
476
|
*/
|
|
477
477
|
export function resolveProfileOptions() {
|
|
478
|
-
// Level 1: TACIT_PROFILE env → load profile
|
|
478
|
+
// Level 1: TACIT_PROFILE env → load profile (profile values take precedence over stray env vars)
|
|
479
479
|
const profileName = process.env['TACIT_PROFILE'];
|
|
480
480
|
if (isNonEmpty(profileName)) {
|
|
481
481
|
const profile = loadProfile(profileName);
|
|
482
482
|
return {
|
|
483
|
-
apiUrl:
|
|
484
|
-
appUrl:
|
|
483
|
+
apiUrl: profile.api_url,
|
|
484
|
+
appUrl: profile.app_url,
|
|
485
485
|
token: profile.token,
|
|
486
486
|
workspaceId: profile.workspace_id,
|
|
487
487
|
};
|
package/dist/index.js
CHANGED
|
@@ -229,6 +229,8 @@ function parseProfile(argv) {
|
|
|
229
229
|
return 'tacit';
|
|
230
230
|
}
|
|
231
231
|
function checkProfileExpiry(profile) {
|
|
232
|
+
if (!/^[a-z0-9][a-z0-9-]{0,63}$/.test(profile))
|
|
233
|
+
return;
|
|
232
234
|
const metaPath = path.join(os.homedir(), '.tacit', 'profiles', `${profile}.json`);
|
|
233
235
|
if (!fs.existsSync(metaPath)) {
|
|
234
236
|
return;
|
|
@@ -316,6 +318,17 @@ async function run() {
|
|
|
316
318
|
if (!isHttpMode) {
|
|
317
319
|
try {
|
|
318
320
|
profileOpts = resolveProfileOptions();
|
|
321
|
+
// Propagate profile credentials to process.env so the module-level getClient()
|
|
322
|
+
// singleton (used by ~107 tool call sites) picks up the correct identity.
|
|
323
|
+
// Without this, tools would use stale env vars from the parent shell.
|
|
324
|
+
if (profileOpts) {
|
|
325
|
+
if (profileOpts.apiUrl)
|
|
326
|
+
process.env['TACIT_API_URL'] = profileOpts.apiUrl;
|
|
327
|
+
if (profileOpts.token)
|
|
328
|
+
process.env['TACIT_TOKEN'] = profileOpts.token;
|
|
329
|
+
if (profileOpts.workspaceId)
|
|
330
|
+
process.env['TACIT_WORKSPACE_ID'] = profileOpts.workspaceId;
|
|
331
|
+
}
|
|
319
332
|
}
|
|
320
333
|
catch (err) {
|
|
321
334
|
const msg = err instanceof Error ? err.message : String(err);
|
package/dist/setup.js
CHANGED
|
@@ -76,6 +76,10 @@ function parseArgs(argv) {
|
|
|
76
76
|
process.stderr.write('Error: --profile requires a value\n');
|
|
77
77
|
process.exit(1);
|
|
78
78
|
}
|
|
79
|
+
if (!/^[a-z0-9][a-z0-9-]{0,63}$/.test(next)) {
|
|
80
|
+
process.stderr.write(`Error: invalid profile name '${next}'. Names must be lowercase alphanumeric with hyphens.\n`);
|
|
81
|
+
process.exit(1);
|
|
82
|
+
}
|
|
79
83
|
opts.profile = next;
|
|
80
84
|
opts.profileExplicit = true;
|
|
81
85
|
i++;
|
|
@@ -106,7 +110,10 @@ export function profileToEnvVar(profile) {
|
|
|
106
110
|
* AC-12: lowercased, spaces→hyphens, non-alphanumeric-hyphen stripped.
|
|
107
111
|
*/
|
|
108
112
|
export function workspaceNameToProfile(name) {
|
|
109
|
-
|
|
113
|
+
const slug = name.toLowerCase().replace(/\s+/g, '-').replace(/[^a-z0-9-]/g, '').replace(/^-+/, '');
|
|
114
|
+
if (!slug || !/^[a-z0-9]/.test(slug))
|
|
115
|
+
return 'workspace';
|
|
116
|
+
return slug.slice(0, 64);
|
|
110
117
|
}
|
|
111
118
|
function claudeDir() {
|
|
112
119
|
return path.join(os.homedir(), '.claude');
|
|
@@ -188,6 +195,10 @@ function configToBytes(cfg) {
|
|
|
188
195
|
* Token plaintext is NEVER written here — metadata only.
|
|
189
196
|
*/
|
|
190
197
|
export function writeProfileMetadata(profile, expiresAt, apiUrl) {
|
|
198
|
+
if (!/^[a-z0-9][a-z0-9-]{0,63}$/.test(profile)) {
|
|
199
|
+
process.stderr.write(`[TACIT] Invalid profile name '${profile}' — skipping metadata write.\n`);
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
191
202
|
const metaDir = path.join(os.homedir(), '.tacit', 'profiles');
|
|
192
203
|
fs.mkdirSync(metaDir, { recursive: true, mode: 0o700 });
|
|
193
204
|
try {
|
|
@@ -195,12 +206,14 @@ export function writeProfileMetadata(profile, expiresAt, apiUrl) {
|
|
|
195
206
|
}
|
|
196
207
|
catch { /* unsupported OS */ }
|
|
197
208
|
const filePath = path.join(metaDir, `${profile}.json`);
|
|
198
|
-
// v2 non-clobber: if a login profile exists,
|
|
209
|
+
// v2 non-clobber: if a login profile exists, update expires_at and api_url in place
|
|
199
210
|
if (fs.existsSync(filePath)) {
|
|
200
211
|
try {
|
|
201
212
|
const existing = JSON.parse(fs.readFileSync(filePath, 'utf-8'));
|
|
202
213
|
if (existing.version === 2) {
|
|
203
|
-
|
|
214
|
+
existing.expires_at = expiresAt;
|
|
215
|
+
existing.api_url = apiUrl;
|
|
216
|
+
fs.writeFileSync(filePath, JSON.stringify(existing, null, 2), { mode: 0o600 });
|
|
204
217
|
return;
|
|
205
218
|
}
|
|
206
219
|
}
|