@promptpartner/bexio-mcp-server 2.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.
Files changed (199) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +161 -0
  3. package/dist/bexio-client.d.ts +350 -0
  4. package/dist/bexio-client.js +1045 -0
  5. package/dist/index.d.ts +15 -0
  6. package/dist/index.js +80 -0
  7. package/dist/logger.d.ts +17 -0
  8. package/dist/logger.js +28 -0
  9. package/dist/server.d.ts +18 -0
  10. package/dist/server.js +81 -0
  11. package/dist/shared/errors.d.ts +21 -0
  12. package/dist/shared/errors.js +54 -0
  13. package/dist/shared/index.d.ts +5 -0
  14. package/dist/shared/index.js +5 -0
  15. package/dist/shared/response.d.ts +24 -0
  16. package/dist/shared/response.js +92 -0
  17. package/dist/tools/accounting/definitions.d.ts +9 -0
  18. package/dist/tools/accounting/definitions.js +345 -0
  19. package/dist/tools/accounting/handlers.d.ts +10 -0
  20. package/dist/tools/accounting/handlers.js +121 -0
  21. package/dist/tools/accounting/index.d.ts +16 -0
  22. package/dist/tools/accounting/index.js +16 -0
  23. package/dist/tools/banking/definitions.d.ts +11 -0
  24. package/dist/tools/banking/definitions.js +349 -0
  25. package/dist/tools/banking/handlers.d.ts +9 -0
  26. package/dist/tools/banking/handlers.js +123 -0
  27. package/dist/tools/banking/index.d.ts +6 -0
  28. package/dist/tools/banking/index.js +6 -0
  29. package/dist/tools/company/definitions.d.ts +7 -0
  30. package/dist/tools/company/definitions.js +87 -0
  31. package/dist/tools/company/handlers.d.ts +7 -0
  32. package/dist/tools/company/handlers.js +31 -0
  33. package/dist/tools/company/index.d.ts +6 -0
  34. package/dist/tools/company/index.js +6 -0
  35. package/dist/tools/contacts/definitions.d.ts +6 -0
  36. package/dist/tools/contacts/definitions.js +150 -0
  37. package/dist/tools/contacts/handlers.d.ts +7 -0
  38. package/dist/tools/contacts/handlers.js +40 -0
  39. package/dist/tools/contacts/index.d.ts +6 -0
  40. package/dist/tools/contacts/index.js +5 -0
  41. package/dist/tools/deliveries/definitions.d.ts +6 -0
  42. package/dist/tools/deliveries/definitions.js +67 -0
  43. package/dist/tools/deliveries/handlers.d.ts +7 -0
  44. package/dist/tools/deliveries/handlers.js +28 -0
  45. package/dist/tools/deliveries/index.d.ts +6 -0
  46. package/dist/tools/deliveries/index.js +5 -0
  47. package/dist/tools/files/definitions.d.ts +6 -0
  48. package/dist/tools/files/definitions.js +217 -0
  49. package/dist/tools/files/handlers.d.ts +7 -0
  50. package/dist/tools/files/handlers.js +63 -0
  51. package/dist/tools/files/index.d.ts +6 -0
  52. package/dist/tools/files/index.js +5 -0
  53. package/dist/tools/index.d.ts +19 -0
  54. package/dist/tools/index.js +93 -0
  55. package/dist/tools/invoices/definitions.d.ts +6 -0
  56. package/dist/tools/invoices/definitions.js +147 -0
  57. package/dist/tools/invoices/handlers.d.ts +7 -0
  58. package/dist/tools/invoices/handlers.js +119 -0
  59. package/dist/tools/invoices/index.d.ts +6 -0
  60. package/dist/tools/invoices/index.js +5 -0
  61. package/dist/tools/items/definitions.d.ts +6 -0
  62. package/dist/tools/items/definitions.js +100 -0
  63. package/dist/tools/items/handlers.d.ts +7 -0
  64. package/dist/tools/items/handlers.js +36 -0
  65. package/dist/tools/items/index.d.ts +6 -0
  66. package/dist/tools/items/index.js +5 -0
  67. package/dist/tools/misc/definitions.d.ts +6 -0
  68. package/dist/tools/misc/definitions.js +126 -0
  69. package/dist/tools/misc/handlers.d.ts +7 -0
  70. package/dist/tools/misc/handlers.js +52 -0
  71. package/dist/tools/misc/index.d.ts +6 -0
  72. package/dist/tools/misc/index.js +5 -0
  73. package/dist/tools/orders/definitions.d.ts +6 -0
  74. package/dist/tools/orders/definitions.js +114 -0
  75. package/dist/tools/orders/handlers.d.ts +7 -0
  76. package/dist/tools/orders/handlers.js +62 -0
  77. package/dist/tools/orders/index.d.ts +6 -0
  78. package/dist/tools/orders/index.js +5 -0
  79. package/dist/tools/payments/definitions.d.ts +6 -0
  80. package/dist/tools/payments/definitions.js +74 -0
  81. package/dist/tools/payments/handlers.d.ts +7 -0
  82. package/dist/tools/payments/handlers.js +28 -0
  83. package/dist/tools/payments/index.d.ts +6 -0
  84. package/dist/tools/payments/index.js +5 -0
  85. package/dist/tools/payroll/definitions.d.ts +15 -0
  86. package/dist/tools/payroll/definitions.js +239 -0
  87. package/dist/tools/payroll/handlers.d.ts +14 -0
  88. package/dist/tools/payroll/handlers.js +152 -0
  89. package/dist/tools/payroll/index.d.ts +16 -0
  90. package/dist/tools/payroll/index.js +16 -0
  91. package/dist/tools/projects/definitions.d.ts +7 -0
  92. package/dist/tools/projects/definitions.js +430 -0
  93. package/dist/tools/projects/handlers.d.ts +7 -0
  94. package/dist/tools/projects/handlers.js +127 -0
  95. package/dist/tools/projects/index.d.ts +6 -0
  96. package/dist/tools/projects/index.js +6 -0
  97. package/dist/tools/purchase/definitions.d.ts +6 -0
  98. package/dist/tools/purchase/definitions.js +381 -0
  99. package/dist/tools/purchase/handlers.d.ts +7 -0
  100. package/dist/tools/purchase/handlers.js +120 -0
  101. package/dist/tools/purchase/index.d.ts +7 -0
  102. package/dist/tools/purchase/index.js +6 -0
  103. package/dist/tools/quotes/definitions.d.ts +6 -0
  104. package/dist/tools/quotes/definitions.js +174 -0
  105. package/dist/tools/quotes/handlers.d.ts +7 -0
  106. package/dist/tools/quotes/handlers.js +79 -0
  107. package/dist/tools/quotes/index.d.ts +6 -0
  108. package/dist/tools/quotes/index.js +5 -0
  109. package/dist/tools/reference/definitions.d.ts +7 -0
  110. package/dist/tools/reference/definitions.js +421 -0
  111. package/dist/tools/reference/handlers.d.ts +7 -0
  112. package/dist/tools/reference/handlers.js +161 -0
  113. package/dist/tools/reference/index.d.ts +6 -0
  114. package/dist/tools/reference/index.js +6 -0
  115. package/dist/tools/reminders/definitions.d.ts +6 -0
  116. package/dist/tools/reminders/definitions.js +132 -0
  117. package/dist/tools/reminders/handlers.d.ts +7 -0
  118. package/dist/tools/reminders/handlers.js +43 -0
  119. package/dist/tools/reminders/index.d.ts +6 -0
  120. package/dist/tools/reminders/index.js +5 -0
  121. package/dist/tools/reports/definitions.d.ts +6 -0
  122. package/dist/tools/reports/definitions.js +133 -0
  123. package/dist/tools/reports/handlers.d.ts +7 -0
  124. package/dist/tools/reports/handlers.js +33 -0
  125. package/dist/tools/reports/index.d.ts +6 -0
  126. package/dist/tools/reports/index.js +5 -0
  127. package/dist/tools/timetracking/definitions.d.ts +9 -0
  128. package/dist/tools/timetracking/definitions.js +226 -0
  129. package/dist/tools/timetracking/handlers.d.ts +9 -0
  130. package/dist/tools/timetracking/handlers.js +88 -0
  131. package/dist/tools/timetracking/index.d.ts +6 -0
  132. package/dist/tools/timetracking/index.js +6 -0
  133. package/dist/tools/users/definitions.d.ts +6 -0
  134. package/dist/tools/users/definitions.js +93 -0
  135. package/dist/tools/users/handlers.d.ts +7 -0
  136. package/dist/tools/users/handlers.js +35 -0
  137. package/dist/tools/users/index.d.ts +6 -0
  138. package/dist/tools/users/index.js +5 -0
  139. package/dist/transports/http.d.ts +17 -0
  140. package/dist/transports/http.js +203 -0
  141. package/dist/transports/index.d.ts +4 -0
  142. package/dist/transports/index.js +4 -0
  143. package/dist/types/common.d.ts +32 -0
  144. package/dist/types/common.js +11 -0
  145. package/dist/types/index.d.ts +9 -0
  146. package/dist/types/index.js +11 -0
  147. package/dist/types/schemas/accounting.d.ts +225 -0
  148. package/dist/types/schemas/accounting.js +96 -0
  149. package/dist/types/schemas/banking.d.ts +207 -0
  150. package/dist/types/schemas/banking.js +86 -0
  151. package/dist/types/schemas/company.d.ts +44 -0
  152. package/dist/types/schemas/company.js +23 -0
  153. package/dist/types/schemas/contacts.d.ts +104 -0
  154. package/dist/types/schemas/contacts.js +42 -0
  155. package/dist/types/schemas/deliveries.d.ts +40 -0
  156. package/dist/types/schemas/deliveries.js +22 -0
  157. package/dist/types/schemas/files.d.ts +152 -0
  158. package/dist/types/schemas/files.js +64 -0
  159. package/dist/types/schemas/index.d.ts +24 -0
  160. package/dist/types/schemas/index.js +44 -0
  161. package/dist/types/schemas/invoices.d.ts +594 -0
  162. package/dist/types/schemas/invoices.js +109 -0
  163. package/dist/types/schemas/items.d.ts +153 -0
  164. package/dist/types/schemas/items.js +43 -0
  165. package/dist/types/schemas/misc.d.ts +64 -0
  166. package/dist/types/schemas/misc.js +36 -0
  167. package/dist/types/schemas/orders.d.ts +657 -0
  168. package/dist/types/schemas/orders.js +101 -0
  169. package/dist/types/schemas/payments.d.ts +46 -0
  170. package/dist/types/schemas/payments.js +24 -0
  171. package/dist/types/schemas/payroll.d.ts +146 -0
  172. package/dist/types/schemas/payroll.js +65 -0
  173. package/dist/types/schemas/projects.d.ts +268 -0
  174. package/dist/types/schemas/projects.js +102 -0
  175. package/dist/types/schemas/purchase.d.ts +228 -0
  176. package/dist/types/schemas/purchase.js +114 -0
  177. package/dist/types/schemas/quotes.d.ts +102 -0
  178. package/dist/types/schemas/quotes.js +49 -0
  179. package/dist/types/schemas/reference.d.ts +240 -0
  180. package/dist/types/schemas/reference.js +99 -0
  181. package/dist/types/schemas/reminders.d.ts +76 -0
  182. package/dist/types/schemas/reminders.js +38 -0
  183. package/dist/types/schemas/reports.d.ts +69 -0
  184. package/dist/types/schemas/reports.js +36 -0
  185. package/dist/types/schemas/timetracking.d.ts +150 -0
  186. package/dist/types/schemas/timetracking.js +68 -0
  187. package/dist/types/schemas/users.d.ts +51 -0
  188. package/dist/types/schemas/users.js +27 -0
  189. package/dist/ui/contact-card/mcp-app.d.ts +1 -0
  190. package/dist/ui/contact-card/mcp-app.js +108 -0
  191. package/dist/ui/dashboard/mcp-app.d.ts +1 -0
  192. package/dist/ui/dashboard/mcp-app.js +81 -0
  193. package/dist/ui/invoice-preview/mcp-app.d.ts +1 -0
  194. package/dist/ui/invoice-preview/mcp-app.js +96 -0
  195. package/dist/ui-resources.d.ts +17 -0
  196. package/dist/ui-resources.js +124 -0
  197. package/dist/vite.config.d.ts +2 -0
  198. package/dist/vite.config.js +46 -0
  199. package/package.json +78 -0
@@ -0,0 +1,93 @@
1
+ /**
2
+ * Tool aggregation module.
3
+ * Single import point for all domain tools.
4
+ *
5
+ * Pattern for adding new domains:
6
+ * 1. Create tools/{domain}/definitions.ts
7
+ * 2. Create tools/{domain}/handlers.ts
8
+ * 3. Create tools/{domain}/index.ts
9
+ * 4. Import and add to arrays below
10
+ */
11
+ // Domain imports
12
+ import * as reference from "./reference/index.js";
13
+ import * as company from "./company/index.js";
14
+ import * as banking from "./banking/index.js";
15
+ import * as projects from "./projects/index.js";
16
+ import * as timetracking from "./timetracking/index.js";
17
+ import * as accounting from "./accounting/index.js";
18
+ import * as contacts from "./contacts/index.js";
19
+ import * as invoices from "./invoices/index.js";
20
+ import * as orders from "./orders/index.js";
21
+ import * as quotes from "./quotes/index.js";
22
+ import * as payments from "./payments/index.js";
23
+ import * as reminders from "./reminders/index.js";
24
+ import * as deliveries from "./deliveries/index.js";
25
+ import * as items from "./items/index.js";
26
+ import * as reports from "./reports/index.js";
27
+ import * as users from "./users/index.js";
28
+ import * as misc from "./misc/index.js";
29
+ import * as purchase from "./purchase/index.js";
30
+ import * as files from "./files/index.js";
31
+ import * as payroll from "./payroll/index.js";
32
+ // Aggregate all tool definitions (218 total)
33
+ const allDefinitions = [
34
+ ...reference.toolDefinitions, // 26 tools (contact groups, sectors, salutations, titles, countries, languages, units)
35
+ ...company.toolDefinitions, // 6 tools (company profile, permissions, payment types)
36
+ ...banking.toolDefinitions, // 13 tools (bank accounts, currencies, IBAN payments, QR payments)
37
+ ...projects.toolDefinitions, // 21 tools (projects, project types, project statuses, milestones, work packages)
38
+ ...timetracking.toolDefinitions, // 11 tools (timesheets, statuses, business activities, communication types)
39
+ ...accounting.toolDefinitions, // 15 tools (accounts, groups, years, entries, VAT, journal)
40
+ ...purchase.toolDefinitions, // 23 tools (bills, expenses, purchase orders, outgoing payments)
41
+ ...files.toolDefinitions, // 10 tools (files, additional addresses)
42
+ ...payroll.toolDefinitions, // 10 tools (employees, absences, payroll docs - conditional)
43
+ ...contacts.toolDefinitions, // 7 tools
44
+ ...invoices.toolDefinitions, // 15 tools
45
+ ...orders.toolDefinitions, // 7 tools
46
+ ...quotes.toolDefinitions, // 11 tools
47
+ ...payments.toolDefinitions, // 4 tools
48
+ ...reminders.toolDefinitions, // 8 tools
49
+ ...deliveries.toolDefinitions, // 4 tools
50
+ ...items.toolDefinitions, // 5 tools
51
+ ...reports.toolDefinitions, // 7 tools
52
+ ...users.toolDefinitions, // 6 tools
53
+ ...misc.toolDefinitions, // 9 tools
54
+ ];
55
+ // Aggregate all handlers
56
+ const allHandlers = {
57
+ ...reference.handlers,
58
+ ...company.handlers,
59
+ ...banking.handlers,
60
+ ...projects.handlers,
61
+ ...timetracking.handlers,
62
+ ...accounting.handlers,
63
+ ...purchase.handlers,
64
+ ...files.handlers,
65
+ ...payroll.handlers,
66
+ ...contacts.handlers,
67
+ ...invoices.handlers,
68
+ ...orders.handlers,
69
+ ...quotes.handlers,
70
+ ...payments.handlers,
71
+ ...reminders.handlers,
72
+ ...deliveries.handlers,
73
+ ...items.handlers,
74
+ ...reports.handlers,
75
+ ...users.handlers,
76
+ ...misc.handlers,
77
+ };
78
+ /** Get all tool definitions for registration */
79
+ export function getAllToolDefinitions() {
80
+ return allDefinitions;
81
+ }
82
+ /** Get handler for a specific tool */
83
+ export function getHandler(toolName) {
84
+ return allHandlers[toolName];
85
+ }
86
+ /** Create handler registry bound to a client */
87
+ export function createHandlerRegistry(client) {
88
+ const registry = new Map();
89
+ for (const [name, handler] of Object.entries(allHandlers)) {
90
+ registry.set(name, (args) => handler(client, args));
91
+ }
92
+ return registry;
93
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Invoice tool definitions.
3
+ * Contains MCP tool metadata for invoices domain.
4
+ */
5
+ import type { Tool } from "@modelcontextprotocol/sdk/types.js";
6
+ export declare const toolDefinitions: Tool[];
@@ -0,0 +1,147 @@
1
+ export const toolDefinitions = [
2
+ {
3
+ name: "list_invoices",
4
+ description: "List invoices from Bexio with optional pagination",
5
+ inputSchema: {
6
+ type: "object",
7
+ properties: {
8
+ limit: { type: "integer", description: "Maximum number to return (default: 50)", default: 50 },
9
+ offset: { type: "integer", description: "Number to skip (default: 0)", default: 0 },
10
+ },
11
+ },
12
+ },
13
+ {
14
+ name: "list_all_invoices",
15
+ description: "List every invoice in Bexio by paging automatically",
16
+ inputSchema: {
17
+ type: "object",
18
+ properties: {
19
+ chunk_size: { type: "integer", description: "Invoices per request (default: 100)", default: 100 },
20
+ },
21
+ },
22
+ },
23
+ {
24
+ name: "get_invoice",
25
+ description: "Get a specific invoice by ID",
26
+ inputSchema: {
27
+ type: "object",
28
+ properties: { invoice_id: { type: "integer", description: "The invoice ID" } },
29
+ required: ["invoice_id"],
30
+ },
31
+ },
32
+ {
33
+ name: "search_invoices",
34
+ description: "Search invoices via the Bexio search endpoint",
35
+ inputSchema: {
36
+ type: "object",
37
+ properties: {
38
+ query: { type: "string", description: "Free-text value matched with LIKE" },
39
+ field: { type: "string", description: "Field to search (default: title)", default: "title" },
40
+ operator: { type: "string", description: "Comparison operator (LIKE, =, >)", default: "LIKE" },
41
+ filters: {
42
+ type: "array", description: "Explicit Bexio search filters",
43
+ items: {
44
+ type: "object",
45
+ properties: { field: { type: "string" }, operator: { type: "string" }, value: {} },
46
+ required: ["field", "operator", "value"],
47
+ },
48
+ },
49
+ limit: { type: "integer", description: "Maximum results" },
50
+ },
51
+ },
52
+ },
53
+ {
54
+ name: "search_invoices_by_customer",
55
+ description: "Search invoices by customer name (finds contact, then invoices)",
56
+ inputSchema: {
57
+ type: "object",
58
+ properties: {
59
+ customer_name: { type: "string", description: "Customer name to search for" },
60
+ limit: { type: "integer", description: "Maximum invoices to return (default: 50)", default: 50 },
61
+ },
62
+ required: ["customer_name"],
63
+ },
64
+ },
65
+ {
66
+ name: "create_invoice",
67
+ description: "Create a new invoice in Bexio",
68
+ inputSchema: {
69
+ type: "object",
70
+ properties: { invoice_data: { type: "object", description: "Invoice data to create" } },
71
+ required: ["invoice_data"],
72
+ },
73
+ },
74
+ {
75
+ name: "issue_invoice",
76
+ description: "Issue an invoice",
77
+ inputSchema: {
78
+ type: "object",
79
+ properties: { invoice_id: { type: "integer", description: "The invoice ID to issue" } },
80
+ required: ["invoice_id"],
81
+ },
82
+ },
83
+ {
84
+ name: "cancel_invoice",
85
+ description: "Cancel an invoice",
86
+ inputSchema: {
87
+ type: "object",
88
+ properties: { invoice_id: { type: "integer", description: "The invoice ID to cancel" } },
89
+ required: ["invoice_id"],
90
+ },
91
+ },
92
+ {
93
+ name: "mark_invoice_as_sent",
94
+ description: "Mark an invoice as sent",
95
+ inputSchema: {
96
+ type: "object",
97
+ properties: { invoice_id: { type: "integer", description: "The invoice ID to mark as sent" } },
98
+ required: ["invoice_id"],
99
+ },
100
+ },
101
+ {
102
+ name: "send_invoice",
103
+ description: "Send an invoice",
104
+ inputSchema: {
105
+ type: "object",
106
+ properties: { invoice_id: { type: "integer", description: "The invoice ID to send" } },
107
+ required: ["invoice_id"],
108
+ },
109
+ },
110
+ {
111
+ name: "copy_invoice",
112
+ description: "Copy an invoice",
113
+ inputSchema: {
114
+ type: "object",
115
+ properties: { invoice_id: { type: "integer", description: "The invoice ID to copy" } },
116
+ required: ["invoice_id"],
117
+ },
118
+ },
119
+ {
120
+ name: "list_invoice_statuses",
121
+ description: "List all available invoice statuses with their meanings",
122
+ inputSchema: { type: "object", properties: {} },
123
+ },
124
+ {
125
+ name: "list_all_statuses",
126
+ description: "List all document statuses for invoices, quotes, and orders",
127
+ inputSchema: {
128
+ type: "object",
129
+ properties: {
130
+ document_type: {
131
+ type: "string", enum: ["all", "invoices", "quotes", "orders"],
132
+ description: "Filter by document type (default: all)", default: "all",
133
+ },
134
+ },
135
+ },
136
+ },
137
+ {
138
+ name: "get_open_invoices",
139
+ description: "Get all open invoices (draft and sent/pending)",
140
+ inputSchema: { type: "object", properties: {} },
141
+ },
142
+ {
143
+ name: "get_overdue_invoices",
144
+ description: "Get all overdue invoices",
145
+ inputSchema: { type: "object", properties: {} },
146
+ },
147
+ ];
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Invoice tool handlers.
3
+ * Implements the logic for each invoice tool.
4
+ */
5
+ import { BexioClient } from "../../bexio-client.js";
6
+ export type HandlerFn = (client: BexioClient, args: unknown) => Promise<unknown>;
7
+ export declare const handlers: Record<string, HandlerFn>;
@@ -0,0 +1,119 @@
1
+ /**
2
+ * Invoice tool handlers.
3
+ * Implements the logic for each invoice tool.
4
+ */
5
+ import { McpError } from "../../shared/errors.js";
6
+ import { ListInvoicesParamsSchema, ListAllInvoicesParamsSchema, GetInvoiceParamsSchema, SearchInvoicesParamsSchema, SearchInvoicesByCustomerParamsSchema, CreateInvoiceParamsSchema, IssueInvoiceParamsSchema, CancelInvoiceParamsSchema, MarkInvoiceAsSentParamsSchema, SendInvoiceParamsSchema, CopyInvoiceParamsSchema, ListInvoiceStatusesParamsSchema, ListAllStatusesParamsSchema, } from "../../types/index.js";
7
+ export const handlers = {
8
+ list_invoices: async (client, args) => {
9
+ const params = ListInvoicesParamsSchema.parse(args);
10
+ return client.listInvoices(params);
11
+ },
12
+ list_all_invoices: async (client, args) => {
13
+ const { chunk_size } = ListAllInvoicesParamsSchema.parse(args);
14
+ return client.listAllInvoices(chunk_size);
15
+ },
16
+ get_invoice: async (client, args) => {
17
+ const { invoice_id } = GetInvoiceParamsSchema.parse(args);
18
+ const invoice = await client.getInvoice(invoice_id);
19
+ if (!invoice) {
20
+ throw McpError.notFound("Invoice", invoice_id);
21
+ }
22
+ return invoice;
23
+ },
24
+ search_invoices: async (client, args) => {
25
+ const params = SearchInvoicesParamsSchema.parse(args);
26
+ const searchParams = {
27
+ field: params.field,
28
+ operator: params.operator,
29
+ };
30
+ if (params.query !== undefined) {
31
+ searchParams.query = params.query;
32
+ }
33
+ if (params.filters !== undefined) {
34
+ searchParams.filters = params.filters.map((filter) => ({
35
+ field: filter.field,
36
+ operator: filter.operator,
37
+ value: filter.value ?? null,
38
+ }));
39
+ }
40
+ if (params.limit !== undefined) {
41
+ searchParams.limit = params.limit;
42
+ }
43
+ return client.searchInvoices(searchParams);
44
+ },
45
+ search_invoices_by_customer: async (client, args) => {
46
+ const params = SearchInvoicesByCustomerParamsSchema.parse(args);
47
+ // Step 1: Find contacts by name
48
+ const contacts = await client.findContactByName(params.customer_name);
49
+ if (!contacts || contacts.length === 0) {
50
+ return {
51
+ invoices: [],
52
+ message: `No contacts found with name "${params.customer_name}"`,
53
+ contacts_found: 0,
54
+ };
55
+ }
56
+ // Step 2: Search invoices for each contact (limit to first 5)
57
+ const allInvoices = [];
58
+ for (const contact of contacts.slice(0, 5)) {
59
+ const contactId = contact.id;
60
+ if (contactId) {
61
+ const searchParams = {
62
+ filters: [
63
+ {
64
+ field: "contact_id",
65
+ operator: "=",
66
+ value: contactId.toString(),
67
+ },
68
+ ],
69
+ limit: params.limit,
70
+ };
71
+ const invoices = await client.searchInvoices(searchParams);
72
+ allInvoices.push(...invoices);
73
+ }
74
+ }
75
+ return {
76
+ invoices: allInvoices,
77
+ contacts_found: contacts.length,
78
+ customer_name: params.customer_name,
79
+ };
80
+ },
81
+ create_invoice: async (client, args) => {
82
+ const { invoice_data } = CreateInvoiceParamsSchema.parse(args);
83
+ return client.createInvoice(invoice_data);
84
+ },
85
+ issue_invoice: async (client, args) => {
86
+ const { invoice_id } = IssueInvoiceParamsSchema.parse(args);
87
+ return client.issueInvoice(invoice_id);
88
+ },
89
+ cancel_invoice: async (client, args) => {
90
+ const { invoice_id } = CancelInvoiceParamsSchema.parse(args);
91
+ return client.cancelInvoice(invoice_id);
92
+ },
93
+ mark_invoice_as_sent: async (client, args) => {
94
+ const { invoice_id } = MarkInvoiceAsSentParamsSchema.parse(args);
95
+ return client.markInvoiceAsSent(invoice_id);
96
+ },
97
+ send_invoice: async (client, args) => {
98
+ const { invoice_id } = SendInvoiceParamsSchema.parse(args);
99
+ return client.sendInvoice(invoice_id);
100
+ },
101
+ copy_invoice: async (client, args) => {
102
+ const { invoice_id } = CopyInvoiceParamsSchema.parse(args);
103
+ return client.copyInvoice(invoice_id);
104
+ },
105
+ list_invoice_statuses: async (client, args) => {
106
+ ListInvoiceStatusesParamsSchema.parse(args);
107
+ return client.listInvoiceStatuses();
108
+ },
109
+ list_all_statuses: async (client, args) => {
110
+ const { document_type } = ListAllStatusesParamsSchema.parse(args);
111
+ return client.listAllStatuses(document_type);
112
+ },
113
+ get_open_invoices: async (client) => {
114
+ return client.getOpenInvoices();
115
+ },
116
+ get_overdue_invoices: async (client) => {
117
+ return client.getOverdueInvoices();
118
+ },
119
+ };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Invoices domain module barrel export.
3
+ */
4
+ export { toolDefinitions } from "./definitions.js";
5
+ export { handlers } from "./handlers.js";
6
+ export type { HandlerFn } from "./handlers.js";
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Invoices domain module barrel export.
3
+ */
4
+ export { toolDefinitions } from "./definitions.js";
5
+ export { handlers } from "./handlers.js";
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Item tool definitions.
3
+ * Contains MCP tool metadata for items/articles and taxes domain.
4
+ */
5
+ import type { Tool } from "@modelcontextprotocol/sdk/types.js";
6
+ export declare const toolDefinitions: Tool[];
@@ -0,0 +1,100 @@
1
+ /**
2
+ * Item tool definitions.
3
+ * Contains MCP tool metadata for items/articles and taxes domain.
4
+ */
5
+ export const toolDefinitions = [
6
+ {
7
+ name: "list_items",
8
+ description: "List items from Bexio with optional pagination",
9
+ inputSchema: {
10
+ type: "object",
11
+ properties: {
12
+ limit: {
13
+ type: "integer",
14
+ description: "Maximum number of items to return (default: 50)",
15
+ default: 50,
16
+ },
17
+ offset: {
18
+ type: "integer",
19
+ description: "Number of items to skip (default: 0)",
20
+ default: 0,
21
+ },
22
+ },
23
+ },
24
+ },
25
+ {
26
+ name: "get_item",
27
+ description: "Get a specific item by ID",
28
+ inputSchema: {
29
+ type: "object",
30
+ properties: {
31
+ item_id: {
32
+ type: "integer",
33
+ description: "The ID of the item to retrieve",
34
+ },
35
+ },
36
+ required: ["item_id"],
37
+ },
38
+ },
39
+ {
40
+ name: "create_item",
41
+ description: "Create a new item in Bexio",
42
+ inputSchema: {
43
+ type: "object",
44
+ properties: {
45
+ item_data: {
46
+ type: "object",
47
+ description: "Item data to create",
48
+ properties: {
49
+ name_1: { type: "string", description: "Item name (primary name field)" },
50
+ name_2: { type: "string", description: "Item name (secondary name field)" },
51
+ description: { type: "string", description: "Item description" },
52
+ internal_pos: { type: "string", description: "Internal position number" },
53
+ unit_id: { type: "integer", description: "Unit ID" },
54
+ purchase_price: { type: "number", description: "Purchase price" },
55
+ sale_price: { type: "number", description: "Sale price" },
56
+ article_type_id: { type: "integer", description: "Article type ID" },
57
+ tax_income_id: { type: "integer", description: "Tax income ID" },
58
+ tax_id: { type: "integer", description: "Tax ID" },
59
+ account_id: { type: "integer", description: "Account ID" },
60
+ },
61
+ required: ["name_1"],
62
+ },
63
+ },
64
+ required: ["item_data"],
65
+ },
66
+ },
67
+ {
68
+ name: "list_taxes",
69
+ description: "List taxes from Bexio with optional pagination",
70
+ inputSchema: {
71
+ type: "object",
72
+ properties: {
73
+ limit: {
74
+ type: "integer",
75
+ description: "Maximum number of taxes to return (default: 50)",
76
+ default: 50,
77
+ },
78
+ offset: {
79
+ type: "integer",
80
+ description: "Number of taxes to skip (default: 0)",
81
+ default: 0,
82
+ },
83
+ },
84
+ },
85
+ },
86
+ {
87
+ name: "get_tax",
88
+ description: "Get a specific tax by ID",
89
+ inputSchema: {
90
+ type: "object",
91
+ properties: {
92
+ tax_id: {
93
+ type: "integer",
94
+ description: "The ID of the tax to retrieve",
95
+ },
96
+ },
97
+ required: ["tax_id"],
98
+ },
99
+ },
100
+ ];
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Item tool handlers.
3
+ * Implements the logic for each item and tax tool.
4
+ */
5
+ import { BexioClient } from "../../bexio-client.js";
6
+ export type HandlerFn = (client: BexioClient, args: unknown) => Promise<unknown>;
7
+ export declare const handlers: Record<string, HandlerFn>;
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Item tool handlers.
3
+ * Implements the logic for each item and tax tool.
4
+ */
5
+ import { McpError } from "../../shared/errors.js";
6
+ import { ListItemsParamsSchema, GetItemParamsSchema, CreateItemParamsSchema, ListTaxesParamsSchema, GetTaxParamsSchema, } from "../../types/index.js";
7
+ export const handlers = {
8
+ list_items: async (client, args) => {
9
+ const params = ListItemsParamsSchema.parse(args);
10
+ return client.listItems(params);
11
+ },
12
+ get_item: async (client, args) => {
13
+ const { item_id } = GetItemParamsSchema.parse(args);
14
+ const item = await client.getItem(item_id);
15
+ if (!item) {
16
+ throw McpError.notFound("Item", item_id);
17
+ }
18
+ return item;
19
+ },
20
+ create_item: async (client, args) => {
21
+ const { item_data } = CreateItemParamsSchema.parse(args);
22
+ return client.createItem(item_data);
23
+ },
24
+ list_taxes: async (client, args) => {
25
+ const params = ListTaxesParamsSchema.parse(args);
26
+ return client.listTaxes(params);
27
+ },
28
+ get_tax: async (client, args) => {
29
+ const { tax_id } = GetTaxParamsSchema.parse(args);
30
+ const tax = await client.getTax(tax_id);
31
+ if (!tax) {
32
+ throw McpError.notFound("Tax", tax_id);
33
+ }
34
+ return tax;
35
+ },
36
+ };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Items domain module barrel export.
3
+ */
4
+ export { toolDefinitions } from "./definitions.js";
5
+ export { handlers } from "./handlers.js";
6
+ export type { HandlerFn } from "./handlers.js";
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Items domain module barrel export.
3
+ */
4
+ export { toolDefinitions } from "./definitions.js";
5
+ export { handlers } from "./handlers.js";
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Misc tool definitions.
3
+ * Contains MCP tool metadata for comments and contact relations.
4
+ */
5
+ import type { Tool } from "@modelcontextprotocol/sdk/types.js";
6
+ export declare const toolDefinitions: Tool[];