@carrierllc/mcp 0.13.33 → 0.13.35
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
|
@@ -44,7 +44,7 @@ import {
|
|
|
44
44
|
verifyStorefront,
|
|
45
45
|
walletScreen,
|
|
46
46
|
which
|
|
47
|
-
} from "./chunk-
|
|
47
|
+
} from "./chunk-EH3ZRLVZ.js";
|
|
48
48
|
import {
|
|
49
49
|
copyTree,
|
|
50
50
|
exists,
|
|
@@ -1127,7 +1127,7 @@ function oauthFirstUseNote() {
|
|
|
1127
1127
|
}
|
|
1128
1128
|
function formatStatusBlock(st) {
|
|
1129
1129
|
const yn = (ok2, yes = "yes", no = "no") => ok2 ? pc.green(yes) : pc.yellow(no);
|
|
1130
|
-
const authLabel = st.authMode === "oauth" ? pc.green("OAuth session ready for CLI / Ask the fleet") : st.authMode === "oauth-first-use" ? pc.cyan("OAuth on first use (no token needed)") : st.authMode === "api-key" ? pc.green("org API key in env (CARRIER_API_KEY)") : st.authMode === "ocs-token" ? pc.green("OCS token in env") : pc.yellow("not ready \u2014 install MCP or open sign-up");
|
|
1130
|
+
const authLabel = st.authMode === "oauth" ? pc.green("OAuth session ready for CLI / Ask the fleet") : st.authMode === "oauth-first-use" ? pc.cyan("OAuth on first use (no token needed)") : st.authMode === "api-key" ? pc.green("org API key in env (CARRIER_API_KEY)") : st.authMode === "ocs-token" ? pc.green("OCS token in env (read-only, ?TOKEN= path; for writes set CARRIER_API_KEY, or unset ESIMVAULT_API_TOKEN/CARRIER_OCS_API_TOKEN and carrier login)") : pc.yellow("not ready \u2014 install MCP or open sign-up");
|
|
1131
1131
|
return [
|
|
1132
1132
|
`Claude Code: ${yn(st.claudeFound, "found", "not on PATH")}`,
|
|
1133
1133
|
`Plugin: ${st.pluginInstalled ? pc.green(`installed v${st.pluginVersion ?? "?"}`) : pc.yellow("not installed")}`,
|
|
@@ -1511,6 +1511,10 @@ function facts(value) {
|
|
|
1511
1511
|
}
|
|
1512
1512
|
|
|
1513
1513
|
// src/cli/lib/ask.ts
|
|
1514
|
+
var OCS_TOKEN_AUTH_HINTS = [
|
|
1515
|
+
"Confirm ESIMVAULT_API_TOKEN / CARRIER_OCS_API_TOKEN is a valid eSIMVault reseller token",
|
|
1516
|
+
"An OCS token is read-only on Carrier MCP. For writes: export CARRIER_API_KEY=ak_\u2026 (it outranks the OCS token), or unset ESIMVAULT_API_TOKEN and CARRIER_OCS_API_TOKEN, then carrier login"
|
|
1517
|
+
];
|
|
1514
1518
|
var DEFAULT_ERROR_HINTS = [
|
|
1515
1519
|
"Re-check the arguments: carrier <domain> <command> --help",
|
|
1516
1520
|
"Or open Claude and ask there with full tool routing"
|
|
@@ -1542,8 +1546,9 @@ function parseRpcBody(raw) {
|
|
|
1542
1546
|
return JSON.parse(dataLine.slice(5).trim());
|
|
1543
1547
|
}
|
|
1544
1548
|
async function callMcpTool(tool, args, opts = {}) {
|
|
1545
|
-
const
|
|
1546
|
-
|
|
1549
|
+
const credential = resolveExplicitCredential({ allowOcs: true }) ?? await resolveCredential({ allowOcs: true });
|
|
1550
|
+
const token = credential?.token;
|
|
1551
|
+
if (!credential || !token) {
|
|
1547
1552
|
return {
|
|
1548
1553
|
ok: false,
|
|
1549
1554
|
text: withNextStep("Not signed in.", [
|
|
@@ -1553,8 +1558,10 @@ async function callMcpTool(tool, args, opts = {}) {
|
|
|
1553
1558
|
])
|
|
1554
1559
|
};
|
|
1555
1560
|
}
|
|
1561
|
+
const isOcsToken = credential.kind === "ocs-token";
|
|
1562
|
+
const mcpUrl = isOcsToken ? `${MCP_URL}?TOKEN=${encodeURIComponent(token)}` : MCP_URL;
|
|
1556
1563
|
const headers = {
|
|
1557
|
-
Authorization: `Bearer ${token}
|
|
1564
|
+
...isOcsToken ? {} : { Authorization: `Bearer ${token}` },
|
|
1558
1565
|
"Content-Type": "application/json",
|
|
1559
1566
|
Accept: "application/json, text/event-stream"
|
|
1560
1567
|
};
|
|
@@ -1571,7 +1578,7 @@ async function callMcpTool(tool, args, opts = {}) {
|
|
|
1571
1578
|
try {
|
|
1572
1579
|
const result = await Promise.race([
|
|
1573
1580
|
(async () => {
|
|
1574
|
-
const initRes = await fetch(
|
|
1581
|
+
const initRes = await fetch(mcpUrl, {
|
|
1575
1582
|
method: "POST",
|
|
1576
1583
|
headers,
|
|
1577
1584
|
signal,
|
|
@@ -1589,13 +1596,29 @@ async function callMcpTool(tool, args, opts = {}) {
|
|
|
1589
1596
|
if (initRes.status === 401 || initRes.status === 403) {
|
|
1590
1597
|
return {
|
|
1591
1598
|
ok: false,
|
|
1592
|
-
text: withNextStep(`MCP returned ${initRes.status} (auth rejected).`, [
|
|
1599
|
+
text: withNextStep(`MCP returned ${initRes.status} (auth rejected).`, isOcsToken ? OCS_TOKEN_AUTH_HINTS : [
|
|
1593
1600
|
"Confirm CARRIER_API_KEY is a valid org key (ak_\u2026) from app.carrier.llc",
|
|
1594
1601
|
"Or complete OCS onboarding: https://app.carrier.llc/onboarding",
|
|
1595
1602
|
"Interactive: use Claude + OAuth instead of a headless key"
|
|
1596
1603
|
])
|
|
1597
1604
|
};
|
|
1598
1605
|
}
|
|
1606
|
+
if (!initRes.ok) {
|
|
1607
|
+
const body = (await initRes.text().catch(() => "")).trim();
|
|
1608
|
+
let reason = body.slice(0, 240);
|
|
1609
|
+
try {
|
|
1610
|
+
const parsed = JSON.parse(body);
|
|
1611
|
+
reason = parsed.error_description ?? parsed.error ?? reason;
|
|
1612
|
+
} catch {
|
|
1613
|
+
}
|
|
1614
|
+
return {
|
|
1615
|
+
ok: false,
|
|
1616
|
+
text: withNextStep(
|
|
1617
|
+
initRes.status === 429 ? `MCP rate limit reached (429): ${reason}` : `MCP initialize failed (${initRes.status}). ${reason}`,
|
|
1618
|
+
initRes.status === 429 ? ["Wait a few minutes and retry, or spread calls out over time"] : ["Retry later, or use Claude with the registered MCP (OAuth path)"]
|
|
1619
|
+
)
|
|
1620
|
+
};
|
|
1621
|
+
}
|
|
1599
1622
|
const sessionId = initRes.headers.get("mcp-session-id") ?? initRes.headers.get("Mcp-Session-Id");
|
|
1600
1623
|
await initRes.arrayBuffer().catch(() => void 0);
|
|
1601
1624
|
if (!sessionId) {
|
|
@@ -1608,13 +1631,13 @@ async function callMcpTool(tool, args, opts = {}) {
|
|
|
1608
1631
|
};
|
|
1609
1632
|
}
|
|
1610
1633
|
const sessionHeaders = { ...headers, "Mcp-Session-Id": sessionId };
|
|
1611
|
-
await fetch(
|
|
1634
|
+
await fetch(mcpUrl, {
|
|
1612
1635
|
method: "POST",
|
|
1613
1636
|
headers: sessionHeaders,
|
|
1614
1637
|
signal,
|
|
1615
1638
|
body: JSON.stringify({ jsonrpc: "2.0", method: "notifications/initialized" })
|
|
1616
1639
|
}).catch(() => void 0);
|
|
1617
|
-
const res = await fetch(
|
|
1640
|
+
const res = await fetch(mcpUrl, {
|
|
1618
1641
|
method: "POST",
|
|
1619
1642
|
headers: sessionHeaders,
|
|
1620
1643
|
signal,
|
|
@@ -1670,7 +1693,9 @@ async function callMcpTool(tool, args, opts = {}) {
|
|
|
1670
1693
|
)
|
|
1671
1694
|
};
|
|
1672
1695
|
}
|
|
1673
|
-
const msg = redact(
|
|
1696
|
+
const msg = redact(
|
|
1697
|
+
(e instanceof Error ? e.message : String(e)).split(token).join("***").split(encodeURIComponent(token)).join("***")
|
|
1698
|
+
);
|
|
1674
1699
|
return {
|
|
1675
1700
|
ok: false,
|
|
1676
1701
|
text: withNextStep(`Could not reach MCP: ${msg}`, [
|