@tacitai/mcp-server 0.6.47 → 0.6.48

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 CHANGED
@@ -3,7 +3,7 @@ import * as fs from 'fs';
3
3
  import * as path from 'path';
4
4
  import * as os from 'os';
5
5
  import * as readline from 'readline';
6
- import { spawn } from 'child_process';
6
+ import { spawn, execFile } from 'child_process';
7
7
  import { deviceAuthFlow, loginFlow, deriveAppUrl, workspaceNameToProfile } from './setup.js';
8
8
  const PROFILES_DIR = path.join(os.homedir(), '.tacit', 'profiles');
9
9
  const DEFAULT_FILE = path.join(os.homedir(), '.tacit', 'default');
@@ -115,6 +115,31 @@ function tryLoadProfile(name) {
115
115
  }
116
116
  }
117
117
  // ─── Subcommands ─────────────────────────────────────────────────────────────
118
+ const PROFILE_PASSTHROUGH = '${TACIT_PROFILE}';
119
+ // Idempotent: older setups lack TACIT_PROFILE in the MCP env, so the spawned MCP server never sees the profile.
120
+ function migrateMcpProfilePassthrough() {
121
+ try {
122
+ const mcpPath = path.join(os.homedir(), '.claude', 'mcp.json');
123
+ if (!fs.existsSync(mcpPath))
124
+ return;
125
+ const config = JSON.parse(fs.readFileSync(mcpPath, 'utf-8'));
126
+ const entry = config.mcpServers?.['tacit'];
127
+ if (!entry || typeof entry !== 'object')
128
+ return;
129
+ const env = entry.env ?? {};
130
+ if ('TACIT_PROFILE' in env)
131
+ return;
132
+ entry.env = { ...env, TACIT_PROFILE: PROFILE_PASSTHROUGH };
133
+ const tmp = mcpPath + '.tmp';
134
+ fs.writeFileSync(tmp, JSON.stringify(config, null, 2) + '\n', { mode: 0o600 });
135
+ fs.renameSync(tmp, mcpPath);
136
+ // Skip add-json when a literal token is embedded: argv is visible to other local users via ps.
137
+ if (typeof env['TACIT_TOKEN'] === 'string' && env['TACIT_TOKEN'].startsWith('${')) {
138
+ execFile('claude', ['mcp', 'add-json', '--scope', 'user', 'tacit', JSON.stringify(entry)], () => { });
139
+ }
140
+ }
141
+ catch { /* best-effort migration */ }
142
+ }
118
143
  async function cmdLaunch(name, extraArgs) {
119
144
  const profile = loadProfile(name);
120
145
  if (profile.expires_at) {
@@ -142,6 +167,7 @@ async function cmdLaunch(name, extraArgs) {
142
167
  if (model) {
143
168
  claudeArgs.push('--model', model);
144
169
  }
170
+ migrateMcpProfilePassthrough();
145
171
  const child = spawn('claude', claudeArgs, {
146
172
  stdio: 'inherit',
147
173
  env: { ...process.env, TACIT_PROFILE: name },
package/dist/client.js CHANGED
@@ -477,7 +477,7 @@ export function loadProfile(name) {
477
477
  export function resolveProfileOptions() {
478
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
- if (isNonEmpty(profileName)) {
480
+ if (isNonEmpty(profileName) && !profileName.includes('${')) {
481
481
  const profile = loadProfile(profileName);
482
482
  return {
483
483
  apiUrl: profile.api_url,
package/dist/setup.js CHANGED
@@ -169,6 +169,7 @@ function buildProfileEntry(apiUrl, envVarName, token) {
169
169
  TACIT_TOKEN: token ?? `\${${envVarName}}`,
170
170
  TACIT_API_URL: apiUrl,
171
171
  TACIT_APP_URL: deriveAppUrl(apiUrl),
172
+ TACIT_PROFILE: '${TACIT_PROFILE}',
172
173
  },
173
174
  };
174
175
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tacitai/mcp-server",
3
- "version": "0.6.47",
3
+ "version": "0.6.48",
4
4
  "description": "stdio MCP server wrapping Tacit /api/v1 REST/SSE API",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {