@avallon-labs/mcp 57.2.0 → 58.0.0-staging.1300
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
|
@@ -33,8 +33,8 @@ function setupFetch() {
|
|
|
33
33
|
const contentType = response.headers.get("Content-Type") ?? "";
|
|
34
34
|
let msg;
|
|
35
35
|
if (contentType.includes("application/json")) {
|
|
36
|
-
const errBody = await response.json().catch(() =>
|
|
37
|
-
msg = errBody
|
|
36
|
+
const errBody = await response.json().catch(() => null) ?? {};
|
|
37
|
+
msg = (errBody.message ?? `API error ${response.status}`) + describeErrors(errBody);
|
|
38
38
|
} else {
|
|
39
39
|
msg = await response.text().catch(() => `API error ${response.status}`);
|
|
40
40
|
}
|
|
@@ -43,8 +43,18 @@ function setupFetch() {
|
|
|
43
43
|
return response;
|
|
44
44
|
};
|
|
45
45
|
}
|
|
46
|
+
function describeErrors(body) {
|
|
47
|
+
const errors = body.data?.errors ?? [];
|
|
48
|
+
if (errors.length === 0) {
|
|
49
|
+
return "";
|
|
50
|
+
}
|
|
51
|
+
const details = errors.map(
|
|
52
|
+
(error) => error.field ? `${error.field}: ${error.message}` : error.message
|
|
53
|
+
);
|
|
54
|
+
return ` (${details.join("; ")})`;
|
|
55
|
+
}
|
|
46
56
|
|
|
47
57
|
// src/index.ts
|
|
48
58
|
setupFetch();
|
|
49
|
-
await import("./server-
|
|
59
|
+
await import("./server-2J3FHU34.js");
|
|
50
60
|
//# 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 if (!response.ok) {\n const contentType = response.headers.get(\"Content-Type\") ?? \"\";\n let msg: unknown;\n if (contentType.includes(\"application/json\")) {\n const errBody
|
|
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: ErrorBody =\n (await response.json().catch(() => null)) ?? {};\n msg =\n (errBody.message ?? `API error ${response.status}`) +\n describeErrors(errBody);\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 response;\n };\n}\n\ntype ErrorBody = {\n message?: string;\n data?: { errors?: { field?: string; message: string }[] };\n};\n\nfunction describeErrors(body: ErrorBody): string {\n const errors = body.data?.errors ?? [];\n if (errors.length === 0) {\n return \"\";\n }\n const details = errors.map((error) =>\n error.field ? `${error.field}: ${error.message}` : error.message\n );\n return ` (${details.join(\"; \")})`;\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;AAE9D,QAAI,CAAC,SAAS,IAAI;AAChB,YAAM,cAAc,SAAS,QAAQ,IAAI,cAAc,KAAK;AAC5D,UAAI;AACJ,UAAI,YAAY,SAAS,kBAAkB,GAAG;AAC5C,cAAM,UACH,MAAM,SAAS,KAAK,EAAE,MAAM,MAAM,IAAI,KAAM,CAAC;AAChD,eACG,QAAQ,WAAW,aAAa,SAAS,MAAM,MAChD,eAAe,OAAO;AAAA,MAC1B,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;AAOA,SAAS,eAAe,MAAyB;AAC/C,QAAM,SAAS,KAAK,MAAM,UAAU,CAAC;AACrC,MAAI,OAAO,WAAW,GAAG;AACvB,WAAO;AAAA,EACT;AACA,QAAM,UAAU,OAAO;AAAA,IAAI,CAAC,UAC1B,MAAM,QAAQ,GAAG,MAAM,KAAK,KAAK,MAAM,OAAO,KAAK,MAAM;AAAA,EAC3D;AACA,SAAO,KAAK,QAAQ,KAAK,IAAI,CAAC;AAChC;;;AC1EA,WAAW;AAEX,MAAM,OAAO,sBAAuB;","names":[]}
|
|
@@ -11505,7 +11505,7 @@ var ListCasesResponse = zod.object({
|
|
|
11505
11505
|
var CreateCaseBody = zod.object({
|
|
11506
11506
|
"id": zod.string().min(1).describe("Case id, e.g. a claim number. Normalized server-side (trimmed and lowercased) to match how case ids are stored."),
|
|
11507
11507
|
"environment": zod.enum(["live", "test"]).optional(),
|
|
11508
|
-
"type_slug": zod.string().
|
|
11508
|
+
"type_slug": zod.string().describe("Slug of a case type. List the case types to pick one, then get it to see its fields."),
|
|
11509
11509
|
"fields": zod.record(zod.string(), zod.union([zod.object({
|
|
11510
11510
|
"value": zod.union([zod.union([zod.string(), zod.number(), zod.boolean()]), zod.array(zod.union([zod.string(), zod.number(), zod.boolean()]))]),
|
|
11511
11511
|
"citations": zod.array(zod.string().uuid()).describe("Chunk IDs from the `[chunk_id=\u2026]` markers of the sources.")
|
|
@@ -11608,7 +11608,7 @@ var UpdateCaseBody = zod.object({
|
|
|
11608
11608
|
"fields": zod.record(zod.string(), zod.union([zod.object({
|
|
11609
11609
|
"value": zod.union([zod.union([zod.string(), zod.number(), zod.boolean()]), zod.array(zod.union([zod.string(), zod.number(), zod.boolean()]))]),
|
|
11610
11610
|
"citations": zod.array(zod.string().uuid()).describe("Chunk IDs from the `[chunk_id=\u2026]` markers of the sources.")
|
|
11611
|
-
}), zod.null()])).optional().describe(
|
|
11611
|
+
}), zod.null()])).optional().describe('Values keyed by field key, validated against the case type. `null` clears a field whose `type` includes `"null"`.')
|
|
11612
11612
|
});
|
|
11613
11613
|
var UpdateCaseResponse = zod.object({
|
|
11614
11614
|
"data": zod.object({
|
|
@@ -12835,7 +12835,7 @@ var CreateCaseTypeBody = zod.object({
|
|
|
12835
12835
|
"description": zod.string(),
|
|
12836
12836
|
"type": zod.union([zod.literal("boolean"), zod.array(zod.enum(["boolean", "null"])).min(createCaseTypeBodyFieldsSchemaFiveItemsFourTypeTwoMin).max(createCaseTypeBodyFieldsSchemaFiveItemsFourTypeTwoMax)])
|
|
12837
12837
|
})])
|
|
12838
|
-
})])).describe("JSON Schema properties, keyed by permanent snake_case field key. Each field is a string, number, boolean or enum, or an array of those; a nullable type
|
|
12838
|
+
})])).describe("JSON Schema properties, keyed by permanent snake_case field key. Each field is a string, number, boolean or enum, or an array of those; a nullable type allows `null`. `title` is the label people see and can change any time. Set `x_sensitive` on fields holding personal data.")
|
|
12839
12839
|
});
|
|
12840
12840
|
var createCaseTypeResponseDataFieldsSchemaTwoTypeTwoMin = 2;
|
|
12841
12841
|
var createCaseTypeResponseDataFieldsSchemaTwoTypeTwoMax = 2;
|
|
@@ -12905,7 +12905,7 @@ var CreateCaseTypeResponse = zod.object({
|
|
|
12905
12905
|
"description": zod.string(),
|
|
12906
12906
|
"type": zod.union([zod.literal("boolean"), zod.array(zod.enum(["boolean", "null"])).min(createCaseTypeResponseDataFieldsSchemaFiveItemsFourTypeTwoMin).max(createCaseTypeResponseDataFieldsSchemaFiveItemsFourTypeTwoMax)])
|
|
12907
12907
|
})])
|
|
12908
|
-
})])).describe("JSON Schema properties, keyed by permanent snake_case field key. Each field is a string, number, boolean or enum, or an array of those; a nullable type
|
|
12908
|
+
})])).describe("JSON Schema properties, keyed by permanent snake_case field key. Each field is a string, number, boolean or enum, or an array of those; a nullable type allows `null`. `title` is the label people see and can change any time. Set `x_sensitive` on fields holding personal data.")
|
|
12909
12909
|
}),
|
|
12910
12910
|
"message": zod.string()
|
|
12911
12911
|
});
|
|
@@ -13010,7 +13010,7 @@ var GetCaseTypeResponse = zod.object({
|
|
|
13010
13010
|
"description": zod.string(),
|
|
13011
13011
|
"type": zod.union([zod.literal("boolean"), zod.array(zod.enum(["boolean", "null"])).min(getCaseTypeResponseDataFieldsSchemaFiveItemsFourTypeTwoMin).max(getCaseTypeResponseDataFieldsSchemaFiveItemsFourTypeTwoMax)])
|
|
13012
13012
|
})])
|
|
13013
|
-
})])).describe("JSON Schema properties, keyed by permanent snake_case field key. Each field is a string, number, boolean or enum, or an array of those; a nullable type
|
|
13013
|
+
})])).describe("JSON Schema properties, keyed by permanent snake_case field key. Each field is a string, number, boolean or enum, or an array of those; a nullable type allows `null`. `title` is the label people see and can change any time. Set `x_sensitive` on fields holding personal data.")
|
|
13014
13014
|
}),
|
|
13015
13015
|
"message": zod.string()
|
|
13016
13016
|
});
|
|
@@ -13076,7 +13076,7 @@ var UpdateCaseTypeBody = zod.object({
|
|
|
13076
13076
|
"description": zod.string(),
|
|
13077
13077
|
"type": zod.union([zod.literal("boolean"), zod.array(zod.enum(["boolean", "null"])).min(updateCaseTypeBodyFieldsSchemaFiveItemsFourTypeTwoMin).max(updateCaseTypeBodyFieldsSchemaFiveItemsFourTypeTwoMax)])
|
|
13078
13078
|
})])
|
|
13079
|
-
})])).optional().describe("JSON Schema properties, keyed by permanent snake_case field key. Each field is a string, number, boolean or enum, or an array of those; a nullable type
|
|
13079
|
+
})])).optional().describe("JSON Schema properties, keyed by permanent snake_case field key. Each field is a string, number, boolean or enum, or an array of those; a nullable type allows `null`. `title` is the label people see and can change any time. Set `x_sensitive` on fields holding personal data.")
|
|
13080
13080
|
});
|
|
13081
13081
|
var updateCaseTypeResponseDataFieldsSchemaTwoTypeTwoMin = 2;
|
|
13082
13082
|
var updateCaseTypeResponseDataFieldsSchemaTwoTypeTwoMax = 2;
|
|
@@ -13146,7 +13146,7 @@ var UpdateCaseTypeResponse = zod.object({
|
|
|
13146
13146
|
"description": zod.string(),
|
|
13147
13147
|
"type": zod.union([zod.literal("boolean"), zod.array(zod.enum(["boolean", "null"])).min(updateCaseTypeResponseDataFieldsSchemaFiveItemsFourTypeTwoMin).max(updateCaseTypeResponseDataFieldsSchemaFiveItemsFourTypeTwoMax)])
|
|
13148
13148
|
})])
|
|
13149
|
-
})])).describe("JSON Schema properties, keyed by permanent snake_case field key. Each field is a string, number, boolean or enum, or an array of those; a nullable type
|
|
13149
|
+
})])).describe("JSON Schema properties, keyed by permanent snake_case field key. Each field is a string, number, boolean or enum, or an array of those; a nullable type allows `null`. `title` is the label people see and can change any time. Set `x_sensitive` on fields holding personal data.")
|
|
13150
13150
|
}),
|
|
13151
13151
|
"message": zod.string()
|
|
13152
13152
|
});
|
|
@@ -13250,7 +13250,7 @@ var GetCaseTypeVersionResponse = zod.object({
|
|
|
13250
13250
|
"description": zod.string(),
|
|
13251
13251
|
"type": zod.union([zod.literal("boolean"), zod.array(zod.enum(["boolean", "null"])).min(getCaseTypeVersionResponseDataFieldsSchemaFiveItemsFourTypeTwoMin).max(getCaseTypeVersionResponseDataFieldsSchemaFiveItemsFourTypeTwoMax)])
|
|
13252
13252
|
})])
|
|
13253
|
-
})])).describe("JSON Schema properties, keyed by permanent snake_case field key. Each field is a string, number, boolean or enum, or an array of those; a nullable type
|
|
13253
|
+
})])).describe("JSON Schema properties, keyed by permanent snake_case field key. Each field is a string, number, boolean or enum, or an array of those; a nullable type allows `null`. `title` is the label people see and can change any time. Set `x_sensitive` on fields holding personal data.")
|
|
13254
13254
|
}),
|
|
13255
13255
|
"message": zod.string()
|
|
13256
13256
|
});
|
|
@@ -15722,7 +15722,7 @@ var createMcpServer = (options) => {
|
|
|
15722
15722
|
"updateCase",
|
|
15723
15723
|
{
|
|
15724
15724
|
title: "Update case",
|
|
15725
|
-
description: "Only the fields sent change
|
|
15725
|
+
description: "Only the fields sent change.",
|
|
15726
15726
|
inputSchema: {
|
|
15727
15727
|
pathParams: UpdateCaseParams,
|
|
15728
15728
|
queryParams: UpdateCaseQueryParams,
|
|
@@ -17150,4 +17150,4 @@ var transport = new StdioServerTransport();
|
|
|
17150
17150
|
server.connect(transport).then(() => {
|
|
17151
17151
|
console.error("MCP server running on stdio");
|
|
17152
17152
|
}).catch(console.error);
|
|
17153
|
-
//# sourceMappingURL=server-
|
|
17153
|
+
//# sourceMappingURL=server-2J3FHU34.js.map
|