@tempo-ai/mcp 0.0.113-staging.3 → 0.0.113
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/README.md +8 -5
- package/dist/bin.js +2 -2
- package/dist/{call-ZENVEMBV.js → call-WAGXDIIR.js} +3 -3
- package/dist/{chunk-3J3V3CVG.js → chunk-2P3T5CJG.js} +251 -132
- package/dist/chunk-2P3T5CJG.js.map +1 -0
- package/dist/{chunk-IC3SRTRB.js → chunk-GWZ4IVKA.js} +31 -62
- package/dist/chunk-GWZ4IVKA.js.map +1 -0
- package/dist/index.d.ts +5 -2
- package/dist/index.js +2 -2
- package/dist/{serve-B3XMDJMJ.js → serve-YVFHBEFM.js} +753 -317
- package/dist/serve-YVFHBEFM.js.map +1 -0
- package/dist/{token-BH4Z4COI.js → token-QSGSKGO3.js} +3 -3
- package/dist/token-QSGSKGO3.js.map +1 -0
- package/package.json +1 -1
- package/dist/chunk-3J3V3CVG.js.map +0 -1
- package/dist/chunk-IC3SRTRB.js.map +0 -1
- package/dist/serve-B3XMDJMJ.js.map +0 -1
- package/dist/token-BH4Z4COI.js.map +0 -1
- /package/dist/{call-ZENVEMBV.js.map → call-WAGXDIIR.js.map} +0 -0
package/README.md
CHANGED
|
@@ -30,7 +30,7 @@ preview capture, plus `canvas_verify_vrt` for VRT stability checks.
|
|
|
30
30
|
|
|
31
31
|
### Install
|
|
32
32
|
|
|
33
|
-
Claude Code:
|
|
33
|
+
One command, no account needed first. Claude Code:
|
|
34
34
|
|
|
35
35
|
```bash
|
|
36
36
|
claude mcp add tempo -- npx -y @tempo-ai/mcp
|
|
@@ -50,11 +50,14 @@ Cursor / generic JSON config:
|
|
|
50
50
|
{ "tempo": { "command": "npx", "args": ["-y", "@tempo-ai/mcp"] } }
|
|
51
51
|
```
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
Then just use a Tempo tool ("list my Tempo issues"). The first one that
|
|
54
|
+
needs your account opens the browser to sign in — or sign up, which walks
|
|
55
|
+
you through creating your organization — and the tool continues once
|
|
56
|
+
you're back. No login command, no restart. Later sessions connect
|
|
57
|
+
silently; if your session ever expires, the next tool call prompts again.
|
|
54
58
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
```
|
|
59
|
+
Optional: sign in ahead of time with `npx -y @tempo-ai/mcp login`, or set
|
|
60
|
+
`TEMPO_AUTH_TOKEN` where no browser exists (see the install guide).
|
|
58
61
|
|
|
59
62
|
### Flags
|
|
60
63
|
|
package/dist/bin.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import { createRequire as __tempoCreateRequire } from 'node:module'; const require = __tempoCreateRequire(import.meta.url);
|
|
3
3
|
import {
|
|
4
4
|
run
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-GWZ4IVKA.js";
|
|
6
|
+
import "./chunk-2P3T5CJG.js";
|
|
7
7
|
import "./chunk-WRI3HTCJ.js";
|
|
8
8
|
|
|
9
9
|
// src/bin.ts
|
|
@@ -2,14 +2,14 @@ import { createRequire as __tempoCreateRequire } from 'node:module'; const requi
|
|
|
2
2
|
import {
|
|
3
3
|
ensureCliAuth,
|
|
4
4
|
parseServeArgs
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-2P3T5CJG.js";
|
|
6
6
|
import "./chunk-WRI3HTCJ.js";
|
|
7
7
|
|
|
8
8
|
// src/call.ts
|
|
9
9
|
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
10
10
|
import { InMemoryTransport } from "@modelcontextprotocol/sdk/inMemory.js";
|
|
11
11
|
async function connectAggregate(options) {
|
|
12
|
-
const { createTempoAggregate } = await import("./serve-
|
|
12
|
+
const { createTempoAggregate } = await import("./serve-YVFHBEFM.js");
|
|
13
13
|
const handle = await createTempoAggregate(options, { stageDocuments: false });
|
|
14
14
|
const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();
|
|
15
15
|
const client = new Client({ name: "tempo-mcp-cli", version: "0" });
|
|
@@ -128,4 +128,4 @@ export {
|
|
|
128
128
|
runCall,
|
|
129
129
|
runTools
|
|
130
130
|
};
|
|
131
|
-
//# sourceMappingURL=call-
|
|
131
|
+
//# sourceMappingURL=call-WAGXDIIR.js.map
|
|
@@ -182,7 +182,7 @@ function createAuthProvider(refreshLoop) {
|
|
|
182
182
|
const auth = await readAuth();
|
|
183
183
|
if (!auth) {
|
|
184
184
|
throw new Error(
|
|
185
|
-
"Not
|
|
185
|
+
"Not signed in to Tempo. Retry the tool to get a sign-in link, or run `npx -y @tempo-ai/mcp login`."
|
|
186
186
|
);
|
|
187
187
|
}
|
|
188
188
|
if (auth.expiresAt - Date.now() < 3e4) {
|
|
@@ -194,7 +194,7 @@ function createAuthProvider(refreshLoop) {
|
|
|
194
194
|
}
|
|
195
195
|
}
|
|
196
196
|
throw new Error(
|
|
197
|
-
"Tempo session expired.
|
|
197
|
+
"Tempo session expired. Retry the tool to get a sign-in link, or run `npx -y @tempo-ai/mcp login`."
|
|
198
198
|
);
|
|
199
199
|
}
|
|
200
200
|
return { jwt: auth.token, expiresAt: auth.expiresAt };
|
|
@@ -202,98 +202,6 @@ function createAuthProvider(refreshLoop) {
|
|
|
202
202
|
};
|
|
203
203
|
}
|
|
204
204
|
|
|
205
|
-
// ../mcp-runtime/auth/token-exchange.ts
|
|
206
|
-
import { createHash } from "crypto";
|
|
207
|
-
var ENV_TOKEN_VAR = "TEMPO_AUTH_TOKEN";
|
|
208
|
-
function envAccessToken() {
|
|
209
|
-
const raw = process.env[ENV_TOKEN_VAR]?.trim();
|
|
210
|
-
return raw ? raw : null;
|
|
211
|
-
}
|
|
212
|
-
function accessTokenFingerprint(accessToken) {
|
|
213
|
-
return createHash("sha256").update(accessToken).digest("hex").slice(0, 16);
|
|
214
|
-
}
|
|
215
|
-
function storedAuthMatchesAccessToken(stored, accessToken) {
|
|
216
|
-
return stored.accessTokenFingerprint === accessTokenFingerprint(accessToken);
|
|
217
|
-
}
|
|
218
|
-
var TokenExchangeError = class extends Error {
|
|
219
|
-
constructor(message, kind) {
|
|
220
|
-
super(message);
|
|
221
|
-
this.kind = kind;
|
|
222
|
-
this.name = "TokenExchangeError";
|
|
223
|
-
}
|
|
224
|
-
};
|
|
225
|
-
async function exchangeAccessToken(opts) {
|
|
226
|
-
const maxRetries = opts.maxRetries ?? 2;
|
|
227
|
-
const retryDelay = opts.retryDelayMs ?? 2e3;
|
|
228
|
-
let lastTransient = "exchange failed";
|
|
229
|
-
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
230
|
-
let res;
|
|
231
|
-
try {
|
|
232
|
-
res = await fetch(`${opts.convexSiteUrl}/auth/token-exchange`, {
|
|
233
|
-
method: "POST",
|
|
234
|
-
headers: { "Content-Type": "application/json" },
|
|
235
|
-
body: JSON.stringify({ token: opts.accessToken })
|
|
236
|
-
});
|
|
237
|
-
} catch (err) {
|
|
238
|
-
lastTransient = err instanceof Error ? err.message : String(err);
|
|
239
|
-
if (attempt < maxRetries) {
|
|
240
|
-
await sleep2(retryDelay * Math.pow(1.5, attempt));
|
|
241
|
-
continue;
|
|
242
|
-
}
|
|
243
|
-
break;
|
|
244
|
-
}
|
|
245
|
-
if (res.status === 401) {
|
|
246
|
-
throw new TokenExchangeError(
|
|
247
|
-
`${ENV_TOKEN_VAR} was rejected (revoked or invalid). Mint a new token with \`tempo-mcp token create\` on a signed-in machine.`,
|
|
248
|
-
"invalid_token"
|
|
249
|
-
);
|
|
250
|
-
}
|
|
251
|
-
if (!res.ok) {
|
|
252
|
-
lastTransient = `token exchange returned ${res.status}`;
|
|
253
|
-
if (attempt < maxRetries) {
|
|
254
|
-
await sleep2(retryDelay * Math.pow(1.5, attempt));
|
|
255
|
-
continue;
|
|
256
|
-
}
|
|
257
|
-
break;
|
|
258
|
-
}
|
|
259
|
-
const body = await res.json();
|
|
260
|
-
if (!body.token || !body.sessionId || !body.userId) {
|
|
261
|
-
throw new TokenExchangeError(
|
|
262
|
-
"token exchange returned an incomplete payload",
|
|
263
|
-
"transient"
|
|
264
|
-
);
|
|
265
|
-
}
|
|
266
|
-
const stored = {
|
|
267
|
-
token: body.token,
|
|
268
|
-
sessionId: body.sessionId,
|
|
269
|
-
userId: body.userId,
|
|
270
|
-
email: decodeJwtEmail(body.token),
|
|
271
|
-
expiresAt: decodeJwtExp(body.token),
|
|
272
|
-
accessTokenFingerprint: accessTokenFingerprint(opts.accessToken)
|
|
273
|
-
};
|
|
274
|
-
await writeAuth(stored);
|
|
275
|
-
return stored;
|
|
276
|
-
}
|
|
277
|
-
throw new TokenExchangeError(
|
|
278
|
-
`Tempo token exchange failed: ${lastTransient}`,
|
|
279
|
-
"transient"
|
|
280
|
-
);
|
|
281
|
-
}
|
|
282
|
-
function decodeJwtEmail(jwt) {
|
|
283
|
-
try {
|
|
284
|
-
const [, payload] = jwt.split(".");
|
|
285
|
-
const decoded = JSON.parse(
|
|
286
|
-
Buffer.from(payload, "base64").toString("utf8")
|
|
287
|
-
);
|
|
288
|
-
return typeof decoded.email === "string" ? decoded.email : void 0;
|
|
289
|
-
} catch {
|
|
290
|
-
return void 0;
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
function sleep2(ms) {
|
|
294
|
-
return new Promise((r) => setTimeout(r, ms));
|
|
295
|
-
}
|
|
296
|
-
|
|
297
205
|
// ../mcp-runtime/auth/browser-flow.ts
|
|
298
206
|
import http from "http";
|
|
299
207
|
async function startBrowserAuthFlow(opts = {}) {
|
|
@@ -363,13 +271,15 @@ async function startBrowserAuthFlow(opts = {}) {
|
|
|
363
271
|
}
|
|
364
272
|
const callbackPort = address.port;
|
|
365
273
|
const signInUrl = `${authUrl}/sign-in?callbackPort=${callbackPort}&flow=mcp`;
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
274
|
+
if (Number.isFinite(timeoutMs)) {
|
|
275
|
+
const timeoutTimer = setTimeout(() => {
|
|
276
|
+
server.close();
|
|
277
|
+
rejectDone(new Error(`Sign-in timeout after ${timeoutMs}ms`));
|
|
278
|
+
}, timeoutMs);
|
|
279
|
+
if (typeof timeoutTimer.unref === "function") timeoutTimer.unref();
|
|
280
|
+
done.finally(() => clearTimeout(timeoutTimer)).catch(() => {
|
|
281
|
+
});
|
|
282
|
+
}
|
|
373
283
|
return {
|
|
374
284
|
signInUrl,
|
|
375
285
|
callbackPort,
|
|
@@ -403,6 +313,171 @@ function readJson(req) {
|
|
|
403
313
|
});
|
|
404
314
|
}
|
|
405
315
|
|
|
316
|
+
// ../mcp-runtime/auth/open-browser.ts
|
|
317
|
+
import { exec } from "child_process";
|
|
318
|
+
import { promisify } from "util";
|
|
319
|
+
var execAsync = promisify(exec);
|
|
320
|
+
function browserLaunchSuppressed() {
|
|
321
|
+
return process.env.TEMPO_MCP_NO_BROWSER === "1";
|
|
322
|
+
}
|
|
323
|
+
async function openInBrowser(url) {
|
|
324
|
+
if (browserLaunchSuppressed()) return false;
|
|
325
|
+
const cmd = process.platform === "darwin" ? `open "${url}"` : process.platform === "win32" ? `start "" "${url}"` : `xdg-open "${url}"`;
|
|
326
|
+
try {
|
|
327
|
+
await execAsync(cmd, { windowsHide: true });
|
|
328
|
+
return true;
|
|
329
|
+
} catch {
|
|
330
|
+
return false;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
// ../mcp-runtime/auth/sign-in-prompt.ts
|
|
335
|
+
function createSignInPrompt(options = {}) {
|
|
336
|
+
const openBrowser = options.openBrowser ?? openInBrowser;
|
|
337
|
+
let current = null;
|
|
338
|
+
const currentOrFresh = () => {
|
|
339
|
+
if (!current || current.spent) {
|
|
340
|
+
const flow = {
|
|
341
|
+
handle: startBrowserAuthFlow({
|
|
342
|
+
authUrl: options.authUrl,
|
|
343
|
+
timeoutMs: Infinity
|
|
344
|
+
}),
|
|
345
|
+
browserOpened: null,
|
|
346
|
+
spent: false
|
|
347
|
+
};
|
|
348
|
+
flow.handle.then((handle) => handle.done).catch(() => {
|
|
349
|
+
}).finally(() => {
|
|
350
|
+
flow.spent = true;
|
|
351
|
+
});
|
|
352
|
+
current = flow;
|
|
353
|
+
}
|
|
354
|
+
return current;
|
|
355
|
+
};
|
|
356
|
+
return {
|
|
357
|
+
async ensure(waitMs) {
|
|
358
|
+
for (; ; ) {
|
|
359
|
+
if (await readAuth()) return "signed_in";
|
|
360
|
+
const flow = currentOrFresh();
|
|
361
|
+
const handle = await flow.handle;
|
|
362
|
+
if (!flow.browserOpened) flow.browserOpened = openBrowser(handle.signInUrl);
|
|
363
|
+
const opened = await flow.browserOpened;
|
|
364
|
+
const landed = await Promise.race([
|
|
365
|
+
handle.done.then(
|
|
366
|
+
() => true,
|
|
367
|
+
() => false
|
|
368
|
+
),
|
|
369
|
+
sleep2(waitMs).then(() => false)
|
|
370
|
+
]);
|
|
371
|
+
if (!landed) return { signInUrl: handle.signInUrl, browserOpened: opened };
|
|
372
|
+
flow.spent = true;
|
|
373
|
+
}
|
|
374
|
+
},
|
|
375
|
+
dispose() {
|
|
376
|
+
if (!current || current.spent) return;
|
|
377
|
+
void current.handle.then((handle) => handle.cancel()).catch(() => {
|
|
378
|
+
});
|
|
379
|
+
}
|
|
380
|
+
};
|
|
381
|
+
}
|
|
382
|
+
function sleep2(ms) {
|
|
383
|
+
return new Promise((resolve) => {
|
|
384
|
+
const timer = setTimeout(resolve, ms);
|
|
385
|
+
if (typeof timer.unref === "function") timer.unref();
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
// ../mcp-runtime/auth/token-exchange.ts
|
|
390
|
+
import { createHash } from "crypto";
|
|
391
|
+
var ENV_TOKEN_VAR = "TEMPO_AUTH_TOKEN";
|
|
392
|
+
function envAccessToken() {
|
|
393
|
+
const raw = process.env[ENV_TOKEN_VAR]?.trim();
|
|
394
|
+
return raw ? raw : null;
|
|
395
|
+
}
|
|
396
|
+
function accessTokenFingerprint(accessToken) {
|
|
397
|
+
return createHash("sha256").update(accessToken).digest("hex").slice(0, 16);
|
|
398
|
+
}
|
|
399
|
+
function storedAuthMatchesAccessToken(stored, accessToken) {
|
|
400
|
+
return stored.accessTokenFingerprint === accessTokenFingerprint(accessToken);
|
|
401
|
+
}
|
|
402
|
+
var TokenExchangeError = class extends Error {
|
|
403
|
+
constructor(message, kind) {
|
|
404
|
+
super(message);
|
|
405
|
+
this.kind = kind;
|
|
406
|
+
this.name = "TokenExchangeError";
|
|
407
|
+
}
|
|
408
|
+
};
|
|
409
|
+
async function exchangeAccessToken(opts) {
|
|
410
|
+
const maxRetries = opts.maxRetries ?? 2;
|
|
411
|
+
const retryDelay = opts.retryDelayMs ?? 2e3;
|
|
412
|
+
let lastTransient = "exchange failed";
|
|
413
|
+
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
414
|
+
let res;
|
|
415
|
+
try {
|
|
416
|
+
res = await fetch(`${opts.convexSiteUrl}/auth/token-exchange`, {
|
|
417
|
+
method: "POST",
|
|
418
|
+
headers: { "Content-Type": "application/json" },
|
|
419
|
+
body: JSON.stringify({ token: opts.accessToken })
|
|
420
|
+
});
|
|
421
|
+
} catch (err) {
|
|
422
|
+
lastTransient = err instanceof Error ? err.message : String(err);
|
|
423
|
+
if (attempt < maxRetries) {
|
|
424
|
+
await sleep3(retryDelay * Math.pow(1.5, attempt));
|
|
425
|
+
continue;
|
|
426
|
+
}
|
|
427
|
+
break;
|
|
428
|
+
}
|
|
429
|
+
if (res.status === 401) {
|
|
430
|
+
throw new TokenExchangeError(
|
|
431
|
+
`${ENV_TOKEN_VAR} was rejected (revoked or invalid). Mint a new token with \`tempo-mcp token create\` on a signed-in machine.`,
|
|
432
|
+
"invalid_token"
|
|
433
|
+
);
|
|
434
|
+
}
|
|
435
|
+
if (!res.ok) {
|
|
436
|
+
lastTransient = `token exchange returned ${res.status}`;
|
|
437
|
+
if (attempt < maxRetries) {
|
|
438
|
+
await sleep3(retryDelay * Math.pow(1.5, attempt));
|
|
439
|
+
continue;
|
|
440
|
+
}
|
|
441
|
+
break;
|
|
442
|
+
}
|
|
443
|
+
const body = await res.json();
|
|
444
|
+
if (!body.token || !body.sessionId || !body.userId) {
|
|
445
|
+
throw new TokenExchangeError(
|
|
446
|
+
"token exchange returned an incomplete payload",
|
|
447
|
+
"transient"
|
|
448
|
+
);
|
|
449
|
+
}
|
|
450
|
+
const stored = {
|
|
451
|
+
token: body.token,
|
|
452
|
+
sessionId: body.sessionId,
|
|
453
|
+
userId: body.userId,
|
|
454
|
+
email: decodeJwtEmail(body.token),
|
|
455
|
+
expiresAt: decodeJwtExp(body.token),
|
|
456
|
+
accessTokenFingerprint: accessTokenFingerprint(opts.accessToken)
|
|
457
|
+
};
|
|
458
|
+
await writeAuth(stored);
|
|
459
|
+
return stored;
|
|
460
|
+
}
|
|
461
|
+
throw new TokenExchangeError(
|
|
462
|
+
`Tempo token exchange failed: ${lastTransient}`,
|
|
463
|
+
"transient"
|
|
464
|
+
);
|
|
465
|
+
}
|
|
466
|
+
function decodeJwtEmail(jwt) {
|
|
467
|
+
try {
|
|
468
|
+
const [, payload] = jwt.split(".");
|
|
469
|
+
const decoded = JSON.parse(
|
|
470
|
+
Buffer.from(payload, "base64").toString("utf8")
|
|
471
|
+
);
|
|
472
|
+
return typeof decoded.email === "string" ? decoded.email : void 0;
|
|
473
|
+
} catch {
|
|
474
|
+
return void 0;
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
function sleep3(ms) {
|
|
478
|
+
return new Promise((r) => setTimeout(r, ms));
|
|
479
|
+
}
|
|
480
|
+
|
|
406
481
|
// ../mcp-runtime/aggregate/aggregator.ts
|
|
407
482
|
import { randomUUID } from "crypto";
|
|
408
483
|
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
@@ -423,7 +498,8 @@ async function createAggregateServer(options) {
|
|
|
423
498
|
backends,
|
|
424
499
|
filterTool,
|
|
425
500
|
injectParams,
|
|
426
|
-
onScopedCall
|
|
501
|
+
onScopedCall,
|
|
502
|
+
gateCall
|
|
427
503
|
} = options;
|
|
428
504
|
const connected = [];
|
|
429
505
|
for (const backend of backends) {
|
|
@@ -519,6 +595,10 @@ async function createAggregateServer(options) {
|
|
|
519
595
|
]
|
|
520
596
|
};
|
|
521
597
|
}
|
|
598
|
+
if (gateCall) {
|
|
599
|
+
const gated = await gateCall(backend.toolset, toolName);
|
|
600
|
+
if (gated) return gated;
|
|
601
|
+
}
|
|
522
602
|
const args = {
|
|
523
603
|
...request.params.arguments ?? {}
|
|
524
604
|
};
|
|
@@ -644,28 +724,6 @@ function installProcessSafety(opts = {}) {
|
|
|
644
724
|
// ../mcp-runtime/transport/pin-interceptor.ts
|
|
645
725
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
646
726
|
|
|
647
|
-
// ../mcp-runtime/elicitation/auth-elicitation.ts
|
|
648
|
-
async function requestAuthElicitation(opts = {}) {
|
|
649
|
-
const handle = await startBrowserAuthFlow({
|
|
650
|
-
authUrl: opts.authUrl,
|
|
651
|
-
timeoutMs: opts.timeoutMs ?? 5 * 6e4
|
|
652
|
-
});
|
|
653
|
-
return {
|
|
654
|
-
signInUrl: handle.signInUrl,
|
|
655
|
-
waitForSignIn: () => handle.done,
|
|
656
|
-
cancel: () => handle.cancel()
|
|
657
|
-
};
|
|
658
|
-
}
|
|
659
|
-
async function ensureAuth(opts = {}) {
|
|
660
|
-
const existing = await readAuth();
|
|
661
|
-
if (existing && existing.expiresAt - Date.now() > 6e4) {
|
|
662
|
-
return { hadExistingAuth: true };
|
|
663
|
-
}
|
|
664
|
-
const eli = await requestAuthElicitation(opts);
|
|
665
|
-
await eli.waitForSignIn();
|
|
666
|
-
return { hadExistingAuth: false, signInUrl: eli.signInUrl };
|
|
667
|
-
}
|
|
668
|
-
|
|
669
727
|
// src/config.ts
|
|
670
728
|
import fs3 from "fs";
|
|
671
729
|
import path4 from "path";
|
|
@@ -678,6 +736,11 @@ function resolveConvexSiteUrl(convexUrl) {
|
|
|
678
736
|
if (explicit) return explicit;
|
|
679
737
|
return convexUrl.replace(/\.convex\.cloud$/, ".convex.site");
|
|
680
738
|
}
|
|
739
|
+
var DEFAULT_SIGN_IN_WAIT_MS = 12e4;
|
|
740
|
+
function resolveSignInWaitMs() {
|
|
741
|
+
const raw = Number(process.env.TEMPO_MCP_SIGN_IN_WAIT_MS);
|
|
742
|
+
return Number.isFinite(raw) && raw >= 0 ? raw : DEFAULT_SIGN_IN_WAIT_MS;
|
|
743
|
+
}
|
|
681
744
|
var ALL_TOOLSETS = [
|
|
682
745
|
"issues",
|
|
683
746
|
"docs",
|
|
@@ -736,6 +799,46 @@ function discoverWorkspace(startDir = process.cwd()) {
|
|
|
736
799
|
}
|
|
737
800
|
}
|
|
738
801
|
|
|
802
|
+
// src/login.ts
|
|
803
|
+
async function signInInteractively() {
|
|
804
|
+
const handle = await startBrowserAuthFlow({
|
|
805
|
+
authUrl: process.env.TEMPO_AUTH_URL
|
|
806
|
+
});
|
|
807
|
+
const opened = await openInBrowser(handle.signInUrl);
|
|
808
|
+
if (opened) {
|
|
809
|
+
console.log("Opened your browser to sign in to Tempo.");
|
|
810
|
+
console.log("If a browser didn't open, visit this URL:");
|
|
811
|
+
} else {
|
|
812
|
+
console.log("Sign in to Tempo by visiting:");
|
|
813
|
+
}
|
|
814
|
+
console.log(` ${handle.signInUrl}`);
|
|
815
|
+
console.log("");
|
|
816
|
+
console.log("Waiting for sign-in to complete...");
|
|
817
|
+
try {
|
|
818
|
+
await handle.done;
|
|
819
|
+
const stored = await readAuth();
|
|
820
|
+
console.log("");
|
|
821
|
+
console.log(
|
|
822
|
+
`Signed in as ${stored?.email ?? stored?.userId ?? "unknown user"}.`
|
|
823
|
+
);
|
|
824
|
+
console.log(`Credentials stored in ~/.tempo/auth.json (0600).`);
|
|
825
|
+
return 0;
|
|
826
|
+
} catch (err) {
|
|
827
|
+
console.error("Sign-in failed:", err instanceof Error ? err.message : err);
|
|
828
|
+
return 1;
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
async function runLogin() {
|
|
832
|
+
const existing = await readAuth();
|
|
833
|
+
if (existing && existing.expiresAt - Date.now() > 6e4) {
|
|
834
|
+
console.log(
|
|
835
|
+
`Already signed in as ${existing.email ?? existing.userId}. Run \`tempo-mcp logout\` first to re-authenticate.`
|
|
836
|
+
);
|
|
837
|
+
return 0;
|
|
838
|
+
}
|
|
839
|
+
return signInInteractively();
|
|
840
|
+
}
|
|
841
|
+
|
|
739
842
|
// ../convex-http-client-auth/client.ts
|
|
740
843
|
import { ConvexHttpClient } from "convex/browser";
|
|
741
844
|
|
|
@@ -808,7 +911,7 @@ var AuthedConvexClient = class {
|
|
|
808
911
|
continue;
|
|
809
912
|
}
|
|
810
913
|
if (mapped.code === "internal" && attempt < MAX_RETRIES - 1) {
|
|
811
|
-
await
|
|
914
|
+
await sleep4(BASE_DELAY_MS * 2 ** attempt);
|
|
812
915
|
continue;
|
|
813
916
|
}
|
|
814
917
|
throw new McpToolError(mapped);
|
|
@@ -820,11 +923,19 @@ var AuthedConvexClient = class {
|
|
|
820
923
|
});
|
|
821
924
|
}
|
|
822
925
|
};
|
|
823
|
-
function
|
|
926
|
+
function sleep4(ms) {
|
|
824
927
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
825
928
|
}
|
|
826
929
|
|
|
827
930
|
// src/cli-auth.ts
|
|
931
|
+
var NotSignedInError = class extends Error {
|
|
932
|
+
constructor() {
|
|
933
|
+
super(
|
|
934
|
+
"Not signed in to Tempo. Run `npx -y @tempo-ai/mcp login` in a terminal, or set TEMPO_AUTH_TOKEN for headless environments."
|
|
935
|
+
);
|
|
936
|
+
this.name = "NotSignedInError";
|
|
937
|
+
}
|
|
938
|
+
};
|
|
828
939
|
async function ensureCliAuth() {
|
|
829
940
|
const accessToken = envAccessToken();
|
|
830
941
|
const convexSiteUrl = resolveConvexSiteUrl(resolveConvexUrl());
|
|
@@ -838,7 +949,9 @@ async function ensureCliAuth() {
|
|
|
838
949
|
});
|
|
839
950
|
await loop.refreshNow();
|
|
840
951
|
}
|
|
841
|
-
await
|
|
952
|
+
if (await readAuth()) return;
|
|
953
|
+
if (!process.stdout.isTTY) throw new NotSignedInError();
|
|
954
|
+
if (await signInInteractively() !== 0) throw new NotSignedInError();
|
|
842
955
|
return;
|
|
843
956
|
}
|
|
844
957
|
const existing = await readAuth();
|
|
@@ -863,7 +976,7 @@ function createCliConvex() {
|
|
|
863
976
|
attemptReauth: envTokenReauth(convexSiteUrl),
|
|
864
977
|
onReauthRequired: () => {
|
|
865
978
|
console.error(
|
|
866
|
-
"[tempo-mcp] Tempo session expired. Run `tempo-mcp login` to sign in again."
|
|
979
|
+
"[tempo-mcp] Tempo session expired. Run `npx -y @tempo-ai/mcp login` to sign in again."
|
|
867
980
|
);
|
|
868
981
|
}
|
|
869
982
|
});
|
|
@@ -874,23 +987,29 @@ function createCliConvex() {
|
|
|
874
987
|
}
|
|
875
988
|
|
|
876
989
|
export {
|
|
990
|
+
McpToolError,
|
|
991
|
+
AuthedConvexClient,
|
|
877
992
|
readAuth,
|
|
878
993
|
readAuthSync,
|
|
879
994
|
clearAuth,
|
|
880
995
|
createRefreshLoop,
|
|
881
996
|
createAuthProvider,
|
|
882
997
|
envAccessToken,
|
|
883
|
-
|
|
998
|
+
storedAuthMatchesAccessToken,
|
|
999
|
+
TokenExchangeError,
|
|
1000
|
+
exchangeAccessToken,
|
|
1001
|
+
createSignInPrompt,
|
|
884
1002
|
createAggregateServer,
|
|
885
1003
|
installProcessSafety,
|
|
886
|
-
McpToolError,
|
|
887
|
-
AuthedConvexClient,
|
|
888
1004
|
resolveConvexUrl,
|
|
889
1005
|
resolveConvexSiteUrl,
|
|
1006
|
+
resolveSignInWaitMs,
|
|
890
1007
|
parseServeArgs,
|
|
891
1008
|
discoverWorkspace,
|
|
1009
|
+
runLogin,
|
|
1010
|
+
NotSignedInError,
|
|
892
1011
|
ensureCliAuth,
|
|
893
1012
|
envTokenReauth,
|
|
894
1013
|
createCliConvex
|
|
895
1014
|
};
|
|
896
|
-
//# sourceMappingURL=chunk-
|
|
1015
|
+
//# sourceMappingURL=chunk-2P3T5CJG.js.map
|