metheus-governance-mcp-cli 0.2.8 → 0.2.9

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.
Files changed (2) hide show
  1. package/cli.mjs +58 -13
  2. package/package.json +1 -1
package/cli.mjs CHANGED
@@ -1411,6 +1411,19 @@ function addDoctorCheck(rows, status, label, detail) {
1411
1411
  });
1412
1412
  }
1413
1413
 
1414
+ function isUnauthorizedLike(rawText) {
1415
+ const text = String(rawText || "").trim().toLowerCase();
1416
+ if (!text) return false;
1417
+ return (
1418
+ text.includes("unauthorized") ||
1419
+ text.includes("access denied") ||
1420
+ text.includes("status 401") ||
1421
+ text.includes("status 403") ||
1422
+ text.includes("http 401") ||
1423
+ text.includes("http 403")
1424
+ );
1425
+ }
1426
+
1414
1427
  function statusIcon(status) {
1415
1428
  if (status === "ok") return "OK";
1416
1429
  if (status === "fail") return "FAIL";
@@ -1695,12 +1708,25 @@ async function runDoctor(flags) {
1695
1708
  addDoctorCheck(rows, "ok", "server mode", "ctxpack writable");
1696
1709
  }
1697
1710
  } catch (err) {
1698
- addDoctorCheck(
1699
- rows,
1700
- "warn",
1701
- "server ctxpack policy",
1702
- `unable to read /ctxpack/stats (${String(err?.message || err)})`,
1703
- );
1711
+ const statusCode = Number(err?.statusCode || 0);
1712
+ const message = String(err?.message || err);
1713
+ if (statusCode === 404) {
1714
+ addDoctorCheck(
1715
+ rows,
1716
+ "ok",
1717
+ "server ctxpack policy",
1718
+ "ctxpack/stats endpoint is not exposed in this deployment (optional check skipped)",
1719
+ );
1720
+ } else if (statusCode === 401 || statusCode === 403 || isUnauthorizedLike(message)) {
1721
+ addDoctorCheck(
1722
+ rows,
1723
+ "warn",
1724
+ "server ctxpack policy",
1725
+ "no permission to read ctxpack/stats in this environment",
1726
+ );
1727
+ } else {
1728
+ addDoctorCheck(rows, "warn", "server ctxpack policy", `unable to read /ctxpack/stats (${message})`);
1729
+ }
1704
1730
  }
1705
1731
  }
1706
1732
 
@@ -1736,7 +1762,17 @@ async function runDoctor(flags) {
1736
1762
  },
1737
1763
  });
1738
1764
  if (!rpc.ok) {
1739
- addDoctorCheck(rows, "fail", `smoke ${row.tool}`, rpc.error || "rpc error");
1765
+ const errorText = String(rpc.error || "rpc error");
1766
+ if (isUnauthorizedLike(errorText)) {
1767
+ addDoctorCheck(
1768
+ rows,
1769
+ "warn",
1770
+ `smoke ${row.tool}`,
1771
+ "unauthorized for this tool with current token/project role",
1772
+ );
1773
+ } else {
1774
+ addDoctorCheck(rows, "fail", `smoke ${row.tool}`, errorText);
1775
+ }
1740
1776
  continue;
1741
1777
  }
1742
1778
  const envelope = parseToolEnvelopeFromRPCResult(safeObject(rpc.response).result);
@@ -1749,12 +1785,21 @@ async function runDoctor(flags) {
1749
1785
  if (ok && status >= 200 && status < 300) {
1750
1786
  addDoctorCheck(rows, "ok", `smoke ${row.tool}`, `status ${status}`);
1751
1787
  } else {
1752
- addDoctorCheck(
1753
- rows,
1754
- "fail",
1755
- `smoke ${row.tool}`,
1756
- `status ${status || "-"}, ok=${ok ? "true" : "false"}`,
1757
- );
1788
+ if (status === 401 || status === 403) {
1789
+ addDoctorCheck(
1790
+ rows,
1791
+ "warn",
1792
+ `smoke ${row.tool}`,
1793
+ `status ${status}: unauthorized for this tool with current token/project role`,
1794
+ );
1795
+ } else {
1796
+ addDoctorCheck(
1797
+ rows,
1798
+ "fail",
1799
+ `smoke ${row.tool}`,
1800
+ `status ${status || "-"}, ok=${ok ? "true" : "false"}`,
1801
+ );
1802
+ }
1758
1803
  }
1759
1804
  }
1760
1805
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "metheus-governance-mcp-cli",
3
- "version": "0.2.8",
3
+ "version": "0.2.9",
4
4
  "description": "Metheus Governance MCP CLI (setup + stdio proxy)",
5
5
  "type": "module",
6
6
  "files": [