@avallon-labs/mcp 3.2.0 → 3.3.0

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/index.js CHANGED
@@ -29,31 +29,30 @@ function setupFetch() {
29
29
  headers.set("x-api-key", apiKey);
30
30
  }
31
31
  const response = await originalFetch(url, { ...init, headers });
32
- const originalJson = response.json.bind(response);
33
- const patchedResponse = Object.create(response);
34
- patchedResponse.json = async function() {
35
- const body2 = await originalJson();
36
- if (body2 !== null && typeof body2 === "object" && "data" in body2) {
37
- return body2.data;
38
- }
39
- return body2;
40
- };
41
32
  if (!response.ok) {
42
33
  const contentType = response.headers.get("Content-Type") ?? "";
43
34
  let msg;
44
35
  if (contentType.includes("application/json")) {
45
- const errBody = await originalJson().catch(() => ({}));
36
+ const errBody = await response.json().catch(() => ({}));
46
37
  msg = errBody?.message ?? `API error ${response.status}`;
47
38
  } else {
48
39
  msg = await response.text().catch(() => `API error ${response.status}`);
49
40
  }
50
41
  throw new Error(`Avallon API error ${response.status}: ${String(msg)}`);
51
42
  }
52
- return patchedResponse;
43
+ const originalJson = response.json.bind(response);
44
+ response.json = async function() {
45
+ const body2 = await originalJson();
46
+ if (body2 !== null && typeof body2 === "object" && "data" in body2) {
47
+ return body2.data;
48
+ }
49
+ return body2;
50
+ };
51
+ return response;
53
52
  };
54
53
  }
55
54
 
56
55
  // src/index.ts
57
56
  setupFetch();
58
- await import("./server-HKL57S22.js");
57
+ await import("./server-J2K6763M.js");
59
58
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/setup-fetch.ts","../src/index.ts"],"sourcesContent":["/**\n * Patches globalThis.fetch before the generated MCP server is imported.\n *\n * Auth precedence (first match wins):\n * 1. AVALLON_ACCESS_TOKEN → Bearer token\n * 2. AVALLON_API_KEY → x-api-key header\n */\n\nconst DEFAULT_BASE_URL = \"https://api.avallon.ai\";\n\nexport function setupFetch(): void {\n const originalFetch = globalThis.fetch;\n\n globalThis.fetch = async function patchedFetch(\n input: RequestInfo | URL,\n init?: RequestInit\n ): Promise<Response> {\n const baseUrl = process.env.AVALLON_BASE_URL ?? DEFAULT_BASE_URL;\n\n // Resolve URL: prepend base URL for relative paths\n let url: string;\n if (typeof input === \"string\") {\n url = input.startsWith(\"http\") ? input : `${baseUrl}${input}`;\n } else if (input instanceof URL) {\n url = input.href.startsWith(\"http\")\n ? input.href\n : `${baseUrl}${input.href}`;\n } else {\n // Request object\n url = (input as Request).url;\n }\n\n const headers = new Headers(\n init?.headers ?? (input instanceof Request ? input.headers : undefined)\n );\n\n // Only set Content-Type for requests with a JSON string body.\n // This lets multipart/form-data requests set their own Content-Type.\n const body =\n init?.body ?? (input instanceof Request ? input.body : undefined);\n if (body && typeof body === \"string\") {\n headers.set(\"Content-Type\", \"application/json\");\n }\n\n const accessToken = process.env.AVALLON_ACCESS_TOKEN;\n const apiKey = process.env.AVALLON_API_KEY;\n\n if (accessToken) {\n headers.set(\"Authorization\", `Bearer ${accessToken}`);\n } else if (apiKey) {\n headers.set(\"x-api-key\", apiKey);\n }\n\n const response = await originalFetch(url, { ...init, headers });\n\n // Wrap response.json() to strip the API envelope ({ data, message } → data)\n const originalJson = response.json.bind(response);\n const patchedResponse = Object.create(response) as Response;\n patchedResponse.json = async function (): Promise<unknown> {\n const body = await originalJson();\n if (\n body !== null &&\n typeof body === \"object\" &&\n \"data\" in (body as Record<string, unknown>)\n ) {\n return (body as Record<string, unknown>).data;\n }\n return body;\n };\n\n if (!response.ok) {\n const contentType = response.headers.get(\"Content-Type\") ?? \"\";\n let msg: unknown;\n if (contentType.includes(\"application/json\")) {\n const errBody = await originalJson().catch(() => ({}));\n msg =\n (errBody as Record<string, unknown>)?.message ??\n `API error ${response.status}`;\n } else {\n msg = await response.text().catch(() => `API error ${response.status}`);\n }\n throw new Error(`Avallon API error ${response.status}: ${String(msg)}`);\n }\n\n return patchedResponse;\n };\n}\n","/**\n * Avallon MCP server entry point.\n *\n * setupFetch() must run before any generated code is imported, because the\n * generated http-client.ts calls globalThis.fetch at module evaluation time.\n * ESM static imports are hoisted, so we use a dynamic import to guarantee\n * ordering: patch first, then load the generated server.\n *\n * Run `npm run generate` (or `npm run mcp:gen` from the repo root) to\n * regenerate the server from the latest OpenAPI spec before building.\n */\n\nimport { setupFetch } from \"./setup-fetch.js\";\n\nsetupFetch();\n\nawait import(\"./generated/server.js\");\n"],"mappings":";;;AAQA,IAAM,mBAAmB;AAElB,SAAS,aAAmB;AACjC,QAAM,gBAAgB,WAAW;AAEjC,aAAW,QAAQ,eAAe,aAChC,OACA,MACmB;AACnB,UAAM,UAAU,QAAQ,IAAI,oBAAoB;AAGhD,QAAI;AACJ,QAAI,OAAO,UAAU,UAAU;AAC7B,YAAM,MAAM,WAAW,MAAM,IAAI,QAAQ,GAAG,OAAO,GAAG,KAAK;AAAA,IAC7D,WAAW,iBAAiB,KAAK;AAC/B,YAAM,MAAM,KAAK,WAAW,MAAM,IAC9B,MAAM,OACN,GAAG,OAAO,GAAG,MAAM,IAAI;AAAA,IAC7B,OAAO;AAEL,YAAO,MAAkB;AAAA,IAC3B;AAEA,UAAM,UAAU,IAAI;AAAA,MAClB,MAAM,YAAY,iBAAiB,UAAU,MAAM,UAAU;AAAA,IAC/D;AAIA,UAAM,OACJ,MAAM,SAAS,iBAAiB,UAAU,MAAM,OAAO;AACzD,QAAI,QAAQ,OAAO,SAAS,UAAU;AACpC,cAAQ,IAAI,gBAAgB,kBAAkB;AAAA,IAChD;AAEA,UAAM,cAAc,QAAQ,IAAI;AAChC,UAAM,SAAS,QAAQ,IAAI;AAE3B,QAAI,aAAa;AACf,cAAQ,IAAI,iBAAiB,UAAU,WAAW,EAAE;AAAA,IACtD,WAAW,QAAQ;AACjB,cAAQ,IAAI,aAAa,MAAM;AAAA,IACjC;AAEA,UAAM,WAAW,MAAM,cAAc,KAAK,EAAE,GAAG,MAAM,QAAQ,CAAC;AAG9D,UAAM,eAAe,SAAS,KAAK,KAAK,QAAQ;AAChD,UAAM,kBAAkB,OAAO,OAAO,QAAQ;AAC9C,oBAAgB,OAAO,iBAAoC;AACzD,YAAMA,QAAO,MAAM,aAAa;AAChC,UACEA,UAAS,QACT,OAAOA,UAAS,YAChB,UAAWA,OACX;AACA,eAAQA,MAAiC;AAAA,MAC3C;AACA,aAAOA;AAAA,IACT;AAEA,QAAI,CAAC,SAAS,IAAI;AAChB,YAAM,cAAc,SAAS,QAAQ,IAAI,cAAc,KAAK;AAC5D,UAAI;AACJ,UAAI,YAAY,SAAS,kBAAkB,GAAG;AAC5C,cAAM,UAAU,MAAM,aAAa,EAAE,MAAM,OAAO,CAAC,EAAE;AACrD,cACG,SAAqC,WACtC,aAAa,SAAS,MAAM;AAAA,MAChC,OAAO;AACL,cAAM,MAAM,SAAS,KAAK,EAAE,MAAM,MAAM,aAAa,SAAS,MAAM,EAAE;AAAA,MACxE;AACA,YAAM,IAAI,MAAM,qBAAqB,SAAS,MAAM,KAAK,OAAO,GAAG,CAAC,EAAE;AAAA,IACxE;AAEA,WAAO;AAAA,EACT;AACF;;;ACxEA,WAAW;AAEX,MAAM,OAAO,sBAAuB;","names":["body"]}
1
+ {"version":3,"sources":["../src/setup-fetch.ts","../src/index.ts"],"sourcesContent":["/**\n * Patches globalThis.fetch before the generated MCP server is imported.\n *\n * Auth precedence (first match wins):\n * 1. AVALLON_ACCESS_TOKEN → Bearer token\n * 2. AVALLON_API_KEY → x-api-key header\n */\n\nconst DEFAULT_BASE_URL = \"https://api.avallon.ai\";\n\nexport function setupFetch(): void {\n const originalFetch = globalThis.fetch;\n\n globalThis.fetch = async function patchedFetch(\n input: RequestInfo | URL,\n init?: RequestInit\n ): Promise<Response> {\n const baseUrl = process.env.AVALLON_BASE_URL ?? DEFAULT_BASE_URL;\n\n // Resolve URL: prepend base URL for relative paths\n let url: string;\n if (typeof input === \"string\") {\n url = input.startsWith(\"http\") ? input : `${baseUrl}${input}`;\n } else if (input instanceof URL) {\n url = input.href.startsWith(\"http\")\n ? input.href\n : `${baseUrl}${input.href}`;\n } else {\n // Request object\n url = (input as Request).url;\n }\n\n const headers = new Headers(\n init?.headers ?? (input instanceof Request ? input.headers : undefined)\n );\n\n // Only set Content-Type for requests with a JSON string body.\n // This lets multipart/form-data requests set their own Content-Type.\n const body =\n init?.body ?? (input instanceof Request ? input.body : undefined);\n if (body && typeof body === \"string\") {\n headers.set(\"Content-Type\", \"application/json\");\n }\n\n const accessToken = process.env.AVALLON_ACCESS_TOKEN;\n const apiKey = process.env.AVALLON_API_KEY;\n\n if (accessToken) {\n headers.set(\"Authorization\", `Bearer ${accessToken}`);\n } else if (apiKey) {\n headers.set(\"x-api-key\", apiKey);\n }\n\n const response = await originalFetch(url, { ...init, headers });\n\n if (!response.ok) {\n const contentType = response.headers.get(\"Content-Type\") ?? \"\";\n let msg: unknown;\n if (contentType.includes(\"application/json\")) {\n const errBody = await response.json().catch(() => ({}));\n msg =\n (errBody as Record<string, unknown>)?.message ??\n `API error ${response.status}`;\n } else {\n msg = await response.text().catch(() => `API error ${response.status}`);\n }\n throw new Error(`Avallon API error ${response.status}: ${String(msg)}`);\n }\n\n // Strip the API envelope ({ data, message } → data) by patching the\n // response in place. We must NOT use Object.create(response) because\n // Node 22+ implements Response with private class fields (#state) that\n // are instance-bound and break through prototype delegation.\n const originalJson = response.json.bind(response);\n response.json = async function (): Promise<unknown> {\n const body = await originalJson();\n if (\n body !== null &&\n typeof body === \"object\" &&\n \"data\" in (body as Record<string, unknown>)\n ) {\n return (body as Record<string, unknown>).data;\n }\n return body;\n };\n\n return response;\n };\n}\n","/**\n * Avallon MCP server entry point.\n *\n * setupFetch() must run before any generated code is imported, because the\n * generated http-client.ts calls globalThis.fetch at module evaluation time.\n * ESM static imports are hoisted, so we use a dynamic import to guarantee\n * ordering: patch first, then load the generated server.\n *\n * Run `npm run generate` (or `npm run mcp:gen` from the repo root) to\n * regenerate the server from the latest OpenAPI spec before building.\n */\n\nimport { setupFetch } from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AAAA,MAChC,OAAO;AACL,cAAM,MAAM,SAAS,KAAK,EAAE,MAAM,MAAM,aAAa,SAAS,MAAM,EAAE;AAAA,MACxE;AACA,YAAM,IAAI,MAAM,qBAAqB,SAAS,MAAM,KAAK,OAAO,GAAG,CAAC,EAAE;AAAA,IACxE;AAMA,UAAM,eAAe,SAAS,KAAK,KAAK,QAAQ;AAChD,aAAS,OAAO,iBAAoC;AAClD,YAAMA,QAAO,MAAM,aAAa;AAChC,UACEA,UAAS,QACT,OAAOA,UAAS,YAChB,UAAWA,OACX;AACA,eAAQA,MAAiC;AAAA,MAC3C;AACA,aAAOA;AAAA,IACT;AAEA,WAAO;AAAA,EACT;AACF;;;AC1EA,WAAW;AAEX,MAAM,OAAO,sBAAuB;","names":["body"]}
@@ -4243,4 +4243,4 @@ var transport = new StdioServerTransport();
4243
4243
  server.connect(transport).then(() => {
4244
4244
  console.error("MCP server running on stdio");
4245
4245
  }).catch(console.error);
4246
- //# sourceMappingURL=server-HKL57S22.js.map
4246
+ //# sourceMappingURL=server-J2K6763M.js.map