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,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic CRUD tool factory.
|
|
3
|
+
*
|
|
4
|
+
* Most easybill resources expose the same five operations over the same
|
|
5
|
+
* pagination envelope, so they are generated from a declarative config here
|
|
6
|
+
* instead of being hand-written five times per resource. Resource-specific
|
|
7
|
+
* behaviour (document actions, downloads, sending) lives in its own module.
|
|
8
|
+
*/
|
|
9
|
+
import { z } from "zod";
|
|
10
|
+
import { buildListResponse, buildMutationResponse, buildRecordResponse, textResult, } from "../services/format.js";
|
|
11
|
+
import { dataSchema, idSchema, listBaseShape, recordBaseShape } from "../schemas/common.js";
|
|
12
|
+
import { registerRead, registerWrite } from "./registry.js";
|
|
13
|
+
/** Reads the standard shared params off an args bag. */
|
|
14
|
+
function readCommon(args) {
|
|
15
|
+
const fields = args.fields;
|
|
16
|
+
const format = args.response_format ?? "markdown";
|
|
17
|
+
return { ...(fields ? { fields } : {}), format };
|
|
18
|
+
}
|
|
19
|
+
/** Collects declared filter values out of the args bag into a query object. */
|
|
20
|
+
function readFilters(args, filters) {
|
|
21
|
+
const query = {};
|
|
22
|
+
if (!filters)
|
|
23
|
+
return query;
|
|
24
|
+
for (const key of Object.keys(filters)) {
|
|
25
|
+
const value = args[key];
|
|
26
|
+
if (value === undefined || value === null || value === "")
|
|
27
|
+
continue;
|
|
28
|
+
query[key] = value;
|
|
29
|
+
}
|
|
30
|
+
return query;
|
|
31
|
+
}
|
|
32
|
+
/** Builds the collection path, honouring a nested parent if configured. */
|
|
33
|
+
function collectionPath(config, args) {
|
|
34
|
+
if (!config.parent)
|
|
35
|
+
return config.path;
|
|
36
|
+
const parentId = args[config.parent.param];
|
|
37
|
+
return `${config.parent.path(parentId)}${config.path}`;
|
|
38
|
+
}
|
|
39
|
+
const FIELDS_NOTE = "Returns a compact field set by default; pass 'fields' for specific columns or ['all'] for everything.";
|
|
40
|
+
export function registerCrudTools(server, client, config) {
|
|
41
|
+
const { singular, plural, namePlural, nameSingular, defaultFields, operations, filters, parent, } = config;
|
|
42
|
+
const parentShape = parent
|
|
43
|
+
? { [parent.param]: z.number().int().positive().describe(parent.description) }
|
|
44
|
+
: {};
|
|
45
|
+
if (operations.includes("list")) {
|
|
46
|
+
registerRead(server, {
|
|
47
|
+
name: `easybill_list_${namePlural}`,
|
|
48
|
+
title: `List ${plural}`,
|
|
49
|
+
description: `List ${plural} from easybill with optional filters and pagination.\n\n` +
|
|
50
|
+
`${config.listNotes ? `${config.listNotes}\n\n` : ""}` +
|
|
51
|
+
`${FIELDS_NOTE}\n\n` +
|
|
52
|
+
`Returns: { total, count, page, pages, has_more, next_page, items[] }.\n` +
|
|
53
|
+
`Use 'next_page' to continue paging. Monetary values are integers in cents (150 = 1.50 EUR).`,
|
|
54
|
+
inputSchema: { ...parentShape, ...listBaseShape, ...(filters ?? {}) },
|
|
55
|
+
}, async (args) => {
|
|
56
|
+
const { fields, format } = readCommon(args);
|
|
57
|
+
const filterQuery = readFilters(args, filters);
|
|
58
|
+
const list = await client.request(collectionPath(config, args), {
|
|
59
|
+
query: { limit: args.limit, page: args.page, ...filterQuery },
|
|
60
|
+
});
|
|
61
|
+
return buildListResponse({
|
|
62
|
+
list,
|
|
63
|
+
resource: plural,
|
|
64
|
+
defaultFields,
|
|
65
|
+
...(fields ? { fields } : {}),
|
|
66
|
+
format,
|
|
67
|
+
filters: filterQuery,
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
if (operations.includes("get")) {
|
|
72
|
+
registerRead(server, {
|
|
73
|
+
name: `easybill_get_${nameSingular}`,
|
|
74
|
+
title: `Get ${singular}`,
|
|
75
|
+
description: `Fetch one ${singular} by its numeric easybill ID, returning all fields by default.\n\n` +
|
|
76
|
+
`Use easybill_list_${namePlural} first if you only know a name or number.\n` +
|
|
77
|
+
`Pass 'fields' to narrow the response. Monetary values are integers in cents (150 = 1.50 EUR).`,
|
|
78
|
+
inputSchema: { ...parentShape, id: idSchema(singular), ...recordBaseShape },
|
|
79
|
+
}, async (args) => {
|
|
80
|
+
const { fields, format } = readCommon(args);
|
|
81
|
+
const record = await client.request(`${collectionPath(config, args)}/${String(args.id)}`);
|
|
82
|
+
return buildRecordResponse({
|
|
83
|
+
record,
|
|
84
|
+
resource: singular,
|
|
85
|
+
defaultFields,
|
|
86
|
+
...(fields ? { fields } : {}),
|
|
87
|
+
format,
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
if (operations.includes("create")) {
|
|
92
|
+
registerWrite(server, {
|
|
93
|
+
name: `easybill_create_${nameSingular}`,
|
|
94
|
+
title: `Create ${singular}`,
|
|
95
|
+
description: `Create a new ${singular} in easybill.\n\n` +
|
|
96
|
+
`${config.createNotes ? `${config.createNotes}\n\n` : ""}` +
|
|
97
|
+
`${config.bodyHint}\n\n` +
|
|
98
|
+
`Returns the created ${singular} including its new 'id'.`,
|
|
99
|
+
inputSchema: {
|
|
100
|
+
...parentShape,
|
|
101
|
+
data: dataSchema(`The ${singular} to create. ${config.bodyHint}`),
|
|
102
|
+
response_format: recordBaseShape.response_format,
|
|
103
|
+
},
|
|
104
|
+
}, async (args) => {
|
|
105
|
+
const { format } = readCommon(args);
|
|
106
|
+
const record = await client.request(collectionPath(config, args), {
|
|
107
|
+
method: "POST",
|
|
108
|
+
body: args.data,
|
|
109
|
+
});
|
|
110
|
+
return buildMutationResponse("Created", singular, record, format, defaultFields);
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
if (operations.includes("update")) {
|
|
114
|
+
registerWrite(server, {
|
|
115
|
+
name: `easybill_update_${nameSingular}`,
|
|
116
|
+
title: `Update ${singular}`,
|
|
117
|
+
description: `Update an existing ${singular}. Only the fields present in 'data' are changed.\n\n` +
|
|
118
|
+
`${config.bodyHint}\n\n` +
|
|
119
|
+
`Fetch the ${singular} first with easybill_get_${nameSingular} to see current values.\n` +
|
|
120
|
+
`Returns the updated ${singular}.`,
|
|
121
|
+
inputSchema: {
|
|
122
|
+
...parentShape,
|
|
123
|
+
id: idSchema(singular),
|
|
124
|
+
data: dataSchema(`Fields to change on this ${singular}. ${config.bodyHint}`),
|
|
125
|
+
response_format: recordBaseShape.response_format,
|
|
126
|
+
},
|
|
127
|
+
idempotent: true,
|
|
128
|
+
}, async (args) => {
|
|
129
|
+
const { format } = readCommon(args);
|
|
130
|
+
const record = await client.request(`${collectionPath(config, args)}/${String(args.id)}`, { method: "PUT", body: args.data });
|
|
131
|
+
return buildMutationResponse("Updated", singular, record, format, defaultFields);
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
if (operations.includes("delete")) {
|
|
135
|
+
registerWrite(server, {
|
|
136
|
+
name: `easybill_delete_${nameSingular}`,
|
|
137
|
+
title: `Delete ${singular}`,
|
|
138
|
+
description: `Permanently delete a ${singular} from easybill. This cannot be undone.\n\n` +
|
|
139
|
+
`${config.deleteNotes ? `${config.deleteNotes}\n\n` : ""}` +
|
|
140
|
+
`Confirm the target with easybill_get_${nameSingular} before calling this.`,
|
|
141
|
+
inputSchema: { ...parentShape, id: idSchema(singular) },
|
|
142
|
+
destructive: true,
|
|
143
|
+
idempotent: true,
|
|
144
|
+
}, async (args) => {
|
|
145
|
+
await client.request(`${collectionPath(config, args)}/${String(args.id)}`, {
|
|
146
|
+
method: "DELETE",
|
|
147
|
+
});
|
|
148
|
+
return textResult(`Deleted ${singular} with id ${String(args.id)}.`);
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
//# sourceMappingURL=crud.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crud.js","sourceRoot":"","sources":["../../src/tools/crud.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAKL,iBAAiB,EACjB,qBAAqB,EACrB,mBAAmB,EACnB,UAAU,GAC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EAAE,IAAI;YACjB,UAAU,EAAE,IAAI;SACjB,EACD,KAAK,EAAE,IAAI,EAAuB,EAAE;YAChC,MAAM,MAAM,CAAC,OAAO,CAAO,GAAG,cAAc,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE;gBACjF,MAAM,EAAE,QAAQ;aACjB,CAAC,CAAC;YACH,OAAO,UAAU,CAAC,WAAW,QAAQ,YAAY,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;QACvE,CAAC,CACF,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Customers, their contact persons, and customer groups. */
|
|
2
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
|
+
import type { EasybillClient } from "../services/client.js";
|
|
4
|
+
export declare function registerCustomerTools(server: McpServer, client: EasybillClient): void;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/** Customers, their contact persons, and customer groups. */
|
|
2
|
+
import { SUMMARY_FIELDS } from "../constants.js";
|
|
3
|
+
import { dateFilter, multiFilter } from "../schemas/common.js";
|
|
4
|
+
import { registerCrudTools } from "./crud.js";
|
|
5
|
+
const CUSTOMER_BODY_HINT = `Required: last_name AND company_name (send an empty string for whichever does not apply —
|
|
6
|
+
a company customer typically has company_name set and last_name empty, and vice versa).
|
|
7
|
+
|
|
8
|
+
Key fields:
|
|
9
|
+
- company_name, salutation, title, first_name, last_name
|
|
10
|
+
- street, suffix_1, suffix_2, zip_code, city, state, country (ISO 2-letter, e.g. 'DE')
|
|
11
|
+
- emails (array of strings), phone_1, phone_2, mobile, fax, internet
|
|
12
|
+
- number (string): your own customer number. easybill assigns one if omitted.
|
|
13
|
+
- group_id (integer): customer group. List them with easybill_list_customer_groups.
|
|
14
|
+
- vat_identifier (string): VAT ID / USt-IdNr., needed for EU B2B reverse-charge invoicing.
|
|
15
|
+
- tax_number (string), personal (boolean), note, info_1, info_2
|
|
16
|
+
- Delivery address: delivery_company_name, delivery_first_name, delivery_last_name,
|
|
17
|
+
delivery_street, delivery_zip_code, delivery_city, delivery_country
|
|
18
|
+
- Bank details: bank_name, bank_iban, bank_bic, bank_account_owner
|
|
19
|
+
- SEPA: sepa_agreement, sepa_agreement_date, sepa_mandate_reference
|
|
20
|
+
- grace_period (integer): default payment term in days for this customer's invoices
|
|
21
|
+
- cash_discount + cash_discount_type ('PERCENT'|'AMOUNT'), sale_price_level (1-10)
|
|
22
|
+
- archived (boolean)
|
|
23
|
+
|
|
24
|
+
Monetary values are integers in cents (150 = 1.50 EUR).`;
|
|
25
|
+
const CONTACT_BODY_HINT = `Required: street AND city.
|
|
26
|
+
|
|
27
|
+
Key fields: salutation, title, first_name, last_name, company_name, department,
|
|
28
|
+
street, suffix_1, suffix_2, zip_code, city, state, country (ISO code),
|
|
29
|
+
emails (array of strings), phone_1, phone_2, mobile, fax, note, personal (boolean).
|
|
30
|
+
|
|
31
|
+
Contacts are the individual people at a customer. A document can reference one
|
|
32
|
+
via its 'contact_id' field.`;
|
|
33
|
+
export function registerCustomerTools(server, client) {
|
|
34
|
+
registerCrudTools(server, client, {
|
|
35
|
+
singular: "customer",
|
|
36
|
+
plural: "customers",
|
|
37
|
+
nameSingular: "customer",
|
|
38
|
+
namePlural: "customers",
|
|
39
|
+
path: "/customers",
|
|
40
|
+
defaultFields: SUMMARY_FIELDS.customer,
|
|
41
|
+
operations: ["list", "get", "create", "update", "delete"],
|
|
42
|
+
listNotes: "NOTE: easybill has no fuzzy full-text customer search. The filters below match exact " +
|
|
43
|
+
"values (though each accepts several comma-separated values). To find a customer by a " +
|
|
44
|
+
"partial name, filter on company_name or last_name with the exact spelling, or page " +
|
|
45
|
+
"through the list and match locally.",
|
|
46
|
+
bodyHint: CUSTOMER_BODY_HINT,
|
|
47
|
+
deleteNotes: "Deleting a customer does not delete their documents, but those documents keep only " +
|
|
48
|
+
"a stored snapshot of the customer data.",
|
|
49
|
+
filters: {
|
|
50
|
+
company_name: multiFilter("Filter by exact company name."),
|
|
51
|
+
last_name: multiFilter("Filter by exact last name."),
|
|
52
|
+
first_name: multiFilter("Filter by exact first name."),
|
|
53
|
+
emails: multiFilter("Filter by email address."),
|
|
54
|
+
number: multiFilter("Filter by your customer number."),
|
|
55
|
+
country: multiFilter("Filter by country (ISO 2-letter code, e.g. 'DE' or 'DE,AT,CH')."),
|
|
56
|
+
zip_code: multiFilter("Filter by postal code."),
|
|
57
|
+
group_id: multiFilter("Filter by customer group ID."),
|
|
58
|
+
additional_group_id: multiFilter("Filter by an additional customer group ID."),
|
|
59
|
+
created_at: dateFilter("creation date"),
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
registerCrudTools(server, client, {
|
|
63
|
+
singular: "contact",
|
|
64
|
+
plural: "contacts",
|
|
65
|
+
nameSingular: "contact",
|
|
66
|
+
namePlural: "contacts",
|
|
67
|
+
path: "/contacts",
|
|
68
|
+
defaultFields: SUMMARY_FIELDS.contact,
|
|
69
|
+
operations: ["list", "get", "create", "update", "delete"],
|
|
70
|
+
listNotes: "Contacts are always scoped to one customer, so 'customer_id' is required.",
|
|
71
|
+
bodyHint: CONTACT_BODY_HINT,
|
|
72
|
+
parent: {
|
|
73
|
+
param: "customer_id",
|
|
74
|
+
path: (id) => `/customers/${String(id)}`,
|
|
75
|
+
description: "The numeric ID of the customer whose contacts these are. Find it with easybill_list_customers.",
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
registerCrudTools(server, client, {
|
|
79
|
+
singular: "customer group",
|
|
80
|
+
plural: "customer groups",
|
|
81
|
+
nameSingular: "customer_group",
|
|
82
|
+
namePlural: "customer_groups",
|
|
83
|
+
path: "/customer-groups",
|
|
84
|
+
defaultFields: SUMMARY_FIELDS.customerGroup,
|
|
85
|
+
operations: ["list", "get"],
|
|
86
|
+
listNotes: "Customer groups classify customers and can carry their own pricing level. " +
|
|
87
|
+
"Use a group's 'id' as 'group_id' when creating or filtering customers.",
|
|
88
|
+
bodyHint: "Key fields: name, display_name, description, number.",
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=customers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"customers.js","sourceRoot":"","sources":["../../src/tools/customers.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAG7D,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,kBAAkB,GAAG;;;;;;;;;;;;;;;;;;;wDAmB6B,CAAC;AAEzD,MAAM,iBAAiB,GAAG;;;;;;;4BAOE,CAAC;AAE7B,MAAM,UAAU,qBAAqB,CAAC,MAAiB,EAAE,MAAsB;IAC7E,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE;QAChC,QAAQ,EAAE,UAAU;QACpB,MAAM,EAAE,WAAW;QACnB,YAAY,EAAE,UAAU;QACxB,UAAU,EAAE,WAAW;QACvB,IAAI,EAAE,YAAY;QAClB,aAAa,EAAE,cAAc,CAAC,QAAQ;QACtC,UAAU,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC;QACzD,SAAS,EACP,uFAAuF;YACvF,uFAAuF;YACvF,qFAAqF;YACrF,qCAAqC;QACvC,QAAQ,EAAE,kBAAkB;QAC5B,WAAW,EACT,qFAAqF;YACrF,yCAAyC;QAC3C,OAAO,EAAE;YACP,YAAY,EAAE,WAAW,CAAC,+BAA+B,CAAC;YAC1D,SAAS,EAAE,WAAW,CAAC,4BAA4B,CAAC;YACpD,UAAU,EAAE,WAAW,CAAC,6BAA6B,CAAC;YACtD,MAAM,EAAE,WAAW,CAAC,0BAA0B,CAAC;YAC/C,MAAM,EAAE,WAAW,CAA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veries, orders and friends.
|
|
3
|
+
* The core of the easybill API — CRUD plus the lifecycle actions
|
|
4
|
+
* (complete, cancel, convert, send, download).
|
|
5
|
+
*/
|
|
6
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
7
|
+
import type { EasybillClient } from "../services/client.js";
|
|
8
|
+
export declare function registerDocumentTools(server: McpServer, client: EasybillClient): void;
|
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Documents: invoices, offers, credit notes, deliveries, orders and friends.
|
|
3
|
+
* The core of the easybill API — CRUD plus the lifecycle actions
|
|
4
|
+
* (complete, cancel, convert, send, download).
|
|
5
|
+
*/
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
import { CONVERTIBLE_TYPES, DATE_RANGE_HINT, DOCUMENT_TYPES, SUMMARY_FIELDS, } from "../constants.js";
|
|
8
|
+
import { dateFilter, idSchema, multiFilter } from "../schemas/common.js";
|
|
9
|
+
import { buildListResponse, buildMutationResponse, } from "../services/format.js";
|
|
10
|
+
import { registerCrudTools } from "./crud.js";
|
|
11
|
+
import { registerRead, registerWrite } from "./registry.js";
|
|
12
|
+
/**
|
|
13
|
+
* The money-in-cents rule is the single most common source of wrong invoices,
|
|
14
|
+
* so it is repeated in every tool description that touches an amount.
|
|
15
|
+
*/
|
|
16
|
+
const MONEY_RULE = "IMPORTANT: all monetary values are INTEGERS IN CENTS — 150 means 1.50 EUR, " +
|
|
17
|
+
"so 19.99 EUR must be sent as 1999. Never send decimal euros.";
|
|
18
|
+
/**
|
|
19
|
+
* Prepended to the create-document description. An agent handed an inbound inquiry
|
|
20
|
+
* will otherwise reach for this tool (or worse, list documents) before it has
|
|
21
|
+
* established who the customer is.
|
|
22
|
+
*/
|
|
23
|
+
const CREATE_WORKFLOW = `WORKFLOW — do this in order. A document needs a customer_id, so resolve the customer FIRST:
|
|
24
|
+
|
|
25
|
+
1. easybill_find_customer — does this customer already exist? (fuzzy name/email search)
|
|
26
|
+
2. easybill_create_customer — only if step 1 found nothing
|
|
27
|
+
3. this tool — creates a DRAFT document
|
|
28
|
+
4. show the draft to the user for review
|
|
29
|
+
5. easybill_complete_document — assigns the official number and locks it
|
|
30
|
+
6. easybill_send_document — only when explicitly asked
|
|
31
|
+
|
|
32
|
+
Do NOT call easybill_list_documents to orient yourself first — it cannot tell you whether
|
|
33
|
+
the customer exists, and it wastes requests against a low rate limit.
|
|
34
|
+
|
|
35
|
+
If prices were not given to you, do not invent them: look up articles with
|
|
36
|
+
easybill_list_positions and reference them via 'position_id', or ask the user.`;
|
|
37
|
+
const DOCUMENT_BODY_HINT = `${MONEY_RULE}
|
|
38
|
+
|
|
39
|
+
Key fields:
|
|
40
|
+
- type (string): one of ${DOCUMENT_TYPES.join(", ")}. Defaults to INVOICE. Can only be set on create.
|
|
41
|
+
- customer_id (integer): the easybill customer this document belongs to. Look it up with easybill_list_customers.
|
|
42
|
+
- document_date (string): YYYY-MM-DD, timezone Europe/Berlin.
|
|
43
|
+
- title (string), text (string), text_prefix (string): heading and body copy.
|
|
44
|
+
- items (array): the line items. Each item accepts:
|
|
45
|
+
description (string), quantity (number), unit (string),
|
|
46
|
+
single_price_net or single_price_gross (integer, CENTS),
|
|
47
|
+
vat_percent (number, default 19), discount (number), discount_type ('PERCENT'|'AMOUNT'),
|
|
48
|
+
position_id (integer — reference an existing article and inherit its values),
|
|
49
|
+
number (string), position (integer, ordering).
|
|
50
|
+
- calc_vat_from (0|1): 0 = prices are net (default), 1 = prices are gross.
|
|
51
|
+
- currency (string): ISO code, default EUR.
|
|
52
|
+
- discount (string) + discount_type ('PERCENT'|'AMOUNT'): document-level discount.
|
|
53
|
+
- grace_period (integer): days until due. Set this instead of due_date, which is derived.
|
|
54
|
+
- pdf_template (string): null/'DE' for German, 'EN' for English, or a numeric template ID.
|
|
55
|
+
- vat_option (string): NULL, nStb, nStbUstID, nStbNoneUstID, nStbIm, revc, IG, AL, sStfr, smallBusiness.
|
|
56
|
+
- project_id (integer), ref_id (string), external_id (string), order_number (string).
|
|
57
|
+
- status (string): only for DELIVERY, ORDER, CHARGE or OFFER — ACCEPT, DONE, DROPSHIPPING or CANCEL.
|
|
58
|
+
|
|
59
|
+
Read-only fields you cannot set directly: id, number, amount, amount_net, due_date,
|
|
60
|
+
is_draft (use easybill_complete_document), paid_amount, paid_at.
|
|
61
|
+
|
|
62
|
+
New documents are created as drafts. Call easybill_complete_document to finalise one
|
|
63
|
+
and have easybill assign its official document number.`;
|
|
64
|
+
export function registerDocumentTools(server, client) {
|
|
65
|
+
registerCrudTools(server, client, {
|
|
66
|
+
singular: "document",
|
|
67
|
+
plural: "documents",
|
|
68
|
+
nameSingular: "document",
|
|
69
|
+
namePlural: "documents",
|
|
70
|
+
path: "/documents",
|
|
71
|
+
defaultFields: SUMMARY_FIELDS.document,
|
|
72
|
+
operations: ["list", "get", "create", "update", "delete"],
|
|
73
|
+
listNotes: "Covers every document type: invoices, offers, credit notes, reminders, deliveries, orders.\n\n" +
|
|
74
|
+
"NOT the right tool for: finding out whether a customer exists (use easybill_find_customer), " +
|
|
75
|
+
"or orienting yourself before creating a document (see easybill_create_document). " +
|
|
76
|
+
"Only call this when you actually need to read existing documents, and always with a filter.\n\n" +
|
|
77
|
+
"Common recipes:\n" +
|
|
78
|
+
"- Unpaid invoices: type='INVOICE', paid_at='null'\n" +
|
|
79
|
+
"- Revenue in a period: type='INVOICE', document_date='2025-01-01,2025-12-31'\n" +
|
|
80
|
+
"- A customer's history: customer_id=<id>\n" +
|
|
81
|
+
"- Exclude drafts: is_draft='0' - exclude cancelled: cancel_id='null'",
|
|
82
|
+
bodyHint: DOCUMENT_BODY_HINT,
|
|
83
|
+
createNotes: CREATE_WORKFLOW,
|
|
84
|
+
deleteNotes: "Completed (non-draft) invoices usually cannot be deleted for legal reasons — " +
|
|
85
|
+
"cancel them with easybill_cancel_document instead, which creates a proper STORNO document.",
|
|
86
|
+
filters: {
|
|
87
|
+
type: z
|
|
88
|
+
.string()
|
|
89
|
+
.optional()
|
|
90
|
+
.describe(`Filter by document type. One of ${DOCUMENT_TYPES.join(", ")}, or several comma-separated (e.g. 'INVOICE,CREDIT').`),
|
|
91
|
+
customer_id: multiFilter("Filter by customer ID."),
|
|
92
|
+
project_id: multiFilter("Filter by project ID."),
|
|
93
|
+
number: multiFilter("Filter by document number (the official invoice number)."),
|
|
94
|
+
title: z.string().optional().describe("Filter by document title."),
|
|
95
|
+
status: z
|
|
96
|
+
.string()
|
|
97
|
+
.optional()
|
|
98
|
+
.describe("Filter by status (ACCEPT, DONE, DROPSHIPPING, CANCEL). Not all types have one."),
|
|
99
|
+
is_draft: z
|
|
100
|
+
.enum(["0", "1"])
|
|
101
|
+
.optional()
|
|
102
|
+
.describe("'0' = only completed documents, '1' = only drafts."),
|
|
103
|
+
is_archive: z.enum(["0", "1"]).optional().describe("'0' = not archived, '1' = archived only."),
|
|
104
|
+
document_date: dateFilter("document date"),
|
|
105
|
+
paid_at: z
|
|
106
|
+
.string()
|
|
107
|
+
.optional()
|
|
108
|
+
.describe(`Filter by payment date. ${DATE_RANGE_HINT}. Use the literal string 'null' to find all UNPAID documents.`),
|
|
109
|
+
edited_at: dateFilter("last edit date"),
|
|
110
|
+
cancel_id: multiFilter("Filter by the ID of the cancelling document. Use the literal string 'null' for all documents that are NOT cancelled."),
|
|
111
|
+
ref_id: z.string().optional().describe("Filter by reference ID."),
|
|
112
|
+
vat_country: z.string().optional().describe("Filter by VAT country (ISO 2-letter code)."),
|
|
113
|
+
shipping_country: z.string().optional().describe("Filter by shipping country (ISO code)."),
|
|
114
|
+
fulfillment_country: z
|
|
115
|
+
.string()
|
|
116
|
+
.optional()
|
|
117
|
+
.describe("Filter by fulfillment country (ISO code)."),
|
|
118
|
+
},
|
|
119
|
+
});
|
|
120
|
+
const format = (args) => args.response_format ?? "markdown";
|
|
121
|
+
registerWrite(server, {
|
|
122
|
+
name: "easybill_complete_document",
|
|
123
|
+
title: "Complete document",
|
|
124
|
+
description: "Finalise a draft document. easybill assigns the official document number and the " +
|
|
125
|
+
"document stops being editable — this is what turns a draft into a real invoice.\n\n" +
|
|
126
|
+
"Call this after easybill_create_document, once the line items are correct.\n" +
|
|
127
|
+
"Returns the completed document including its assigned 'number'.",
|
|
128
|
+
inputSchema: {
|
|
129
|
+
id: idSchema("document to complete"),
|
|
130
|
+
reason_for_change: z
|
|
131
|
+
.string()
|
|
132
|
+
.min(1)
|
|
133
|
+
.max(255)
|
|
134
|
+
.optional()
|
|
135
|
+
.describe("Optional note stored on the document version as the reason for the change."),
|
|
136
|
+
response_format: z.enum(["markdown", "json"]).default("markdown"),
|
|
137
|
+
},
|
|
138
|
+
}, async (args) => {
|
|
139
|
+
const record = await client.request(`/documents/${String(args.id)}/done`, {
|
|
140
|
+
method: "PUT",
|
|
141
|
+
query: { reason_for_change: args.reason_for_change },
|
|
142
|
+
});
|
|
143
|
+
return buildMutationResponse("Completed", "document", record, format(args), SUMMARY_FIELDS.document);
|
|
144
|
+
});
|
|
145
|
+
registerWrite(server, {
|
|
146
|
+
name: "easybill_cancel_document",
|
|
147
|
+
title: "Cancel document",
|
|
148
|
+
description: "Cancel a document by creating a matching cancellation (STORNO) document. This is the " +
|
|
149
|
+
"legally correct way to void a completed invoice — use it instead of easybill_delete_document.\n\n" +
|
|
150
|
+
"Returns the newly created STORNO document. The original document's 'cancel_id' then " +
|
|
151
|
+
"points at it.",
|
|
152
|
+
inputSchema: {
|
|
153
|
+
id: idSchema("document to cancel"),
|
|
154
|
+
use_text_from_template: z
|
|
155
|
+
.boolean()
|
|
156
|
+
.default(false)
|
|
157
|
+
.describe("Use the standard cancellation texts from the PDF template."),
|
|
158
|
+
response_format: z.enum(["markdown", "json"]).default("markdown"),
|
|
159
|
+
},
|
|
160
|
+
destructive: true,
|
|
161
|
+
}, async (args) => {
|
|
162
|
+
const record = await client.request(`/documents/${String(args.id)}/cancel`, {
|
|
163
|
+
method: "POST",
|
|
164
|
+
query: { use_text_from_template: args.use_text_from_template },
|
|
165
|
+
});
|
|
166
|
+
return buildMutationResponse("Created cancellation for", "document", record, format(args), SUMMARY_FIELDS.document);
|
|
167
|
+
});
|
|
168
|
+
registerWrite(server, {
|
|
169
|
+
name: "easybill_convert_document",
|
|
170
|
+
title: "Convert document to another type",
|
|
171
|
+
description: "Convert an existing document into a new document of a different type, copying over the " +
|
|
172
|
+
"customer and line items. The source document is left untouched.\n\n" +
|
|
173
|
+
"Typical flows: OFFER -> INVOICE (accepted quote), INVOICE -> DUNNING or REMINDER " +
|
|
174
|
+
"(chasing payment), INVOICE -> CREDIT (credit note), ORDER -> DELIVERY.\n\n" +
|
|
175
|
+
"Returns the newly created document.",
|
|
176
|
+
inputSchema: {
|
|
177
|
+
id: idSchema("source document"),
|
|
178
|
+
type: z
|
|
179
|
+
.enum(CONVERTIBLE_TYPES)
|
|
180
|
+
.describe(`Target document type. One of: ${CONVERTIBLE_TYPES.join(", ")}.`),
|
|
181
|
+
pdf_template: z
|
|
182
|
+
.string()
|
|
183
|
+
.optional()
|
|
184
|
+
.describe("PDF template ID for the new document. Defaults to 'DE'."),
|
|
185
|
+
response_format: z.enum(["markdown", "json"]).default("markdown"),
|
|
186
|
+
},
|
|
187
|
+
}, async (args) => {
|
|
188
|
+
const record = await client.request(`/documents/${String(args.id)}/${String(args.type)}`, {
|
|
189
|
+
method: "POST",
|
|
190
|
+
query: { pdf_template: args.pdf_template },
|
|
191
|
+
});
|
|
192
|
+
return buildMutationResponse(`Converted to ${String(args.type)} —`, "document", record, format(args), SUMMARY_FIELDS.document);
|
|
193
|
+
});
|
|
194
|
+
registerWrite(server, {
|
|
195
|
+
name: "easybill_send_document",
|
|
196
|
+
title: "Send document",
|
|
197
|
+
description: "Send a document to the customer by email, fax or post. This dispatches real mail to a " +
|
|
198
|
+
"real recipient — confirm the recipient and document before calling.\n\n" +
|
|
199
|
+
"For 'email', 'to' may hold several addresses separated by commas. Leave 'to' empty to use " +
|
|
200
|
+
"the address stored on the customer.\n\n" +
|
|
201
|
+
"Returns the post box entry created for the send.",
|
|
202
|
+
inputSchema: {
|
|
203
|
+
id: idSchema("document to send"),
|
|
204
|
+
type: z
|
|
205
|
+
.enum(["email", "fax", "post"])
|
|
206
|
+
.describe("Delivery channel: 'email', 'fax' or 'post'."),
|
|
207
|
+
to: z
|
|
208
|
+
.string()
|
|
209
|
+
.optional()
|
|
210
|
+
.describe("Recipient(s). For email, several addresses may be separated by comma, semicolon or newline. Omit to use the customer's stored address."),
|
|
211
|
+
cc: z.string().optional().describe("CC recipient(s) for email sends."),
|
|
212
|
+
subject: z.string().optional().describe("Subject line."),
|
|
213
|
+
message: z.string().optional().describe("Message body."),
|
|
214
|
+
send_with_attachment: z
|
|
215
|
+
.boolean()
|
|
216
|
+
.default(true)
|
|
217
|
+
.describe("Attach the document itself to the message."),
|
|
218
|
+
document_file_type: z
|
|
219
|
+
.enum([
|
|
220
|
+
"default",
|
|
221
|
+
"zugferd1",
|
|
222
|
+
"zugferd2_2",
|
|
223
|
+
"zugferd2_4_en16931",
|
|
224
|
+
"zugferd2_4_extended",
|
|
225
|
+
"zugferd2_5_en16931",
|
|
226
|
+
"zugferd2_5_extended",
|
|
227
|
+
"xrechnung",
|
|
228
|
+
"xrechnung_xml",
|
|
229
|
+
"xrechnung2_2_xml",
|
|
230
|
+
"xrechnung3_0_xml",
|
|
231
|
+
])
|
|
232
|
+
.optional()
|
|
233
|
+
.describe("Attachment format for e-invoicing. Omit to use the format configured on the customer."),
|
|
234
|
+
response_format: z.enum(["markdown", "json"]).default("markdown"),
|
|
235
|
+
},
|
|
236
|
+
destructive: true,
|
|
237
|
+
}, async (args) => {
|
|
238
|
+
const body = { send_with_attachment: args.send_with_attachment };
|
|
239
|
+
for (const key of ["to", "cc", "subject", "message", "document_file_type"]) {
|
|
240
|
+
if (args[key] !== undefined)
|
|
241
|
+
body[key] = args[key];
|
|
242
|
+
}
|
|
243
|
+
const record = await client.request(`/documents/${String(args.id)}/send/${String(args.type)}`, { method: "POST", body });
|
|
244
|
+
return buildMutationResponse(`Sent via ${String(args.type)} —`, "document", record, format(args), ["id", "document_id", "type", "status", "status_msg", "to", "cc", "subject", "created_at"]);
|
|
245
|
+
});
|
|
246
|
+
registerRead(server, {
|
|
247
|
+
name: "easybill_download_document",
|
|
248
|
+
title: "Download document file",
|
|
249
|
+
description: "Download a document as a PDF or e-invoicing file and save it to a local path.\n\n" +
|
|
250
|
+
"Supported formats: 'pdf' (plain), 'zugferd1', 'zugferd2_2' (PDF with embedded XML), " +
|
|
251
|
+
"'xrechnung2_3', 'xrechnung3_0' (XML), and 'jpg' (first page as an image).\n\n" +
|
|
252
|
+
"Returns the saved file path and its size in bytes. The file content itself is NOT loaded " +
|
|
253
|
+
"into the conversation, so this is safe for large PDFs.",
|
|
254
|
+
inputSchema: {
|
|
255
|
+
id: idSchema("document to download"),
|
|
256
|
+
output_path: z
|
|
257
|
+
.string()
|
|
258
|
+
.min(1)
|
|
259
|
+
.describe("Absolute path to write the file to, e.g. '/Users/me/Desktop/invoice-123.pdf'. Parent directory must exist."),
|
|
260
|
+
format: z
|
|
261
|
+
.enum(["pdf", "jpg", "zugferd1", "zugferd2_2", "xrechnung2_3", "xrechnung3_0"])
|
|
262
|
+
.default("pdf")
|
|
263
|
+
.describe("File format to request."),
|
|
264
|
+
},
|
|
265
|
+
}, async (args) => {
|
|
266
|
+
const requested = args.format;
|
|
267
|
+
const outputPath = args.output_path;
|
|
268
|
+
// Plain pdf/jpg have dedicated endpoints; e-invoice formats are negotiated
|
|
269
|
+
// through the Accept header on /download.
|
|
270
|
+
const acceptByFormat = {
|
|
271
|
+
zugferd1: "application/pdf;format=zugferd;version=1.0.0",
|
|
272
|
+
zugferd2_2: "application/pdf;format=zugferd;version=2.2.0",
|
|
273
|
+
xrechnung2_3: "application/xml;format=xrechnung;version=2.3.0",
|
|
274
|
+
xrechnung3_0: "application/xml;format=xrechnung;version=3.0.1",
|
|
275
|
+
};
|
|
276
|
+
const binary = requested === "pdf" || requested === "jpg"
|
|
277
|
+
? await client.requestBinary(`/documents/${String(args.id)}/${requested}`, {
|
|
278
|
+
accept: requested === "pdf" ? "application/pdf" : "image/jpeg",
|
|
279
|
+
})
|
|
280
|
+
: await client.requestBinary(`/documents/${String(args.id)}/download`, {
|
|
281
|
+
accept: acceptByFormat[requested] ?? "application/pdf",
|
|
282
|
+
});
|
|
283
|
+
const { writeFile } = await import("node:fs/promises");
|
|
284
|
+
await writeFile(outputPath, binary.data);
|
|
285
|
+
const output = {
|
|
286
|
+
saved_to: outputPath,
|
|
287
|
+
bytes: binary.data.byteLength,
|
|
288
|
+
content_type: binary.contentType,
|
|
289
|
+
document_id: args.id,
|
|
290
|
+
format: requested,
|
|
291
|
+
};
|
|
292
|
+
return {
|
|
293
|
+
content: [
|
|
294
|
+
{
|
|
295
|
+
type: "text",
|
|
296
|
+
text: `Saved document ${String(args.id)} as ${requested} to ${outputPath} ` +
|
|
297
|
+
`(${binary.data.byteLength.toLocaleString("en-US")} bytes, ${binary.contentType}).`,
|
|
298
|
+
},
|
|
299
|
+
],
|
|
300
|
+
structuredContent: output,
|
|
301
|
+
};
|
|
302
|
+
});
|
|
303
|
+
registerRead(server, {
|
|
304
|
+
name: "easybill_list_document_versions",
|
|
305
|
+
title: "List document versions",
|
|
306
|
+
description: "List the change history of a document. easybill snapshots a version whenever a " +
|
|
307
|
+
"completed document is modified, which is what you need for audit questions like " +
|
|
308
|
+
"'was this invoice altered after it was issued?'.\n\n" +
|
|
309
|
+
"Returns: { total, count, page, pages, items[] } with each version's id, created_at and reason.",
|
|
310
|
+
inputSchema: {
|
|
311
|
+
id: idSchema("document"),
|
|
312
|
+
limit: z.number().int().min(1).max(1000).default(25).describe("Items per page."),
|
|
313
|
+
page: z.number().int().min(1).default(1).describe("Page number, starting at 1."),
|
|
314
|
+
response_format: z.enum(["markdown", "json"]).default("markdown"),
|
|
315
|
+
},
|
|
316
|
+
}, async (args) => {
|
|
317
|
+
const list = await client.request(`/documents/${String(args.id)}/versions`, { query: { limit: args.limit, page: args.page } });
|
|
318
|
+
return buildListResponse({
|
|
319
|
+
list,
|
|
320
|
+
resource: "document versions",
|
|
321
|
+
defaultFields: ["id", "document_id", "created_at", "reason", "items"],
|
|
322
|
+
format: format(args),
|
|
323
|
+
});
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
//# sourceMappingURL=documents.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"documents.js","sourceRoot":"","sources":["../../src/tools/documents.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,cAAc,EACd,cAAc,GACf,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEzE,OAAO,EAKL,iBAAiB,EACjB,qBAAqB,GACtB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAa,iBAAiB,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE5D;;;GAGG;AACH,MAAM,UAAU,GACd,6EAA6E;IAC7E,8DAA8D,CAAC;AAEjE;;;;GAIG;AACH,MAAM,eAAe,GAAG;;;;;;;;;;;;;+EAauD,CAAC;AAEhF,MAAM,kBAAkB,GAAG,GAAG,UAAU;;;0BAGd,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC;;;;;;;;;;;;;;;;;;;;;;;uDAuBI,CAAC;AAExD,MAAM,UAAU,qBAAqB,CAAC,MAAiB,EAAE,MAAsB;IAC7E,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE;QAChC,QAAQ,EAAE,UAAU;QACpB,MAAM,EAAE,WAAW;QACnB,YAAY,EAAE,UAAU;QACxB,UAAU,EAAE,WAAW;QACvB,IAAI,EAAE,YAAY;QAClB,aAAa,EAAE,cAAc,CAAC,QAAQ;QACtC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"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Attachments and the text / PDF template catalogues. */
|
|
2
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
|
+
import type { EasybillClient } from "../services/client.js";
|
|
4
|
+
export declare function registerFileTools(server: McpServer, client: EasybillClient): void;
|