@vorim/mcp-server 1.1.5 → 1.1.6

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/build/index.js +55 -8
  2. package/package.json +1 -1
package/build/index.js CHANGED
@@ -41,10 +41,25 @@ if (!API_KEY) {
41
41
  }
42
42
  // ─── HTTP Client ──────────────────────────────────────────────────────────
43
43
  // Read the package version once so the User-Agent string and the MCP
44
- // server's advertised version stay in sync with package.json.
45
- // require() works in the CommonJS build path; for the ESM-only build
46
- // we fall back to a constant that must match package.json.
47
- const MCP_VERSION = "1.1.5";
44
+ // server's advertised version stay in sync with package.json. The
45
+ // hardcoded fallback is the last-known version operators see a
46
+ // loud-fail if it ever drifts in CI because `npm test` re-reads
47
+ // package.json and compares.
48
+ import { readFileSync } from "node:fs";
49
+ import { fileURLToPath } from "node:url";
50
+ import { dirname, join } from "node:path";
51
+ function readMcpVersion() {
52
+ try {
53
+ const here = dirname(fileURLToPath(import.meta.url));
54
+ const pkgPath = join(here, "..", "package.json");
55
+ const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
56
+ if (typeof pkg.version === "string")
57
+ return pkg.version;
58
+ }
59
+ catch { /* fall through */ }
60
+ return "1.1.6"; // hardcoded fallback; bump alongside package.json
61
+ }
62
+ const MCP_VERSION = readMcpVersion();
48
63
  /**
49
64
  * URL-encode a user-supplied path segment. Agent ids, scopes, and
50
65
  * chain ids all reach the API via path interpolation; raw slashes or
@@ -80,7 +95,19 @@ async function vorimRequest(method, path, body) {
80
95
  }
81
96
  throw new Error(err?.message || "Vorim API rejected with 403");
82
97
  }
83
- const json = await response.json();
98
+ // Be defensive about non-JSON 5xx bodies (nginx 502, gateway HTML).
99
+ // Without this, response.json() throws "Unexpected token <" and the
100
+ // user sees an unhelpful parser error.
101
+ let json;
102
+ try {
103
+ json = await response.json();
104
+ }
105
+ catch {
106
+ if (!response.ok) {
107
+ throw new Error(`Vorim API returned HTTP ${response.status} (non-JSON response — check upstream gateway)`);
108
+ }
109
+ throw new Error("Vorim API returned a non-JSON success response");
110
+ }
84
111
  if (!response.ok) {
85
112
  const err = json.error;
86
113
  throw new Error(err?.message || `HTTP ${response.status}`);
@@ -117,8 +144,16 @@ server.registerTool("vorim_ping", {
117
144
  const response = await fetch(`${BASE_URL}/health`, {
118
145
  headers: { "User-Agent": `vorim-mcp-server/${MCP_VERSION}` },
119
146
  });
120
- const data = await response.json();
121
- return text(data);
147
+ if (!response.ok) {
148
+ throw new Error(`Vorim API health endpoint returned HTTP ${response.status}`);
149
+ }
150
+ try {
151
+ const data = await response.json();
152
+ return text(data);
153
+ }
154
+ catch {
155
+ throw new Error(`Vorim API returned a non-JSON health response (status ${response.status}); check upstream gateway`);
156
+ }
122
157
  });
123
158
  // ─── Agent Identity ───────────────────────────────────────────────────────
124
159
  server.registerTool("vorim_register_agent", {
@@ -284,7 +319,19 @@ server.registerTool("vorim_verify_trust", {
284
319
  const response = await fetch(`${BASE_URL}/v1/trust/verify/${encId(agent_id)}`, {
285
320
  headers: { "User-Agent": `vorim-mcp-server/${MCP_VERSION}` },
286
321
  });
287
- const json = await response.json();
322
+ if (!response.ok) {
323
+ if (response.status === 404) {
324
+ throw new Error(`Agent ${agent_id} is not registered with Vorim`);
325
+ }
326
+ throw new Error(`Vorim trust endpoint returned HTTP ${response.status}`);
327
+ }
328
+ let json;
329
+ try {
330
+ json = await response.json();
331
+ }
332
+ catch {
333
+ throw new Error(`Vorim trust endpoint returned a non-JSON response (status ${response.status})`);
334
+ }
288
335
  return text(json.data || json);
289
336
  });
290
337
  // ─── Ephemeral Agents ────────────────────────────────────────────────────
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vorim/mcp-server",
3
- "version": "1.1.5",
3
+ "version": "1.1.6",
4
4
  "mcpName": "io.github.Kzino/vorim-mcp-server",
5
5
  "description": "MCP server for Vorim AI — AI agent identity, permissions, and audit trails",
6
6
  "type": "module",