@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.
- package/LICENSE +21 -0
- package/README.md +161 -0
- package/dist/bexio-client.d.ts +350 -0
- package/dist/bexio-client.js +1045 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +80 -0
- package/dist/logger.d.ts +17 -0
- package/dist/logger.js +28 -0
- package/dist/server.d.ts +18 -0
- package/dist/server.js +81 -0
- package/dist/shared/errors.d.ts +21 -0
- package/dist/shared/errors.js +54 -0
- package/dist/shared/index.d.ts +5 -0
- package/dist/shared/index.js +5 -0
- package/dist/shared/response.d.ts +24 -0
- package/dist/shared/response.js +92 -0
- package/dist/tools/accounting/definitions.d.ts +9 -0
- package/dist/tools/accounting/definitions.js +345 -0
- package/dist/tools/accounting/handlers.d.ts +10 -0
- package/dist/tools/accounting/handlers.js +121 -0
- package/dist/tools/accounting/index.d.ts +16 -0
- package/dist/tools/accounting/index.js +16 -0
- package/dist/tools/banking/definitions.d.ts +11 -0
- package/dist/tools/banking/definitions.js +349 -0
- package/dist/tools/banking/handlers.d.ts +9 -0
- package/dist/tools/banking/handlers.js +123 -0
- package/dist/tools/banking/index.d.ts +6 -0
- package/dist/tools/banking/index.js +6 -0
- package/dist/tools/company/definitions.d.ts +7 -0
- package/dist/tools/company/definitions.js +87 -0
- package/dist/tools/company/handlers.d.ts +7 -0
- package/dist/tools/company/handlers.js +31 -0
- package/dist/tools/company/index.d.ts +6 -0
- package/dist/tools/company/index.js +6 -0
- package/dist/tools/contacts/definitions.d.ts +6 -0
- package/dist/tools/contacts/definitions.js +150 -0
- package/dist/tools/contacts/handlers.d.ts +7 -0
- package/dist/tools/contacts/handlers.js +40 -0
- package/dist/tools/contacts/index.d.ts +6 -0
- package/dist/tools/contacts/index.js +5 -0
- package/dist/tools/deliveries/definitions.d.ts +6 -0
- package/dist/tools/deliveries/definitions.js +67 -0
- package/dist/tools/deliveries/handlers.d.ts +7 -0
- package/dist/tools/deliveries/handlers.js +28 -0
- package/dist/tools/deliveries/index.d.ts +6 -0
- package/dist/tools/deliveries/index.js +5 -0
- package/dist/tools/files/definitions.d.ts +6 -0
- package/dist/tools/files/definitions.js +217 -0
- package/dist/tools/files/handlers.d.ts +7 -0
- package/dist/tools/files/handlers.js +63 -0
- package/dist/tools/files/index.d.ts +6 -0
- package/dist/tools/files/index.js +5 -0
- package/dist/tools/index.d.ts +19 -0
- package/dist/tools/index.js +93 -0
- package/dist/tools/invoices/definitions.d.ts +6 -0
- package/dist/tools/invoices/definitions.js +147 -0
- package/dist/tools/invoices/handlers.d.ts +7 -0
- package/dist/tools/invoices/handlers.js +119 -0
- package/dist/tools/invoices/index.d.ts +6 -0
- package/dist/tools/invoices/index.js +5 -0
- package/dist/tools/items/definitions.d.ts +6 -0
- package/dist/tools/items/definitions.js +100 -0
- package/dist/tools/items/handlers.d.ts +7 -0
- package/dist/tools/items/handlers.js +36 -0
- package/dist/tools/items/index.d.ts +6 -0
- package/dist/tools/items/index.js +5 -0
- package/dist/tools/misc/definitions.d.ts +6 -0
- package/dist/tools/misc/definitions.js +126 -0
- package/dist/tools/misc/handlers.d.ts +7 -0
- package/dist/tools/misc/handlers.js +52 -0
- package/dist/tools/misc/index.d.ts +6 -0
- package/dist/tools/misc/index.js +5 -0
- package/dist/tools/orders/definitions.d.ts +6 -0
- package/dist/tools/orders/definitions.js +114 -0
- package/dist/tools/orders/handlers.d.ts +7 -0
- package/dist/tools/orders/handlers.js +62 -0
- package/dist/tools/orders/index.d.ts +6 -0
- package/dist/tools/orders/index.js +5 -0
- package/dist/tools/payments/definitions.d.ts +6 -0
- package/dist/tools/payments/definitions.js +74 -0
- package/dist/tools/payments/handlers.d.ts +7 -0
- package/dist/tools/payments/handlers.js +28 -0
- package/dist/tools/payments/index.d.ts +6 -0
- package/dist/tools/payments/index.js +5 -0
- package/dist/tools/payroll/definitions.d.ts +15 -0
- package/dist/tools/payroll/definitions.js +239 -0
- package/dist/tools/payroll/handlers.d.ts +14 -0
- package/dist/tools/payroll/handlers.js +152 -0
- package/dist/tools/payroll/index.d.ts +16 -0
- package/dist/tools/payroll/index.js +16 -0
- package/dist/tools/projects/definitions.d.ts +7 -0
- package/dist/tools/projects/definitions.js +430 -0
- package/dist/tools/projects/handlers.d.ts +7 -0
- package/dist/tools/projects/handlers.js +127 -0
- package/dist/tools/projects/index.d.ts +6 -0
- package/dist/tools/projects/index.js +6 -0
- package/dist/tools/purchase/definitions.d.ts +6 -0
- package/dist/tools/purchase/definitions.js +381 -0
- package/dist/tools/purchase/handlers.d.ts +7 -0
- package/dist/tools/purchase/handlers.js +120 -0
- package/dist/tools/purchase/index.d.ts +7 -0
- package/dist/tools/purchase/index.js +6 -0
- package/dist/tools/quotes/definitions.d.ts +6 -0
- package/dist/tools/quotes/definitions.js +174 -0
- package/dist/tools/quotes/handlers.d.ts +7 -0
- package/dist/tools/quotes/handlers.js +79 -0
- package/dist/tools/quotes/index.d.ts +6 -0
- package/dist/tools/quotes/index.js +5 -0
- package/dist/tools/reference/definitions.d.ts +7 -0
- package/dist/tools/reference/definitions.js +421 -0
- package/dist/tools/reference/handlers.d.ts +7 -0
- package/dist/tools/reference/handlers.js +161 -0
- package/dist/tools/reference/index.d.ts +6 -0
- package/dist/tools/reference/index.js +6 -0
- package/dist/tools/reminders/definitions.d.ts +6 -0
- package/dist/tools/reminders/definitions.js +132 -0
- package/dist/tools/reminders/handlers.d.ts +7 -0
- package/dist/tools/reminders/handlers.js +43 -0
- package/dist/tools/reminders/index.d.ts +6 -0
- package/dist/tools/reminders/index.js +5 -0
- package/dist/tools/reports/definitions.d.ts +6 -0
- package/dist/tools/reports/definitions.js +133 -0
- package/dist/tools/reports/handlers.d.ts +7 -0
- package/dist/tools/reports/handlers.js +33 -0
- package/dist/tools/reports/index.d.ts +6 -0
- package/dist/tools/reports/index.js +5 -0
- package/dist/tools/timetracking/definitions.d.ts +9 -0
- package/dist/tools/timetracking/definitions.js +226 -0
- package/dist/tools/timetracking/handlers.d.ts +9 -0
- package/dist/tools/timetracking/handlers.js +88 -0
- package/dist/tools/timetracking/index.d.ts +6 -0
- package/dist/tools/timetracking/index.js +6 -0
- package/dist/tools/users/definitions.d.ts +6 -0
- package/dist/tools/users/definitions.js +93 -0
- package/dist/tools/users/handlers.d.ts +7 -0
- package/dist/tools/users/handlers.js +35 -0
- package/dist/tools/users/index.d.ts +6 -0
- package/dist/tools/users/index.js +5 -0
- package/dist/transports/http.d.ts +17 -0
- package/dist/transports/http.js +203 -0
- package/dist/transports/index.d.ts +4 -0
- package/dist/transports/index.js +4 -0
- package/dist/types/common.d.ts +32 -0
- package/dist/types/common.js +11 -0
- package/dist/types/index.d.ts +9 -0
- package/dist/types/index.js +11 -0
- package/dist/types/schemas/accounting.d.ts +225 -0
- package/dist/types/schemas/accounting.js +96 -0
- package/dist/types/schemas/banking.d.ts +207 -0
- package/dist/types/schemas/banking.js +86 -0
- package/dist/types/schemas/company.d.ts +44 -0
- package/dist/types/schemas/company.js +23 -0
- package/dist/types/schemas/contacts.d.ts +104 -0
- package/dist/types/schemas/contacts.js +42 -0
- package/dist/types/schemas/deliveries.d.ts +40 -0
- package/dist/types/schemas/deliveries.js +22 -0
- package/dist/types/schemas/files.d.ts +152 -0
- package/dist/types/schemas/files.js +64 -0
- package/dist/types/schemas/index.d.ts +24 -0
- package/dist/types/schemas/index.js +44 -0
- package/dist/types/schemas/invoices.d.ts +594 -0
- package/dist/types/schemas/invoices.js +109 -0
- package/dist/types/schemas/items.d.ts +153 -0
- package/dist/types/schemas/items.js +43 -0
- package/dist/types/schemas/misc.d.ts +64 -0
- package/dist/types/schemas/misc.js +36 -0
- package/dist/types/schemas/orders.d.ts +657 -0
- package/dist/types/schemas/orders.js +101 -0
- package/dist/types/schemas/payments.d.ts +46 -0
- package/dist/types/schemas/payments.js +24 -0
- package/dist/types/schemas/payroll.d.ts +146 -0
- package/dist/types/schemas/payroll.js +65 -0
- package/dist/types/schemas/projects.d.ts +268 -0
- package/dist/types/schemas/projects.js +102 -0
- package/dist/types/schemas/purchase.d.ts +228 -0
- package/dist/types/schemas/purchase.js +114 -0
- package/dist/types/schemas/quotes.d.ts +102 -0
- package/dist/types/schemas/quotes.js +49 -0
- package/dist/types/schemas/reference.d.ts +240 -0
- package/dist/types/schemas/reference.js +99 -0
- package/dist/types/schemas/reminders.d.ts +76 -0
- package/dist/types/schemas/reminders.js +38 -0
- package/dist/types/schemas/reports.d.ts +69 -0
- package/dist/types/schemas/reports.js +36 -0
- package/dist/types/schemas/timetracking.d.ts +150 -0
- package/dist/types/schemas/timetracking.js +68 -0
- package/dist/types/schemas/users.d.ts +51 -0
- package/dist/types/schemas/users.js +27 -0
- package/dist/ui/contact-card/mcp-app.d.ts +1 -0
- package/dist/ui/contact-card/mcp-app.js +108 -0
- package/dist/ui/dashboard/mcp-app.d.ts +1 -0
- package/dist/ui/dashboard/mcp-app.js +81 -0
- package/dist/ui/invoice-preview/mcp-app.d.ts +1 -0
- package/dist/ui/invoice-preview/mcp-app.js +96 -0
- package/dist/ui-resources.d.ts +17 -0
- package/dist/ui-resources.js +124 -0
- package/dist/vite.config.d.ts +2 -0
- package/dist/vite.config.js +46 -0
- package/package.json +78 -0
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Payroll tool definitions.
|
|
3
|
+
* Contains MCP tool metadata for payroll domain.
|
|
4
|
+
*
|
|
5
|
+
* IMPORTANT: Payroll module requires a Bexio subscription with payroll features.
|
|
6
|
+
* All tools check module availability on first call and cache the result.
|
|
7
|
+
* When unavailable, tools return a friendly error explaining how to enable payroll.
|
|
8
|
+
*
|
|
9
|
+
* 10 tools total:
|
|
10
|
+
* - Employees: 4 tools (list, get, create, update)
|
|
11
|
+
* - Absences: 5 tools (list, get, create, update, delete)
|
|
12
|
+
* - Payroll Documents: 1 tool (list)
|
|
13
|
+
*/
|
|
14
|
+
export const toolDefinitions = [
|
|
15
|
+
// ===== EMPLOYEES (PAY-01) =====
|
|
16
|
+
{
|
|
17
|
+
name: "list_employees",
|
|
18
|
+
description: "List employees in the payroll system. Requires Bexio Payroll module subscription. Use to get employee IDs for timesheets and absences.",
|
|
19
|
+
inputSchema: {
|
|
20
|
+
type: "object",
|
|
21
|
+
properties: {
|
|
22
|
+
limit: {
|
|
23
|
+
type: "integer",
|
|
24
|
+
description: "Maximum number of results to return (default: 50)",
|
|
25
|
+
default: 50,
|
|
26
|
+
},
|
|
27
|
+
offset: {
|
|
28
|
+
type: "integer",
|
|
29
|
+
description: "Number of results to skip (default: 0)",
|
|
30
|
+
default: 0,
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
name: "get_employee",
|
|
37
|
+
description: "Get a specific employee by ID. Requires Bexio Payroll module subscription.",
|
|
38
|
+
inputSchema: {
|
|
39
|
+
type: "object",
|
|
40
|
+
properties: {
|
|
41
|
+
employee_id: {
|
|
42
|
+
type: "integer",
|
|
43
|
+
description: "The ID of the employee to retrieve",
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
required: ["employee_id"],
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
name: "create_employee",
|
|
51
|
+
description: "Create a new employee in the payroll system. Requires Bexio Payroll module subscription. Links a Bexio user to payroll.",
|
|
52
|
+
inputSchema: {
|
|
53
|
+
type: "object",
|
|
54
|
+
properties: {
|
|
55
|
+
user_id: {
|
|
56
|
+
type: "integer",
|
|
57
|
+
description: "The ID of the Bexio user to create as an employee",
|
|
58
|
+
},
|
|
59
|
+
first_name: {
|
|
60
|
+
type: "string",
|
|
61
|
+
description: "Employee's first name",
|
|
62
|
+
},
|
|
63
|
+
last_name: {
|
|
64
|
+
type: "string",
|
|
65
|
+
description: "Employee's last name",
|
|
66
|
+
},
|
|
67
|
+
email: {
|
|
68
|
+
type: "string",
|
|
69
|
+
description: "Employee's email address",
|
|
70
|
+
},
|
|
71
|
+
hourly_rate: {
|
|
72
|
+
type: "number",
|
|
73
|
+
description: "Hourly rate for the employee",
|
|
74
|
+
},
|
|
75
|
+
start_date: {
|
|
76
|
+
type: "string",
|
|
77
|
+
description: "Employment start date in YYYY-MM-DD format",
|
|
78
|
+
},
|
|
79
|
+
end_date: {
|
|
80
|
+
type: "string",
|
|
81
|
+
description: "Employment end date in YYYY-MM-DD format (for terminations)",
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
required: ["user_id"],
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
name: "update_employee",
|
|
89
|
+
description: "Update an existing employee. Requires Bexio Payroll module subscription.",
|
|
90
|
+
inputSchema: {
|
|
91
|
+
type: "object",
|
|
92
|
+
properties: {
|
|
93
|
+
employee_id: {
|
|
94
|
+
type: "integer",
|
|
95
|
+
description: "The ID of the employee to update",
|
|
96
|
+
},
|
|
97
|
+
employee_data: {
|
|
98
|
+
type: "object",
|
|
99
|
+
description: "The data to update on the employee (e.g., hourly_rate, end_date)",
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
required: ["employee_id", "employee_data"],
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
// ===== ABSENCES (PAY-02) =====
|
|
106
|
+
{
|
|
107
|
+
name: "list_absences",
|
|
108
|
+
description: "List employee absences (vacation, sick leave, etc.). Requires Bexio Payroll module subscription. Optional year filter.",
|
|
109
|
+
inputSchema: {
|
|
110
|
+
type: "object",
|
|
111
|
+
properties: {
|
|
112
|
+
year: {
|
|
113
|
+
type: "integer",
|
|
114
|
+
description: "Filter absences by year (e.g., 2024)",
|
|
115
|
+
},
|
|
116
|
+
limit: {
|
|
117
|
+
type: "integer",
|
|
118
|
+
description: "Maximum number of results to return (default: 50)",
|
|
119
|
+
default: 50,
|
|
120
|
+
},
|
|
121
|
+
offset: {
|
|
122
|
+
type: "integer",
|
|
123
|
+
description: "Number of results to skip (default: 0)",
|
|
124
|
+
default: 0,
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
name: "get_absence",
|
|
131
|
+
description: "Get a specific absence record by ID. Requires Bexio Payroll module subscription.",
|
|
132
|
+
inputSchema: {
|
|
133
|
+
type: "object",
|
|
134
|
+
properties: {
|
|
135
|
+
absence_id: {
|
|
136
|
+
type: "integer",
|
|
137
|
+
description: "The ID of the absence to retrieve",
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
required: ["absence_id"],
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
name: "create_absence",
|
|
145
|
+
description: "Create a new absence record (vacation, sick leave, etc.). Requires Bexio Payroll module subscription.",
|
|
146
|
+
inputSchema: {
|
|
147
|
+
type: "object",
|
|
148
|
+
properties: {
|
|
149
|
+
user_id: {
|
|
150
|
+
type: "integer",
|
|
151
|
+
description: "The ID of the user/employee for this absence",
|
|
152
|
+
},
|
|
153
|
+
absence_type_id: {
|
|
154
|
+
type: "integer",
|
|
155
|
+
description: "The type of absence (vacation, sick, etc.) - use list_absences to find types",
|
|
156
|
+
},
|
|
157
|
+
start_date: {
|
|
158
|
+
type: "string",
|
|
159
|
+
description: "Absence start date in YYYY-MM-DD format",
|
|
160
|
+
},
|
|
161
|
+
end_date: {
|
|
162
|
+
type: "string",
|
|
163
|
+
description: "Absence end date in YYYY-MM-DD format",
|
|
164
|
+
},
|
|
165
|
+
half_day_start: {
|
|
166
|
+
type: "boolean",
|
|
167
|
+
description: "True if absence starts at midday (default: false)",
|
|
168
|
+
default: false,
|
|
169
|
+
},
|
|
170
|
+
half_day_end: {
|
|
171
|
+
type: "boolean",
|
|
172
|
+
description: "True if absence ends at midday (default: false)",
|
|
173
|
+
default: false,
|
|
174
|
+
},
|
|
175
|
+
note: {
|
|
176
|
+
type: "string",
|
|
177
|
+
description: "Optional note for this absence",
|
|
178
|
+
},
|
|
179
|
+
},
|
|
180
|
+
required: ["user_id", "absence_type_id", "start_date", "end_date"],
|
|
181
|
+
},
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
name: "update_absence",
|
|
185
|
+
description: "Update an existing absence record. Requires Bexio Payroll module subscription.",
|
|
186
|
+
inputSchema: {
|
|
187
|
+
type: "object",
|
|
188
|
+
properties: {
|
|
189
|
+
absence_id: {
|
|
190
|
+
type: "integer",
|
|
191
|
+
description: "The ID of the absence to update",
|
|
192
|
+
},
|
|
193
|
+
absence_data: {
|
|
194
|
+
type: "object",
|
|
195
|
+
description: "The data to update (e.g., end_date, note)",
|
|
196
|
+
},
|
|
197
|
+
},
|
|
198
|
+
required: ["absence_id", "absence_data"],
|
|
199
|
+
},
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
name: "delete_absence",
|
|
203
|
+
description: "Delete an absence record. Requires Bexio Payroll module subscription.",
|
|
204
|
+
inputSchema: {
|
|
205
|
+
type: "object",
|
|
206
|
+
properties: {
|
|
207
|
+
absence_id: {
|
|
208
|
+
type: "integer",
|
|
209
|
+
description: "The ID of the absence to delete",
|
|
210
|
+
},
|
|
211
|
+
},
|
|
212
|
+
required: ["absence_id"],
|
|
213
|
+
},
|
|
214
|
+
},
|
|
215
|
+
// ===== PAYROLL DOCUMENTS (PAY-03) =====
|
|
216
|
+
{
|
|
217
|
+
name: "list_payroll_documents",
|
|
218
|
+
description: "List payroll documents (payslips, etc.). Requires Bexio Payroll module subscription. Optional employee filter.",
|
|
219
|
+
inputSchema: {
|
|
220
|
+
type: "object",
|
|
221
|
+
properties: {
|
|
222
|
+
employee_id: {
|
|
223
|
+
type: "integer",
|
|
224
|
+
description: "Filter by employee ID to see only their documents",
|
|
225
|
+
},
|
|
226
|
+
limit: {
|
|
227
|
+
type: "integer",
|
|
228
|
+
description: "Maximum number of results to return (default: 50)",
|
|
229
|
+
default: 50,
|
|
230
|
+
},
|
|
231
|
+
offset: {
|
|
232
|
+
type: "integer",
|
|
233
|
+
description: "Number of results to skip (default: 0)",
|
|
234
|
+
default: 0,
|
|
235
|
+
},
|
|
236
|
+
},
|
|
237
|
+
},
|
|
238
|
+
},
|
|
239
|
+
];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Payroll tool handlers.
|
|
3
|
+
* Implements the logic for each payroll tool with module detection.
|
|
4
|
+
*
|
|
5
|
+
* IMPORTANT: Payroll module is conditional - not all Bexio subscriptions include it.
|
|
6
|
+
* Uses probe-on-first-call pattern: attempts listEmployees(limit=1) to detect availability.
|
|
7
|
+
* Result is cached for the session to avoid repeated probes.
|
|
8
|
+
*
|
|
9
|
+
* When module is unavailable (403/404), returns a friendly error message explaining
|
|
10
|
+
* what the payroll module provides and how to enable it in Bexio settings.
|
|
11
|
+
*/
|
|
12
|
+
import { BexioClient } from "../../bexio-client.js";
|
|
13
|
+
export type HandlerFn = (client: BexioClient, args: unknown) => Promise<unknown>;
|
|
14
|
+
export declare const handlers: Record<string, HandlerFn>;
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Payroll tool handlers.
|
|
3
|
+
* Implements the logic for each payroll tool with module detection.
|
|
4
|
+
*
|
|
5
|
+
* IMPORTANT: Payroll module is conditional - not all Bexio subscriptions include it.
|
|
6
|
+
* Uses probe-on-first-call pattern: attempts listEmployees(limit=1) to detect availability.
|
|
7
|
+
* Result is cached for the session to avoid repeated probes.
|
|
8
|
+
*
|
|
9
|
+
* When module is unavailable (403/404), returns a friendly error message explaining
|
|
10
|
+
* what the payroll module provides and how to enable it in Bexio settings.
|
|
11
|
+
*/
|
|
12
|
+
import { McpError } from "../../shared/errors.js";
|
|
13
|
+
import {
|
|
14
|
+
// Employees
|
|
15
|
+
ListEmployeesParamsSchema, GetEmployeeParamsSchema, CreateEmployeeParamsSchema, UpdateEmployeeParamsSchema,
|
|
16
|
+
// Absences
|
|
17
|
+
ListAbsencesParamsSchema, GetAbsenceParamsSchema, CreateAbsenceParamsSchema, UpdateAbsenceParamsSchema, DeleteAbsenceParamsSchema,
|
|
18
|
+
// Payroll Documents
|
|
19
|
+
ListPayrollDocumentsParamsSchema, } from "../../types/index.js";
|
|
20
|
+
import { logger } from "../../logger.js";
|
|
21
|
+
// ===== MODULE AVAILABILITY DETECTION =====
|
|
22
|
+
/**
|
|
23
|
+
* Cached result of payroll module availability check.
|
|
24
|
+
* null = not yet checked, true = available, false = unavailable
|
|
25
|
+
*/
|
|
26
|
+
let payrollModuleAvailable = null;
|
|
27
|
+
/**
|
|
28
|
+
* Check if the Bexio Payroll module is available.
|
|
29
|
+
* Uses probe-on-first-call pattern: attempts a minimal API call to detect access.
|
|
30
|
+
* Result is cached for the session to avoid repeated probes.
|
|
31
|
+
*/
|
|
32
|
+
async function checkPayrollModule(client) {
|
|
33
|
+
// Return cached result if already checked
|
|
34
|
+
if (payrollModuleAvailable !== null) {
|
|
35
|
+
return payrollModuleAvailable;
|
|
36
|
+
}
|
|
37
|
+
try {
|
|
38
|
+
// Probe with a minimal request - just fetch 1 employee
|
|
39
|
+
await client.listEmployees({ limit: 1, offset: 0 });
|
|
40
|
+
logger.debug("Payroll module is available");
|
|
41
|
+
payrollModuleAvailable = true;
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
// Check if the error indicates the module is unavailable
|
|
46
|
+
if (error instanceof McpError) {
|
|
47
|
+
const status = error.statusCode;
|
|
48
|
+
// 403 Forbidden or 404 Not Found typically mean module not enabled
|
|
49
|
+
if (status === 403 || status === 404) {
|
|
50
|
+
logger.debug("Payroll module is not available", { status });
|
|
51
|
+
payrollModuleAvailable = false;
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
// For other errors (network, 500, etc.), don't cache - let them propagate
|
|
56
|
+
throw error;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Create a user-friendly error for when the payroll module is not available.
|
|
61
|
+
* Explains what the module provides and how to enable it.
|
|
62
|
+
*/
|
|
63
|
+
function payrollUnavailableError() {
|
|
64
|
+
return new McpError("BEXIO_API_ERROR", `Payroll module is not enabled for your Bexio account.
|
|
65
|
+
|
|
66
|
+
The Payroll module provides:
|
|
67
|
+
- Employee management (work contracts, hourly rates)
|
|
68
|
+
- Absence tracking (vacation, sick leave, etc.)
|
|
69
|
+
- Payroll documents (payslips, tax statements)
|
|
70
|
+
|
|
71
|
+
To enable the Payroll module:
|
|
72
|
+
1. Go to Bexio Settings > Subscriptions
|
|
73
|
+
2. Select a plan that includes Payroll features
|
|
74
|
+
3. Contact Bexio support if you need help choosing the right plan
|
|
75
|
+
|
|
76
|
+
Note: Payroll features are typically available in Bexio Pro and Enterprise plans.
|
|
77
|
+
Visit https://www.bexio.com/en/pricing for plan details.`, { module: "payroll", available: false });
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Ensure payroll module is available before executing an operation.
|
|
81
|
+
* Throws a friendly error if the module is not enabled.
|
|
82
|
+
*/
|
|
83
|
+
async function ensurePayrollAvailable(client) {
|
|
84
|
+
const available = await checkPayrollModule(client);
|
|
85
|
+
if (!available) {
|
|
86
|
+
throw payrollUnavailableError();
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
// ===== HANDLERS =====
|
|
90
|
+
export const handlers = {
|
|
91
|
+
// ===== EMPLOYEES (PAY-01) =====
|
|
92
|
+
list_employees: async (client, args) => {
|
|
93
|
+
await ensurePayrollAvailable(client);
|
|
94
|
+
const params = ListEmployeesParamsSchema.parse(args);
|
|
95
|
+
return client.listEmployees(params);
|
|
96
|
+
},
|
|
97
|
+
get_employee: async (client, args) => {
|
|
98
|
+
await ensurePayrollAvailable(client);
|
|
99
|
+
const { employee_id } = GetEmployeeParamsSchema.parse(args);
|
|
100
|
+
const employee = await client.getEmployee(employee_id);
|
|
101
|
+
if (!employee) {
|
|
102
|
+
throw McpError.notFound("Employee", employee_id);
|
|
103
|
+
}
|
|
104
|
+
return employee;
|
|
105
|
+
},
|
|
106
|
+
create_employee: async (client, args) => {
|
|
107
|
+
await ensurePayrollAvailable(client);
|
|
108
|
+
const params = CreateEmployeeParamsSchema.parse(args);
|
|
109
|
+
return client.createEmployee(params);
|
|
110
|
+
},
|
|
111
|
+
update_employee: async (client, args) => {
|
|
112
|
+
await ensurePayrollAvailable(client);
|
|
113
|
+
const { employee_id, employee_data } = UpdateEmployeeParamsSchema.parse(args);
|
|
114
|
+
return client.updateEmployee(employee_id, employee_data);
|
|
115
|
+
},
|
|
116
|
+
// ===== ABSENCES (PAY-02) =====
|
|
117
|
+
list_absences: async (client, args) => {
|
|
118
|
+
await ensurePayrollAvailable(client);
|
|
119
|
+
const params = ListAbsencesParamsSchema.parse(args);
|
|
120
|
+
return client.listAbsences(params);
|
|
121
|
+
},
|
|
122
|
+
get_absence: async (client, args) => {
|
|
123
|
+
await ensurePayrollAvailable(client);
|
|
124
|
+
const { absence_id } = GetAbsenceParamsSchema.parse(args);
|
|
125
|
+
const absence = await client.getAbsence(absence_id);
|
|
126
|
+
if (!absence) {
|
|
127
|
+
throw McpError.notFound("Absence", absence_id);
|
|
128
|
+
}
|
|
129
|
+
return absence;
|
|
130
|
+
},
|
|
131
|
+
create_absence: async (client, args) => {
|
|
132
|
+
await ensurePayrollAvailable(client);
|
|
133
|
+
const params = CreateAbsenceParamsSchema.parse(args);
|
|
134
|
+
return client.createAbsence(params);
|
|
135
|
+
},
|
|
136
|
+
update_absence: async (client, args) => {
|
|
137
|
+
await ensurePayrollAvailable(client);
|
|
138
|
+
const { absence_id, absence_data } = UpdateAbsenceParamsSchema.parse(args);
|
|
139
|
+
return client.updateAbsence(absence_id, absence_data);
|
|
140
|
+
},
|
|
141
|
+
delete_absence: async (client, args) => {
|
|
142
|
+
await ensurePayrollAvailable(client);
|
|
143
|
+
const { absence_id } = DeleteAbsenceParamsSchema.parse(args);
|
|
144
|
+
return client.deleteAbsence(absence_id);
|
|
145
|
+
},
|
|
146
|
+
// ===== PAYROLL DOCUMENTS (PAY-03) =====
|
|
147
|
+
list_payroll_documents: async (client, args) => {
|
|
148
|
+
await ensurePayrollAvailable(client);
|
|
149
|
+
const params = ListPayrollDocumentsParamsSchema.parse(args);
|
|
150
|
+
return client.listPayrollDocuments(params);
|
|
151
|
+
},
|
|
152
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Payroll domain module.
|
|
3
|
+
* Exports tool definitions and handlers for payroll operations.
|
|
4
|
+
*
|
|
5
|
+
* CONDITIONAL MODULE: Payroll requires a Bexio subscription with payroll features.
|
|
6
|
+
* All handlers check module availability on first call using probe pattern.
|
|
7
|
+
* When unavailable, returns friendly error with upgrade instructions.
|
|
8
|
+
*
|
|
9
|
+
* PAY-01: Employees - 4 tools (list, get, create, update)
|
|
10
|
+
* PAY-02: Absences - 5 tools (list, get, create, update, delete)
|
|
11
|
+
* PAY-03: Payroll Documents - 1 tool (list)
|
|
12
|
+
*
|
|
13
|
+
* Total: 10 tools
|
|
14
|
+
*/
|
|
15
|
+
export { toolDefinitions } from "./definitions.js";
|
|
16
|
+
export { handlers } from "./handlers.js";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Payroll domain module.
|
|
3
|
+
* Exports tool definitions and handlers for payroll operations.
|
|
4
|
+
*
|
|
5
|
+
* CONDITIONAL MODULE: Payroll requires a Bexio subscription with payroll features.
|
|
6
|
+
* All handlers check module availability on first call using probe pattern.
|
|
7
|
+
* When unavailable, returns friendly error with upgrade instructions.
|
|
8
|
+
*
|
|
9
|
+
* PAY-01: Employees - 4 tools (list, get, create, update)
|
|
10
|
+
* PAY-02: Absences - 5 tools (list, get, create, update, delete)
|
|
11
|
+
* PAY-03: Payroll Documents - 1 tool (list)
|
|
12
|
+
*
|
|
13
|
+
* Total: 10 tools
|
|
14
|
+
*/
|
|
15
|
+
export { toolDefinitions } from "./definitions.js";
|
|
16
|
+
export { handlers } from "./handlers.js";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Projects tool definitions.
|
|
3
|
+
* Contains MCP tool metadata for projects domain.
|
|
4
|
+
* Includes: Projects (CRUD, archive, search), Project Types, Project Statuses, Milestones, Work Packages
|
|
5
|
+
*/
|
|
6
|
+
import type { Tool } from "@modelcontextprotocol/sdk/types.js";
|
|
7
|
+
export declare const toolDefinitions: Tool[];
|