easybill-mcp 1.0.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/LICENSE +21 -0
- package/README.md +373 -0
- package/dist/constants.d.ts +50 -0
- package/dist/constants.js +204 -0
- package/dist/constants.js.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +154 -0
- package/dist/index.js.map +1 -0
- package/dist/instructions.d.ts +11 -0
- package/dist/instructions.js +89 -0
- package/dist/instructions.js.map +1 -0
- package/dist/schemas/common.d.ts +44 -0
- package/dist/schemas/common.js +59 -0
- package/dist/schemas/common.js.map +1 -0
- package/dist/services/client.d.ts +57 -0
- package/dist/services/client.js +258 -0
- package/dist/services/client.js.map +1 -0
- package/dist/services/format.d.ts +70 -0
- package/dist/services/format.js +158 -0
- package/dist/services/format.js.map +1 -0
- package/dist/tools/catalog.d.ts +4 -0
- package/dist/tools/catalog.js +74 -0
- package/dist/tools/catalog.js.map +1 -0
- package/dist/tools/crud.d.ts +51 -0
- package/dist/tools/crud.js +152 -0
- package/dist/tools/crud.js.map +1 -0
- package/dist/tools/customers.d.ts +4 -0
- package/dist/tools/customers.js +91 -0
- package/dist/tools/customers.js.map +1 -0
- package/dist/tools/documents.d.ts +8 -0
- package/dist/tools/documents.js +326 -0
- package/dist/tools/documents.js.map +1 -0
- package/dist/tools/files.d.ts +4 -0
- package/dist/tools/files.js +108 -0
- package/dist/tools/files.js.map +1 -0
- package/dist/tools/finance.d.ts +4 -0
- package/dist/tools/finance.js +39 -0
- package/dist/tools/finance.js.map +1 -0
- package/dist/tools/meta.d.ts +10 -0
- package/dist/tools/meta.js +74 -0
- package/dist/tools/meta.js.map +1 -0
- package/dist/tools/registry.d.ts +39 -0
- package/dist/tools/registry.js +56 -0
- package/dist/tools/registry.js.map +1 -0
- package/dist/tools/search.d.ts +13 -0
- package/dist/tools/search.js +243 -0
- package/dist/tools/search.js.map +1 -0
- package/dist/tools/work.d.ts +4 -0
- package/dist/tools/work.js +76 -0
- package/dist/tools/work.js.map +1 -0
- package/package.json +58 -0
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/** Attachments and the text / PDF template catalogues. */
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { SUMMARY_FIELDS } from "../constants.js";
|
|
4
|
+
import { idSchema } from "../schemas/common.js";
|
|
5
|
+
import { buildListResponse, } from "../services/format.js";
|
|
6
|
+
import { registerCrudTools } from "./crud.js";
|
|
7
|
+
import { registerRead } from "./registry.js";
|
|
8
|
+
export function registerFileTools(server, client) {
|
|
9
|
+
registerCrudTools(server, client, {
|
|
10
|
+
singular: "attachment",
|
|
11
|
+
plural: "attachments",
|
|
12
|
+
nameSingular: "attachment",
|
|
13
|
+
namePlural: "attachments",
|
|
14
|
+
path: "/attachments",
|
|
15
|
+
defaultFields: SUMMARY_FIELDS.attachment,
|
|
16
|
+
operations: ["list", "get", "delete"],
|
|
17
|
+
listNotes: "Files stored in easybill and linked to a document, customer or project. " +
|
|
18
|
+
"This endpoint has no filters — page through the list and match on 'document_id', " +
|
|
19
|
+
"'customer_id' or 'file_name'.\n" +
|
|
20
|
+
"Use easybill_download_attachment to fetch the actual file content.",
|
|
21
|
+
bodyHint: "Attachments are uploaded as multipart form data, which this server does not expose.",
|
|
22
|
+
deleteNotes: "The file is removed from easybill and unlinked from any document.",
|
|
23
|
+
});
|
|
24
|
+
registerRead(server, {
|
|
25
|
+
name: "easybill_download_attachment",
|
|
26
|
+
title: "Download attachment",
|
|
27
|
+
description: "Download an attachment's file content and save it to a local path.\n\n" +
|
|
28
|
+
"Returns the saved file path and size in bytes. The content is NOT loaded into the " +
|
|
29
|
+
"conversation, so this is safe for large files.\n" +
|
|
30
|
+
"Find attachment IDs with easybill_list_attachments.",
|
|
31
|
+
inputSchema: {
|
|
32
|
+
id: idSchema("attachment to download"),
|
|
33
|
+
output_path: z
|
|
34
|
+
.string()
|
|
35
|
+
.min(1)
|
|
36
|
+
.describe("Absolute path to write the file to, e.g. '/Users/me/Desktop/receipt.pdf'. Parent directory must exist."),
|
|
37
|
+
},
|
|
38
|
+
}, async (args) => {
|
|
39
|
+
const outputPath = args.output_path;
|
|
40
|
+
const binary = await client.requestBinary(`/attachments/${String(args.id)}/content`, {
|
|
41
|
+
accept: "*/*",
|
|
42
|
+
});
|
|
43
|
+
const { writeFile } = await import("node:fs/promises");
|
|
44
|
+
await writeFile(outputPath, binary.data);
|
|
45
|
+
const output = {
|
|
46
|
+
saved_to: outputPath,
|
|
47
|
+
bytes: binary.data.byteLength,
|
|
48
|
+
content_type: binary.contentType,
|
|
49
|
+
attachment_id: args.id,
|
|
50
|
+
...(binary.fileName ? { original_file_name: binary.fileName } : {}),
|
|
51
|
+
};
|
|
52
|
+
return {
|
|
53
|
+
content: [
|
|
54
|
+
{
|
|
55
|
+
type: "text",
|
|
56
|
+
text: `Saved attachment ${String(args.id)} to ${outputPath} ` +
|
|
57
|
+
`(${binary.data.byteLength.toLocaleString("en-US")} bytes, ${binary.contentType}).`,
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
|
+
structuredContent: output,
|
|
61
|
+
};
|
|
62
|
+
});
|
|
63
|
+
registerCrudTools(server, client, {
|
|
64
|
+
singular: "text template",
|
|
65
|
+
plural: "text templates",
|
|
66
|
+
nameSingular: "text_template",
|
|
67
|
+
namePlural: "text_templates",
|
|
68
|
+
path: "/text-templates",
|
|
69
|
+
defaultFields: SUMMARY_FIELDS.textTemplate,
|
|
70
|
+
operations: ["list", "get"],
|
|
71
|
+
listNotes: "Reusable text blocks for document headers, footers and notes. Handy for reusing your " +
|
|
72
|
+
"standard payment terms or closing wording when creating a document.",
|
|
73
|
+
bodyHint: "Key fields: title, text.",
|
|
74
|
+
});
|
|
75
|
+
registerRead(server, {
|
|
76
|
+
name: "easybill_list_pdf_templates",
|
|
77
|
+
title: "List PDF templates",
|
|
78
|
+
description: "List the PDF layout templates configured in your easybill account.\n\n" +
|
|
79
|
+
"Pass a template's 'id' as 'pdf_template' when creating or converting a document to " +
|
|
80
|
+
"control its layout and language. The built-in values are 'DE' (German, the default) " +
|
|
81
|
+
"and 'EN' (English); anything custom uses a numeric ID.\n\n" +
|
|
82
|
+
"Note: this endpoint is not paginated and returns all templates at once.",
|
|
83
|
+
inputSchema: {
|
|
84
|
+
type: z
|
|
85
|
+
.string()
|
|
86
|
+
.optional()
|
|
87
|
+
.describe("Filter by document type, e.g. 'INVOICE' or several comma-separated ('INVOICE,OFFER')."),
|
|
88
|
+
response_format: z.enum(["markdown", "json"]).default("markdown"),
|
|
89
|
+
},
|
|
90
|
+
}, async (args) => {
|
|
91
|
+
const format = args.response_format ?? "markdown";
|
|
92
|
+
const raw = await client.request("/pdf-templates", {
|
|
93
|
+
query: { type: args.type },
|
|
94
|
+
});
|
|
95
|
+
// This endpoint is unpaginated and may answer with a bare array.
|
|
96
|
+
const items = Array.isArray(raw) ? raw : (raw?.items ?? []);
|
|
97
|
+
const list = Array.isArray(raw)
|
|
98
|
+
? { page: 1, pages: 1, limit: items.length, total: items.length, items }
|
|
99
|
+
: raw;
|
|
100
|
+
return buildListResponse({
|
|
101
|
+
list,
|
|
102
|
+
resource: "PDF templates",
|
|
103
|
+
defaultFields: SUMMARY_FIELDS.pdfTemplate,
|
|
104
|
+
format,
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=files.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files.js","sourceRoot":"","sources":["../../src/tools/files.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAG1D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEhD,OAAO,EAKL,iBAAiB,GAClB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9C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F;YACH,eAAe,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC;SAClE;KACF,EACD,KAAK,EAAE,IAAI,EAAuB,EAAE;QAClC,MAAM,MAAM,GAAI,IAAI,CAAC,eAA8C,IAAI,UAAU,CAAC;QAClF,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,OAAO,CAAoC,gBAAgB,EAAE;YACpF,KAAK,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,IAA0B,EAAE;SACjD,CAAC,CAAC;QAEH,iEAAiE;QACjE,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC;QAC5D,MAAM,IAAI,GAA0B,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC;YACpD,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE;YACxE,CAAC,CAAE,GAA6B,CAAC;QAEnC,OAAO,iBAAiB,CAAC;YACvB,IAAI;YACJ,QAAQ,EAAE,eAAe;YACzB,aAAa,EAAE,cAAc,CAAC,WAAW;YACzC,MAAM;SACP,CAAC,CAAC;IACL,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Payments recorded against documents. */
|
|
2
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
|
+
import type { EasybillClient } from "../services/client.js";
|
|
4
|
+
export declare function registerFinanceTools(server: McpServer, client: EasybillClient): void;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/** Payments recorded against documents. */
|
|
2
|
+
import { SUMMARY_FIELDS } from "../constants.js";
|
|
3
|
+
import { dateFilter, multiFilter } from "../schemas/common.js";
|
|
4
|
+
import { registerCrudTools } from "./crud.js";
|
|
5
|
+
export function registerFinanceTools(server, client) {
|
|
6
|
+
registerCrudTools(server, client, {
|
|
7
|
+
singular: "document payment",
|
|
8
|
+
plural: "document payments",
|
|
9
|
+
nameSingular: "document_payment",
|
|
10
|
+
namePlural: "document_payments",
|
|
11
|
+
path: "/document-payments",
|
|
12
|
+
defaultFields: SUMMARY_FIELDS.payment,
|
|
13
|
+
operations: ["list", "get", "create", "delete"],
|
|
14
|
+
listNotes: "Payments booked against documents. Recording a payment is what marks an invoice as paid — " +
|
|
15
|
+
"it updates the document's 'paid_amount' and 'paid_at'.\n" +
|
|
16
|
+
"To find open invoices instead, use easybill_list_documents with type='INVOICE' and paid_at='null'.\n" +
|
|
17
|
+
"Amounts are integers in cents (150 = 1.50 EUR).",
|
|
18
|
+
bodyHint: `Required: document_id and amount.
|
|
19
|
+
|
|
20
|
+
IMPORTANT: 'amount' is an INTEGER IN CENTS — 1999 means 19.99 EUR.
|
|
21
|
+
|
|
22
|
+
- document_id (integer): the invoice being paid.
|
|
23
|
+
- amount (integer, CENTS): the amount received. A partial payment is fine; easybill
|
|
24
|
+
tracks the running total in the document's 'paid_amount'.
|
|
25
|
+
- payment_at (string): date of payment, YYYY-MM-DD (Europe/Berlin). Defaults to now.
|
|
26
|
+
- type (string): free-text payment method, e.g. 'Überweisung', 'PayPal', 'Lastschrift'.
|
|
27
|
+
- reference (string): bank reference / transaction ID, useful for reconciliation.
|
|
28
|
+
- notice (string): internal note.
|
|
29
|
+
- is_overdue_fee (boolean): mark this as a late-payment fee rather than a payment on the invoice.`,
|
|
30
|
+
deleteNotes: "Removing a payment reopens the invoice by reducing its paid_amount. Use this to undo a " +
|
|
31
|
+
"mis-booked payment.",
|
|
32
|
+
filters: {
|
|
33
|
+
document_id: multiFilter("Filter by the document (invoice) the payment belongs to."),
|
|
34
|
+
reference: multiFilter("Filter by bank reference / transaction ID."),
|
|
35
|
+
payment_at: dateFilter("payment date"),
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=finance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"finance.js","sourceRoot":"","sources":["../../src/tools/finance.ts"],"names":[],"mappings":"AAAA,2CAA2C;AAG3C,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAE/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAE9C,MAAM,UAAU,oBAAoB,CAAC,MAAiB,EAAE,MAAsB;IAC5E,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE;QAChC,QAAQ,EAAE,kBAAkB;QAC5B,MAAM,EAAE,mBAAmB;QAC3B,YAAY,EAAE,kBAAkB;QAChC,UAAU,EAAE,mBAAmB;QAC/B,IAAI,EAAE,oBAAoB;QAC1B,aAAa,EAAE,cAAc,CAAC,OAAO;QACrC,UAAU,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,CAAC;QAC/C,SAAS,EACP,4FAA4F;YAC5F,0DAA0D;YAC1D,sGAAsG;YACtG,iDAAiD;QACnD,QAAQ,EAAE;;;;;;;;;;;kGAWoF;QAC9F,WAAW,EACT,yFAAyF;YACzF,qBAAqB;QACvB,OAAO,EAAE;YACP,WAAW,EAAE,WAAW,CAAC,0DAA0D,CAAC;YACpF,SAAS,EAAE,WAAW,CAAC,4CAA4C,CAAC;YACpE,UAAU,EAAE,UAAU,CAAC,cAAc,CAAC;SACvC;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server introspection.
|
|
3
|
+
*
|
|
4
|
+
* Makes the read-only/write mode discoverable: when writes are disabled the
|
|
5
|
+
* create/update/delete tools are not registered at all, and without this tool an
|
|
6
|
+
* agent could only report "no such tool" without explaining why.
|
|
7
|
+
*/
|
|
8
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
9
|
+
import type { EasybillClient } from "../services/client.js";
|
|
10
|
+
export declare function registerMetaTools(server: McpServer, client: EasybillClient): void;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server introspection.
|
|
3
|
+
*
|
|
4
|
+
* Makes the read-only/write mode discoverable: when writes are disabled the
|
|
5
|
+
* create/update/delete tools are not registered at all, and without this tool an
|
|
6
|
+
* agent could only report "no such tool" without explaining why.
|
|
7
|
+
*/
|
|
8
|
+
import { z } from "zod";
|
|
9
|
+
import { API_BASE_URL, CHARACTER_LIMIT, RATE_LIMIT_PER_MINUTE, SERVER_VERSION, WRITES_ENABLED, } from "../constants.js";
|
|
10
|
+
import { registerRead, registrationStats } from "./registry.js";
|
|
11
|
+
export function registerMetaTools(server, client) {
|
|
12
|
+
registerRead(server, {
|
|
13
|
+
name: "easybill_get_server_info",
|
|
14
|
+
title: "Get server info and connection status",
|
|
15
|
+
description: "Report this MCP server's configuration and verify the easybill API credentials work.\n\n" +
|
|
16
|
+
"Call this when a write tool appears to be missing, when you get authentication errors, " +
|
|
17
|
+
"or when you hit rate limits — it explains the current mode and limits.\n\n" +
|
|
18
|
+
"Returns: { server_version, api_base_url, writes_enabled, tools_registered, " +
|
|
19
|
+
"rate_limit_per_minute, character_limit, connection } where 'connection' reports " +
|
|
20
|
+
"whether a live test call to easybill succeeded.",
|
|
21
|
+
inputSchema: {
|
|
22
|
+
test_connection: z
|
|
23
|
+
.boolean()
|
|
24
|
+
.default(true)
|
|
25
|
+
.describe("Make one lightweight API call to verify the credentials. Costs one request against your rate limit."),
|
|
26
|
+
},
|
|
27
|
+
}, async (args) => {
|
|
28
|
+
let connection = "not tested";
|
|
29
|
+
if (args.test_connection !== false) {
|
|
30
|
+
try {
|
|
31
|
+
// Cheapest authenticated call available: one customer group.
|
|
32
|
+
await client.request("/customer-groups", { query: { limit: 1 } });
|
|
33
|
+
connection = "ok — credentials accepted by easybill";
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
const { formatApiError } = await import("../services/client.js");
|
|
37
|
+
connection = `failed — ${formatApiError(error)}`;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
const output = {
|
|
41
|
+
server_version: SERVER_VERSION,
|
|
42
|
+
api_base_url: API_BASE_URL,
|
|
43
|
+
writes_enabled: WRITES_ENABLED,
|
|
44
|
+
tools_registered: {
|
|
45
|
+
read_only: registrationStats.read,
|
|
46
|
+
write: registrationStats.write,
|
|
47
|
+
withheld_because_writes_disabled: registrationStats.skipped,
|
|
48
|
+
},
|
|
49
|
+
rate_limit_per_minute: RATE_LIMIT_PER_MINUTE,
|
|
50
|
+
character_limit: CHARACTER_LIMIT,
|
|
51
|
+
connection,
|
|
52
|
+
};
|
|
53
|
+
const modeLine = WRITES_ENABLED
|
|
54
|
+
? `Write mode is ENABLED — ${registrationStats.write} create/update/delete tools are available.`
|
|
55
|
+
: `Write mode is DISABLED (read-only). ${registrationStats.skipped} create/update/delete tools ` +
|
|
56
|
+
`are withheld. To enable them, set EASYBILL_ENABLE_WRITES=true in the server's environment ` +
|
|
57
|
+
`and restart the MCP server.`;
|
|
58
|
+
const text = [
|
|
59
|
+
`# easybill MCP server v${SERVER_VERSION}`,
|
|
60
|
+
"",
|
|
61
|
+
modeLine,
|
|
62
|
+
"",
|
|
63
|
+
`- **API**: ${API_BASE_URL}`,
|
|
64
|
+
`- **Read-only tools**: ${registrationStats.read}`,
|
|
65
|
+
`- **Write tools**: ${registrationStats.write}`,
|
|
66
|
+
`- **Rate limit (client-side throttle)**: ${RATE_LIMIT_PER_MINUTE} requests/minute`,
|
|
67
|
+
` easybill allows 10/min on PLUS and 60/min on BUSINESS — set EASYBILL_RATE_LIMIT_PER_MINUTE to match your plan.`,
|
|
68
|
+
`- **Response character limit**: ${CHARACTER_LIMIT.toLocaleString("en-US")}`,
|
|
69
|
+
`- **Connection**: ${connection}`,
|
|
70
|
+
].join("\n");
|
|
71
|
+
return { content: [{ type: "text", text }], structuredContent: output };
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=meta.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"meta.js","sourceRoot":"","sources":["../../src/tools/meta.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,YAAY,EACZ,eAAe,EACf,qBAAqB,EACrB,cAAc,EACd,cAAc,GACf,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAEhE,MAAM,UAAU,iBAAiB,CAAC,MAAiB,EAAE,MAAsB;IACzE,YAAY,CACV,MAAM,EACN;QACE,IAAI,EAAE,0BAA0B;QAChC,KAAK,EAAE,uCAAuC;QAC9C,WAAW,EACT,0FAA0F;YAC1F,yFAAyF;YACzF,4EAA4E;YAC5E,6EAA6E;YAC7E,kFAAkF;YAClF,iDAAiD;QACnD,WAAW,EAAE;YACX,eAAe,EAAE,CAAC;iBACf,OAAO,EAAE;iBACT,OAAO,CAAC,IAAI,CAAC;iBACb,QAAQ,CACP,qGAAqG,CACtG;SACJ;KACF,EACD,KAAK,EAAE,IAAI,EAAuB,EAAE;QAElC,IAAI,UAAU,GAAG,YAAY,CAAC;QAC9B,IAAI,IAAI,CAAC,eAAe,KAAK,KAAK,EAAE,CAAC;YACnC,IAAI,CAAC;gBACH,6DAA6D;gBAC7D,MAAM,MAAM,CAAC,OAAO,CAAU,kBAAkB,EAAE,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;gBAC3E,UAAU,GAAG,uCAAuC,CAAC;YACvD,CAAC;YAAC,OAAO,KAAK,EAA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
|
+
/**
|
|
2
|
+
* Tool registration helpers.
|
|
3
|
+
*
|
|
4
|
+
* `registerRead` always registers. `registerWrite` only registers when
|
|
5
|
+
* EASYBILL_ENABLE_WRITES is set, so a default install cannot mutate live
|
|
6
|
+
* accounting data and read-only sessions keep a lean tool list.
|
|
7
|
+
*/
|
|
8
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
9
|
+
import type { ZodRawShape } from "zod";
|
|
10
|
+
import { type ToolResult } from "../services/format.js";
|
|
11
|
+
export interface ToolSpec<Shape extends ZodRawShape> {
|
|
12
|
+
name: string;
|
|
13
|
+
title: string;
|
|
14
|
+
description: string;
|
|
15
|
+
inputSchema: Shape;
|
|
16
|
+
/** True for tools that delete data or are otherwise hard to undo. */
|
|
17
|
+
destructive?: boolean;
|
|
18
|
+
/** True when repeating the call has no additional effect. */
|
|
19
|
+
idempotent?: boolean;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Validated tool arguments.
|
|
23
|
+
*
|
|
24
|
+
* Deliberately loose: the CRUD factory assembles input shapes at runtime from
|
|
25
|
+
* declarative config, so there is no static shape to infer per tool. The Zod
|
|
26
|
+
* schema passed as `inputSchema` is the real validation boundary — the SDK
|
|
27
|
+
* rejects malformed calls before a handler ever runs, so handlers can read the
|
|
28
|
+
* keys their own schema declares.
|
|
29
|
+
*/
|
|
30
|
+
export type Args = Record<string, unknown>;
|
|
31
|
+
export type Handler = (args: Args) => Promise<ToolResult>;
|
|
32
|
+
/** Counts of what actually got registered, for the startup log. */
|
|
33
|
+
export declare const registrationStats: {
|
|
34
|
+
read: number;
|
|
35
|
+
write: number;
|
|
36
|
+
skipped: number;
|
|
37
|
+
};
|
|
38
|
+
export declare function registerRead<Shape extends ZodRawShape>(server: McpServer, spec: ToolSpec<Shape>, handler: Handler): void;
|
|
39
|
+
export declare function registerWrite<Shape extends ZodRawShape>(server: McpServer, spec: ToolSpec<Shape>, handler: Handler): void;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool registration helpers.
|
|
3
|
+
*
|
|
4
|
+
* `registerRead` always registers. `registerWrite` only registers when
|
|
5
|
+
* EASYBILL_ENABLE_WRITES is set, so a default install cannot mutate live
|
|
6
|
+
* accounting data and read-only sessions keep a lean tool list.
|
|
7
|
+
*/
|
|
8
|
+
import { WRITES_ENABLED } from "../constants.js";
|
|
9
|
+
import { formatApiError } from "../services/client.js";
|
|
10
|
+
import { textResult } from "../services/format.js";
|
|
11
|
+
/** Counts of what actually got registered, for the startup log. */
|
|
12
|
+
export const registrationStats = { read: 0, write: 0, skipped: 0 };
|
|
13
|
+
/** Wraps a handler so no thrown error ever escapes as a protocol-level failure. */
|
|
14
|
+
function guard(handler) {
|
|
15
|
+
return async (args) => {
|
|
16
|
+
try {
|
|
17
|
+
return await handler(args);
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
return textResult(formatApiError(error), true);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export function registerRead(server, spec, handler) {
|
|
25
|
+
server.registerTool(spec.name, {
|
|
26
|
+
title: spec.title,
|
|
27
|
+
description: spec.description,
|
|
28
|
+
inputSchema: spec.inputSchema,
|
|
29
|
+
annotations: {
|
|
30
|
+
readOnlyHint: true,
|
|
31
|
+
destructiveHint: false,
|
|
32
|
+
idempotentHint: true,
|
|
33
|
+
openWorldHint: true,
|
|
34
|
+
},
|
|
35
|
+
}, guard(handler));
|
|
36
|
+
registrationStats.read++;
|
|
37
|
+
}
|
|
38
|
+
export function registerWrite(server, spec, handler) {
|
|
39
|
+
if (!WRITES_ENABLED) {
|
|
40
|
+
registrationStats.skipped++;
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
server.registerTool(spec.name, {
|
|
44
|
+
title: spec.title,
|
|
45
|
+
description: spec.description,
|
|
46
|
+
inputSchema: spec.inputSchema,
|
|
47
|
+
annotations: {
|
|
48
|
+
readOnlyHint: false,
|
|
49
|
+
destructiveHint: spec.destructive ?? false,
|
|
50
|
+
idempotentHint: spec.idempotent ?? false,
|
|
51
|
+
openWorldHint: true,
|
|
52
|
+
},
|
|
53
|
+
}, guard(handler));
|
|
54
|
+
registrationStats.write++;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/tools/registry.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAmB,UAAU,EAAE,MAAM,uBAAuB,CAAC;AA0BpE,mEAAmE;AACnE,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;AAEnE,mFAAmF;AACnF,SAAS,KAAK,CAAC,OAAgB;IAC7B,OAAO,KAAK,EAAE,IAAU,EAAuB,EAAE;QAC/C,IAAI,CAAC;YACH,OAAO,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;QAC7B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,UAAU,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,CAAC;QACjD,CAAC;IACH,CAAC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,YAAY,CAC1B,MAAiB,EACjB,IAAqB,EACrB,OAAgB;IAEhB,MAAM,CAAC,YAAY,CACjB,IAAI,CAAC,IAAI,EACT;QACE,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,WAAW,EAAE;YACX,YAAY,EAAE,IAAI;YAClB,eAAe,EAAE,KAAK;YACtB,cAAc,EAAE,IAAI;YACpB,aAAa,EAAE,IAAI;SACpB;KACF,EACD,KAAK,CAAC,OAAO,CAAU,CACxB,CAAC;IACF,iBAAiB,CAAC,IAAI,EAAE,CAAC;AAC3B,CAAC;AAED,MAAM,UAAU,aAAa,CAC3B,MAAiB,EACjB,IAAqB,EACrB,OAAgB;IAEhB,IAAI,CAAC,cAAc,EAAE,CAAC;QACpB,iBAAiB,CAAC,OAAO,EAAE,CAAC;QAC5B,OAAO;IACT,CAAC;IACD,MAAM,CAAC,YAAY,CACjB,IAAI,CAAC,IAAI,EACT;QACE,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,WAAW,EAAE;YACX,YAAY,EAAE,KAAK;YACnB,eAAe,EAAE,IAAI,CAAC,WAAW,IAAI,KAAK;YAC1C,cAAc,EAAE,IAAI,CAAC,UAAU,IAAI,KAAK;YACxC,aAAa,EAAE,IAAI;SACpB;KACF,EACD,KAAK,CAAC,OAAO,CAAU,CACxB,CAAC;IACF,iBAAiB,CAAC,KAAK,EAAE,CAAC;AAC5B,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fuzzy customer lookup.
|
|
3
|
+
*
|
|
4
|
+
* The easybill API offers no full-text search — its customer filters match exact
|
|
5
|
+
* values only. That makes "is this company already a customer?" surprisingly hard,
|
|
6
|
+
* which is the first question to answer when processing an inbound inquiry.
|
|
7
|
+
*
|
|
8
|
+
* This tool bridges the gap: it tries cheap exact filters first, then falls back to
|
|
9
|
+
* paging the customer list and scoring candidates locally.
|
|
10
|
+
*/
|
|
11
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
12
|
+
import type { EasybillClient } from "../services/client.js";
|
|
13
|
+
export declare function registerSearchTools(server: McpServer, client: EasybillClient): void;
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fuzzy customer lookup.
|
|
3
|
+
*
|
|
4
|
+
* The easybill API offers no full-text search — its customer filters match exact
|
|
5
|
+
* values only. That makes "is this company already a customer?" surprisingly hard,
|
|
6
|
+
* which is the first question to answer when processing an inbound inquiry.
|
|
7
|
+
*
|
|
8
|
+
* This tool bridges the gap: it tries cheap exact filters first, then falls back to
|
|
9
|
+
* paging the customer list and scoring candidates locally.
|
|
10
|
+
*/
|
|
11
|
+
import { z } from "zod";
|
|
12
|
+
import { SUMMARY_FIELDS } from "../constants.js";
|
|
13
|
+
import { responseFormatSchema } from "../schemas/common.js";
|
|
14
|
+
import { selectFields, } from "../services/format.js";
|
|
15
|
+
import { registerRead } from "./registry.js";
|
|
16
|
+
/** Legal-form and filler tokens that carry no identifying weight. */
|
|
17
|
+
const NOISE_TOKENS = new Set([
|
|
18
|
+
"gmbh", "co", "kg", "ag", "ohg", "gbr", "ug", "ek", "e", "k", "mbh", "kgaa",
|
|
19
|
+
"and", "und", "the", "der", "die", "das", "haftungsbeschraenkt",
|
|
20
|
+
"ltd", "llc", "inc", "bv", "nv", "sa", "srl", "spa", "as", "ab", "oy", "aps",
|
|
21
|
+
]);
|
|
22
|
+
/** Lowercase, strip punctuation, split into meaningful tokens. */
|
|
23
|
+
function tokenize(value) {
|
|
24
|
+
return value
|
|
25
|
+
.toLowerCase()
|
|
26
|
+
.replace(/[äöüß]/g, (c) => ({ ä: "ae", ö: "oe", ü: "ue", ß: "ss" })[c] ?? c)
|
|
27
|
+
.replace(/[^a-z0-9]+/g, " ")
|
|
28
|
+
.split(" ")
|
|
29
|
+
.filter((t) => t.length > 1 && !NOISE_TOKENS.has(t));
|
|
30
|
+
}
|
|
31
|
+
/** Fields on a customer record worth matching a query against. */
|
|
32
|
+
const SEARCHABLE = [
|
|
33
|
+
"company_name",
|
|
34
|
+
"display_name",
|
|
35
|
+
"last_name",
|
|
36
|
+
"first_name",
|
|
37
|
+
"number",
|
|
38
|
+
"city",
|
|
39
|
+
"street",
|
|
40
|
+
"zip_code",
|
|
41
|
+
"vat_identifier",
|
|
42
|
+
];
|
|
43
|
+
/** Builds the haystack string for a customer, including its email addresses. */
|
|
44
|
+
function haystack(customer) {
|
|
45
|
+
const parts = [];
|
|
46
|
+
for (const key of SEARCHABLE) {
|
|
47
|
+
const value = customer[key];
|
|
48
|
+
if (typeof value === "string" && value !== "")
|
|
49
|
+
parts.push(value);
|
|
50
|
+
}
|
|
51
|
+
const emails = customer.emails;
|
|
52
|
+
if (Array.isArray(emails))
|
|
53
|
+
parts.push(...emails.filter((e) => typeof e === "string"));
|
|
54
|
+
else if (typeof emails === "string")
|
|
55
|
+
parts.push(emails);
|
|
56
|
+
return parts.join(" ");
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Scores a customer against the query tokens.
|
|
60
|
+
* 1.0 = every query token appears; 0 = nothing matches.
|
|
61
|
+
*/
|
|
62
|
+
function score(customer, queryTokens, rawQuery) {
|
|
63
|
+
const hay = haystack(customer);
|
|
64
|
+
const hayLower = hay.toLowerCase();
|
|
65
|
+
// A full substring hit is the strongest signal.
|
|
66
|
+
if (rawQuery.length >= 3 && hayLower.includes(rawQuery.toLowerCase()))
|
|
67
|
+
return 1;
|
|
68
|
+
const hayTokens = new Set(tokenize(hay));
|
|
69
|
+
if (queryTokens.length === 0 || hayTokens.size === 0)
|
|
70
|
+
return 0;
|
|
71
|
+
let hits = 0;
|
|
72
|
+
for (const token of queryTokens) {
|
|
73
|
+
// Exact token match, or a token that starts with the query token (≥4 chars).
|
|
74
|
+
if (hayTokens.has(token))
|
|
75
|
+
hits++;
|
|
76
|
+
else if (token.length >= 4 && [...hayTokens].some((h) => h.startsWith(token)))
|
|
77
|
+
hits += 0.8;
|
|
78
|
+
}
|
|
79
|
+
return hits / queryTokens.length;
|
|
80
|
+
}
|
|
81
|
+
export function registerSearchTools(server, client) {
|
|
82
|
+
registerRead(server, {
|
|
83
|
+
name: "easybill_find_customer",
|
|
84
|
+
title: "Find a customer by name, email or number (fuzzy)",
|
|
85
|
+
description: `Search for an existing customer by company name, person name, email, customer number or city.
|
|
86
|
+
|
|
87
|
+
USE THIS FIRST whenever you need to know whether someone is already a customer — for example
|
|
88
|
+
before creating an offer or invoice from an inbound inquiry. The easybill API has no full-text
|
|
89
|
+
search, so this tool combines exact filters with a local fuzzy match over the customer list.
|
|
90
|
+
|
|
91
|
+
It tolerates the differences that break exact matching: legal forms ('GmbH & Co. KG'),
|
|
92
|
+
punctuation ('M.B. MUSTERMANN' vs 'MB Mustermann'), umlauts, and word order.
|
|
93
|
+
|
|
94
|
+
Args:
|
|
95
|
+
- query (string): what to search for. A company name, surname, email or customer number.
|
|
96
|
+
- limit (number): max candidates to return, 1-25 (default 5).
|
|
97
|
+
- min_score (number): 0-1 match threshold (default 0.5). Lower it to cast a wider net.
|
|
98
|
+
- max_pages (number): how many pages of 1000 customers to scan in the fallback (default 3).
|
|
99
|
+
Each page is one API request, so keep this low on a plan with a 10 req/min limit.
|
|
100
|
+
|
|
101
|
+
Returns: { query, match_count, exact_match (boolean), candidates[] } where each candidate has
|
|
102
|
+
its easybill 'id', 'match_score' (1 = certain) and the usual summary fields.
|
|
103
|
+
|
|
104
|
+
Next steps based on the result:
|
|
105
|
+
- Exactly one strong candidate (score 1) -> use its 'id' as customer_id.
|
|
106
|
+
- Several candidates -> show them to the user and ask which one, do NOT guess.
|
|
107
|
+
- No candidates -> the customer does not exist yet. Create it with easybill_create_customer,
|
|
108
|
+
then use the returned 'id'.
|
|
109
|
+
|
|
110
|
+
Examples:
|
|
111
|
+
- "Is Mustermann Handels GmbH & Co. KG already a customer?" -> query="Mustermann Handels GmbH & Co. KG"
|
|
112
|
+
- "Find the customer with email einkauf@example.com" -> query="einkauf@example.com"
|
|
113
|
+
- "Look up customer number 10023" -> query="10023"`,
|
|
114
|
+
inputSchema: {
|
|
115
|
+
query: z
|
|
116
|
+
.string()
|
|
117
|
+
.min(2, "Query must be at least 2 characters")
|
|
118
|
+
.max(200)
|
|
119
|
+
.describe("Company name, person name, email address, customer number or city."),
|
|
120
|
+
limit: z.number().int().min(1).max(25).default(5).describe("Max candidates to return."),
|
|
121
|
+
min_score: z
|
|
122
|
+
.number()
|
|
123
|
+
.min(0)
|
|
124
|
+
.max(1)
|
|
125
|
+
.default(0.5)
|
|
126
|
+
.describe("Minimum match score, 0-1. Lower for a wider net."),
|
|
127
|
+
max_pages: z
|
|
128
|
+
.number()
|
|
129
|
+
.int()
|
|
130
|
+
.min(1)
|
|
131
|
+
.max(10)
|
|
132
|
+
.default(3)
|
|
133
|
+
.describe("Pages of 1000 customers to scan in the fuzzy fallback. Each costs 1 request."),
|
|
134
|
+
response_format: responseFormatSchema,
|
|
135
|
+
},
|
|
136
|
+
}, async (args) => {
|
|
137
|
+
const query = args.query.trim();
|
|
138
|
+
const limit = args.limit;
|
|
139
|
+
const minScore = args.min_score;
|
|
140
|
+
const maxPages = args.max_pages;
|
|
141
|
+
const format = args.response_format ?? "markdown";
|
|
142
|
+
const queryTokens = tokenize(query);
|
|
143
|
+
const looksLikeEmail = query.includes("@");
|
|
144
|
+
const looksLikeNumber = /^\d+$/.test(query);
|
|
145
|
+
// --- Phase 1: cheap exact filters (1 request each, only where plausible) ---
|
|
146
|
+
const exactAttempts = [];
|
|
147
|
+
if (looksLikeEmail)
|
|
148
|
+
exactAttempts.push({ field: "emails", value: query });
|
|
149
|
+
else if (looksLikeNumber)
|
|
150
|
+
exactAttempts.push({ field: "number", value: query });
|
|
151
|
+
else
|
|
152
|
+
exactAttempts.push({ field: "company_name", value: query });
|
|
153
|
+
for (const attempt of exactAttempts) {
|
|
154
|
+
const hit = await client.request("/customers", {
|
|
155
|
+
query: { [attempt.field]: attempt.value, limit: limit },
|
|
156
|
+
});
|
|
157
|
+
const items = hit?.items ?? [];
|
|
158
|
+
if (items.length > 0) {
|
|
159
|
+
const candidates = items.slice(0, limit).map((c) => ({
|
|
160
|
+
...selectFields(c, SUMMARY_FIELDS.customer),
|
|
161
|
+
match_score: 1,
|
|
162
|
+
matched_by: `exact ${attempt.field}`,
|
|
163
|
+
}));
|
|
164
|
+
return render(query, candidates, true, format, `exact match on ${attempt.field}`);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
// --- Phase 2: page the list and score locally ---
|
|
168
|
+
const scored = [];
|
|
169
|
+
let pagesScanned = 0;
|
|
170
|
+
let totalCustomers = 0;
|
|
171
|
+
for (let page = 1; page <= maxPages; page++) {
|
|
172
|
+
const list = await client.request("/customers", {
|
|
173
|
+
query: { limit: 1000, page },
|
|
174
|
+
});
|
|
175
|
+
pagesScanned++;
|
|
176
|
+
totalCustomers = list?.total ?? 0;
|
|
177
|
+
for (const customer of list?.items ?? []) {
|
|
178
|
+
const value = score(customer, queryTokens, query);
|
|
179
|
+
if (value >= minScore)
|
|
180
|
+
scored.push({ customer, value });
|
|
181
|
+
}
|
|
182
|
+
if (page >= (list?.pages ?? 1))
|
|
183
|
+
break;
|
|
184
|
+
}
|
|
185
|
+
scored.sort((a, b) => b.value - a.value);
|
|
186
|
+
const candidates = scored.slice(0, limit).map(({ customer, value }) => ({
|
|
187
|
+
...selectFields(customer, SUMMARY_FIELDS.customer),
|
|
188
|
+
match_score: Math.round(value * 100) / 100,
|
|
189
|
+
matched_by: "fuzzy",
|
|
190
|
+
}));
|
|
191
|
+
const scanNote = `scanned ${pagesScanned} page(s), ${totalCustomers} customers total` +
|
|
192
|
+
(pagesScanned * 1000 < totalCustomers
|
|
193
|
+
? ` — NOT all customers were scanned, raise 'max_pages' to widen the search`
|
|
194
|
+
: "");
|
|
195
|
+
return render(query, candidates, false, format, scanNote);
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
/** Shared rendering for both search phases. */
|
|
199
|
+
function render(query, candidates, exact, format, note) {
|
|
200
|
+
const output = {
|
|
201
|
+
query,
|
|
202
|
+
match_count: candidates.length,
|
|
203
|
+
exact_match: exact,
|
|
204
|
+
search_note: note,
|
|
205
|
+
candidates,
|
|
206
|
+
};
|
|
207
|
+
if (candidates.length === 0) {
|
|
208
|
+
const text = `No customer found matching "${query}" (${note}).\n\n` +
|
|
209
|
+
`This customer most likely does not exist in easybill yet. ` +
|
|
210
|
+
`To proceed, create it with easybill_create_customer (required: last_name AND company_name — ` +
|
|
211
|
+
`send an empty string for whichever does not apply), then use the returned 'id' as customer_id.\n\n` +
|
|
212
|
+
`If you expected a match, try a shorter query (just the distinctive word), or lower 'min_score'.`;
|
|
213
|
+
return { content: [{ type: "text", text }], structuredContent: output };
|
|
214
|
+
}
|
|
215
|
+
if (format === "json") {
|
|
216
|
+
return { content: [{ type: "text", text: JSON.stringify(output, null, 2) }], structuredContent: output };
|
|
217
|
+
}
|
|
218
|
+
const lines = [
|
|
219
|
+
`# Customer search: "${query}"`,
|
|
220
|
+
"",
|
|
221
|
+
`${candidates.length} candidate(s) — ${note}`,
|
|
222
|
+
"",
|
|
223
|
+
];
|
|
224
|
+
for (const c of candidates) {
|
|
225
|
+
const label = c.display_name ?? c.company_name ?? `${String(c.last_name ?? "")}`.trim();
|
|
226
|
+
lines.push(`## ${String(label || "(unnamed)")} — id ${String(c.id)} (score ${String(c.match_score)})`);
|
|
227
|
+
for (const key of ["number", "company_name", "first_name", "last_name", "emails", "street", "zip_code", "city", "country"]) {
|
|
228
|
+
const value = c[key];
|
|
229
|
+
if (value === undefined || value === null || value === "")
|
|
230
|
+
continue;
|
|
231
|
+
lines.push(`- **${key}**: ${Array.isArray(value) ? value.join(", ") : String(value)}`);
|
|
232
|
+
}
|
|
233
|
+
lines.push("");
|
|
234
|
+
}
|
|
235
|
+
if (candidates.length > 1) {
|
|
236
|
+
lines.push("> Several customers matched. Confirm which one is meant before creating a document — do not guess.");
|
|
237
|
+
}
|
|
238
|
+
else if (candidates[0]?.match_score !== 1) {
|
|
239
|
+
lines.push("> This is a fuzzy match, not a certain one. Verify it is the right customer before using its id.");
|
|
240
|
+
}
|
|
241
|
+
return { content: [{ type: "text", text: lines.join("\n") }], structuredContent: output };
|
|
242
|
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