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.
Files changed (51) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +373 -0
  3. package/dist/constants.d.ts +50 -0
  4. package/dist/constants.js +204 -0
  5. package/dist/constants.js.map +1 -0
  6. package/dist/index.d.ts +17 -0
  7. package/dist/index.js +154 -0
  8. package/dist/index.js.map +1 -0
  9. package/dist/instructions.d.ts +11 -0
  10. package/dist/instructions.js +89 -0
  11. package/dist/instructions.js.map +1 -0
  12. package/dist/schemas/common.d.ts +44 -0
  13. package/dist/schemas/common.js +59 -0
  14. package/dist/schemas/common.js.map +1 -0
  15. package/dist/services/client.d.ts +57 -0
  16. package/dist/services/client.js +258 -0
  17. package/dist/services/client.js.map +1 -0
  18. package/dist/services/format.d.ts +70 -0
  19. package/dist/services/format.js +158 -0
  20. package/dist/services/format.js.map +1 -0
  21. package/dist/tools/catalog.d.ts +4 -0
  22. package/dist/tools/catalog.js +74 -0
  23. package/dist/tools/catalog.js.map +1 -0
  24. package/dist/tools/crud.d.ts +51 -0
  25. package/dist/tools/crud.js +152 -0
  26. package/dist/tools/crud.js.map +1 -0
  27. package/dist/tools/customers.d.ts +4 -0
  28. package/dist/tools/customers.js +91 -0
  29. package/dist/tools/customers.js.map +1 -0
  30. package/dist/tools/documents.d.ts +8 -0
  31. package/dist/tools/documents.js +326 -0
  32. package/dist/tools/documents.js.map +1 -0
  33. package/dist/tools/files.d.ts +4 -0
  34. package/dist/tools/files.js +108 -0
  35. package/dist/tools/files.js.map +1 -0
  36. package/dist/tools/finance.d.ts +4 -0
  37. package/dist/tools/finance.js +39 -0
  38. package/dist/tools/finance.js.map +1 -0
  39. package/dist/tools/meta.d.ts +10 -0
  40. package/dist/tools/meta.js +74 -0
  41. package/dist/tools/meta.js.map +1 -0
  42. package/dist/tools/registry.d.ts +39 -0
  43. package/dist/tools/registry.js +56 -0
  44. package/dist/tools/registry.js.map +1 -0
  45. package/dist/tools/search.d.ts +13 -0
  46. package/dist/tools/search.js +243 -0
  47. package/dist/tools/search.js.map +1 -0
  48. package/dist/tools/work.d.ts +4 -0
  49. package/dist/tools/work.js +76 -0
  50. package/dist/tools/work.js.map +1 -0
  51. package/package.json +58 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 stack74
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,373 @@
1
+ # easybill MCP Server
2
+
3
+ An [MCP](https://modelcontextprotocol.io) server for the [easybill REST API](https://www.easybill.de/api/).
4
+ Gives Claude access to your invoices, customers, article catalogue, payments, projects and tracked time.
5
+
6
+ Built on the official [`@modelcontextprotocol/sdk`](https://github.com/modelcontextprotocol/typescript-sdk)
7
+ (TypeScript), talking stdio.
8
+
9
+ - **54 tools** across 12 easybill resources
10
+ - **Read-only by default** — create/update/delete tools stay unregistered unless you opt in
11
+ - **Workflow-aware** — ships server instructions so the agent resolves the customer before
12
+ writing a document, instead of guessing where to start
13
+ - **Fuzzy customer search** the easybill API itself does not offer
14
+ - **Self-throttling** to respect easybill's 10–60 requests/minute cap
15
+ - **Context-aware responses** — compact field sets, pagination metadata, automatic truncation
16
+
17
+ ---
18
+
19
+ ## Setup
20
+
21
+ ### 1. Get an easybill API key
22
+
23
+ In easybill: **Einstellungen → App-Center → API**. Create a key and copy it.
24
+
25
+ ### 2. Build
26
+
27
+ ```bash
28
+ git clone https://github.com/stack74/easybill-mcp.git
29
+ cd easybill-mcp
30
+ npm install
31
+ npm run build
32
+ ```
33
+
34
+ ### 3. Test locally first
35
+
36
+ Copy `.env.example` to `.env`, put your key in it, then run the read-only self-test:
37
+
38
+ ```bash
39
+ cp .env.example .env
40
+ $EDITOR .env
41
+ npm run smoke
42
+ ```
43
+
44
+ It makes five read-only calls and prints what came back:
45
+
46
+ ```
47
+ easybill-mcp-server v1.0.0 self-test
48
+ API: https://api.easybill.de/rest/v1
49
+ Throttle: 60 req/min | writes disabled
50
+
51
+ OK Auth check (customer groups): total=2 first=Stammkunden
52
+ OK Customers: total=42 first=Example GmbH
53
+ OK Invoices: total=128 first=RE-2026-0001
54
+ OK Unpaid invoices: total=7 first=RE-2026-0117
55
+ OK Articles (positions): total=95 first=ART-001
56
+
57
+ All probes passed. The server is ready to register with an MCP client.
58
+ ```
59
+
60
+ (Numbers above are illustrative — you will see your own account's totals.)
61
+
62
+ On a bad key it fails on the first call and stops, so it never burns your rate limit.
63
+
64
+ To poke at individual tools interactively:
65
+
66
+ ```bash
67
+ npm run inspect # MCP Inspector, loads .env
68
+ ```
69
+
70
+ > **Note:** `.env` is only read by these npm scripts, via Node's `--env-file`. The server
71
+ > itself reads plain environment variables — when you register it with an MCP client, pass
72
+ > the key through the client's config as shown below, not via `.env`.
73
+
74
+ ### 4. Register with Claude Code
75
+
76
+ Read-only (recommended to start):
77
+
78
+ ```bash
79
+ claude mcp add easybill \
80
+ --env EASYBILL_API_KEY=your_api_key_here \
81
+ --env EASYBILL_RATE_LIMIT_PER_MINUTE=10 \
82
+ -- node /absolute/path/to/easybill-mcp/dist/index.js
83
+ ```
84
+
85
+ With write access, once you trust it:
86
+
87
+ ```bash
88
+ claude mcp add easybill \
89
+ --env EASYBILL_API_KEY=your_api_key_here \
90
+ --env EASYBILL_RATE_LIMIT_PER_MINUTE=10 \
91
+ --env EASYBILL_ENABLE_WRITES=true \
92
+ -- node /absolute/path/to/easybill-mcp/dist/index.js
93
+ ```
94
+
95
+ Set `EASYBILL_RATE_LIMIT_PER_MINUTE` to **10** on the PLUS plan or **60** on BUSINESS.
96
+
97
+ Verify it connected:
98
+
99
+ ```
100
+ > use easybill_get_server_info
101
+ ```
102
+
103
+ ### 5. Claude Desktop (alternative)
104
+
105
+ Add to `claude_desktop_config.json`:
106
+
107
+ ```json
108
+ {
109
+ "mcpServers": {
110
+ "easybill": {
111
+ "command": "node",
112
+ "args": ["/absolute/path/to/easybill-mcp/dist/index.js"],
113
+ "env": {
114
+ "EASYBILL_API_KEY": "your_api_key_here",
115
+ "EASYBILL_RATE_LIMIT_PER_MINUTE": "10"
116
+ }
117
+ }
118
+ }
119
+ }
120
+ ```
121
+
122
+ ### Installing without cloning
123
+
124
+ Once published to npm, no clone or build is needed — `npx` fetches and runs it:
125
+
126
+ ```bash
127
+ claude mcp add easybill --env EASYBILL_API_KEY=your_key -- npx -y easybill-mcp
128
+ ```
129
+
130
+ Straight from GitHub also works, but is slower (it compiles TypeScript on install
131
+ via the `prepare` script) and needs a toolchain:
132
+
133
+ ```bash
134
+ claude mcp add easybill --env EASYBILL_API_KEY=your_key -- npx -y github:stack74/easybill-mcp
135
+ ```
136
+
137
+ ### Publishing to npm
138
+
139
+ ```bash
140
+ npm login # once, needs an npmjs.com account
141
+ npm run build && npm run smoke
142
+ npm publish # unscoped packages are public by default
143
+ ```
144
+
145
+ Verify what ships before you publish — `npm pack --dry-run` lists the tarball contents.
146
+ Only `dist/`, `README.md`, `LICENSE` and `package.json` are included; `src/` and `.env`
147
+ are not.
148
+
149
+ For later releases bump the version first (`npm version patch|minor|major`), which also
150
+ creates a git tag. npm does not allow republishing an existing version.
151
+
152
+ ---
153
+
154
+ ## Configuration
155
+
156
+ | Variable | Default | Purpose |
157
+ |---|---|---|
158
+ | `EASYBILL_API_KEY` | — | **Required.** Your easybill API key. |
159
+ | `EASYBILL_ENABLE_WRITES` | *unset* | Set to `true` to register create/update/delete tools. Otherwise read-only. |
160
+ | `EASYBILL_RATE_LIMIT_PER_MINUTE` | `60` | Client-side throttle. Use `10` for PLUS, `60` for BUSINESS. |
161
+ | `EASYBILL_CHARACTER_LIMIT` | `25000` | Max characters per response before truncation. |
162
+ | `EASYBILL_TIMEOUT_MS` | `30000` | HTTP request timeout. |
163
+ | `EASYBILL_MAX_RETRIES` | `3` | Retries on HTTP 429 / 5xx. |
164
+ | `EASYBILL_BASE_URL` | easybill production | Override for a proxy or test double. |
165
+
166
+ ---
167
+
168
+ ## Tools
169
+
170
+ ### Customer lookup
171
+
172
+ | Tool | Access |
173
+ |---|---|
174
+ | `easybill_find_customer` | read — **start here**: fuzzy search by name, email or number |
175
+
176
+ The easybill API has no full-text search, so this tool tries exact filters first, then pages
177
+ the customer list and scores candidates locally. It tolerates legal forms (`GmbH & Co. KG`),
178
+ punctuation (`M.B. MUSTERMANN` vs `MB Mustermann`), umlauts and word order.
179
+
180
+ ### Documents — invoices, offers, credit notes, deliveries, orders
181
+
182
+ | Tool | Access |
183
+ |---|---|
184
+ | `easybill_list_documents` | read |
185
+ | `easybill_get_document` | read |
186
+ | `easybill_download_document` | read — saves PDF / ZUGFeRD / XRechnung to disk |
187
+ | `easybill_list_document_versions` | read — audit trail |
188
+ | `easybill_create_document` | write |
189
+ | `easybill_update_document` | write |
190
+ | `easybill_complete_document` | write — finalises a draft, assigns the invoice number |
191
+ | `easybill_cancel_document` | write — creates a STORNO document |
192
+ | `easybill_convert_document` | write — OFFER → INVOICE, INVOICE → DUNNING, … |
193
+ | `easybill_send_document` | write — **sends real email / fax / post** |
194
+ | `easybill_delete_document` | write, destructive |
195
+
196
+ ### Customers, contacts, groups
197
+
198
+ `easybill_list_customers`, `easybill_get_customer`, `easybill_create_customer`,
199
+ `easybill_update_customer`, `easybill_delete_customer`,
200
+ `easybill_list_contacts`, `easybill_get_contact`, `easybill_create_contact`,
201
+ `easybill_update_contact`, `easybill_delete_contact`,
202
+ `easybill_list_customer_groups`, `easybill_get_customer_group`
203
+
204
+ ### Article catalogue and stock
205
+
206
+ `easybill_list_positions`, `easybill_get_position`, `easybill_create_position`,
207
+ `easybill_update_position`, `easybill_delete_position`,
208
+ `easybill_list_stock_entries`, `easybill_get_stock_entry`, `easybill_create_stock_entry`
209
+
210
+ ### Payments
211
+
212
+ `easybill_list_document_payments`, `easybill_get_document_payment`,
213
+ `easybill_create_document_payment`, `easybill_delete_document_payment`
214
+
215
+ ### Projects and time tracking
216
+
217
+ `easybill_list_projects`, `easybill_get_project`, `easybill_create_project`,
218
+ `easybill_update_project`, `easybill_delete_project`,
219
+ `easybill_list_time_trackings`, `easybill_get_time_tracking`,
220
+ `easybill_create_time_tracking`, `easybill_update_time_tracking`, `easybill_delete_time_tracking`
221
+
222
+ ### Attachments and templates
223
+
224
+ `easybill_list_attachments`, `easybill_get_attachment`, `easybill_download_attachment`,
225
+ `easybill_delete_attachment`, `easybill_list_text_templates`, `easybill_get_text_template`,
226
+ `easybill_list_pdf_templates`
227
+
228
+ ### Server
229
+
230
+ `easybill_get_server_info` — reports mode, limits and whether the credentials work.
231
+
232
+ ---
233
+
234
+ ## Things worth knowing
235
+
236
+ ### The server tells the agent how to sequence work
237
+
238
+ A plain set of endpoint wrappers leads agents astray. Handed an inbound customer inquiry,
239
+ Claude's first instinct was to call `easybill_list_documents` — which cannot answer the actual
240
+ first question, *is this company already a customer?*
241
+
242
+ The server therefore ships MCP **server instructions** (see `src/instructions.ts`) with the
243
+ ordering for common tasks, and `easybill_create_document` opens with the same sequence:
244
+
245
+ ```
246
+ 1. easybill_find_customer — does the customer exist?
247
+ 2. easybill_create_customer — only if not
248
+ 3. easybill_create_document — creates a DRAFT
249
+ 4. review with the user
250
+ 5. easybill_complete_document — assigns the official number, locks it
251
+ 6. easybill_send_document — only when explicitly asked
252
+ ```
253
+
254
+ `easybill_list_documents` explicitly says it is *not* the tool for orienting yourself. If you
255
+ extend this server, keep that pattern: state prerequisites at the top of the description of
256
+ the tool an agent will reach for first.
257
+
258
+ ### All money is in cents
259
+
260
+ easybill represents every monetary value as an **integer in cents**, even where the API
261
+ types it as a float. `1999` means **19.99 EUR**. This is stated in every tool description
262
+ that touches an amount, because getting it wrong produces invoices off by 100×.
263
+
264
+ Times in time tracking (`timer_value`) are in **minutes**.
265
+
266
+ ### Drafts vs. completed documents
267
+
268
+ `easybill_create_document` produces a **draft**. It has no official document number and can
269
+ still be edited. Call `easybill_complete_document` to finalise it — easybill then assigns the
270
+ number and locks it.
271
+
272
+ To void a completed invoice, use `easybill_cancel_document` (which creates a proper STORNO
273
+ document), not `easybill_delete_document`. Completed invoices generally cannot be deleted for
274
+ legal reasons.
275
+
276
+ ### Rate limits are low
277
+
278
+ easybill allows **10 requests/minute on PLUS** and **60 on BUSINESS**. The server throttles
279
+ itself to `EASYBILL_RATE_LIMIT_PER_MINUTE` and, if a 429 slips through, retries while honouring
280
+ `Retry-After`. Set the variable to match your plan — otherwise a broad question that pages
281
+ through many documents will stall.
282
+
283
+ Because of this, prefer narrow filters over paging: `easybill_list_documents` with
284
+ `type='INVOICE'` and `paid_at='null'` costs one request, where scanning everything costs dozens.
285
+
286
+ ### Context management
287
+
288
+ `Document` has 69 fields and `Customer` 79. List tools therefore return a **compact default
289
+ field set**, and single-record lookups return everything. Both accept `fields`:
290
+
291
+ - omit it → compact defaults
292
+ - `fields: ["number", "amount"]` → just those (plus `id`)
293
+ - `fields: ["all"]` → every field
294
+
295
+ Responses over `EASYBILL_CHARACTER_LIMIT` are truncated, halving the item count until they
296
+ fit, and say so in `truncation_message`.
297
+
298
+ ### No fuzzy customer search
299
+
300
+ The easybill API has no full-text search. Customer filters match **exact** values (each
301
+ accepts several comma-separated). To find a customer by partial name, either use the exact
302
+ spelling or page through and match locally.
303
+
304
+ ### Useful filter recipes
305
+
306
+ | Question | Call |
307
+ |---|---|
308
+ | Which invoices are unpaid? | `easybill_list_documents` `type='INVOICE'`, `paid_at='null'` |
309
+ | Revenue in 2025? | `easybill_list_documents` `type='INVOICE'`, `document_date='2025-01-01,2025-12-31'` |
310
+ | One customer's history | `easybill_list_documents` `customer_id=<id>` |
311
+ | Only real, non-cancelled invoices | add `is_draft='0'`, `cancel_id='null'` |
312
+ | Unbilled tracked time | `easybill_list_time_trackings`, then filter `cleared_at = null` |
313
+
314
+ ---
315
+
316
+ ## Development
317
+
318
+ ```bash
319
+ npm run build # compile to dist/
320
+ npm run typecheck # tsc --noEmit
321
+ npm run dev # watch mode
322
+ npm run smoke # read-only self-test against the live API (needs .env)
323
+ npm run inspect # MCP Inspector against the built server (needs .env)
324
+ ```
325
+
326
+ Project layout:
327
+
328
+ ```
329
+ src/
330
+ ├── index.ts entry point, stdio transport, env validation, --selftest
331
+ ├── instructions.ts MCP server instructions: workflow ordering for the agent
332
+ ├── constants.ts config, summary field sets, enums
333
+ ├── schemas/common.ts shared Zod building blocks
334
+ ├── services/
335
+ │ ├── client.ts HTTP, auth, throttling, retries, error mapping
336
+ │ └── format.ts field selection, pagination, markdown, truncation
337
+ └── tools/
338
+ ├── registry.ts registration + write-gating
339
+ ├── crud.ts generic CRUD tool factory
340
+ ├── search.ts fuzzy customer lookup
341
+ ├── documents.ts documents + lifecycle actions
342
+ ├── customers.ts customers, contacts, groups
343
+ ├── catalog.ts positions, stock
344
+ ├── finance.ts payments
345
+ ├── work.ts projects, time tracking
346
+ ├── files.ts attachments, templates
347
+ └── meta.ts server info
348
+ ```
349
+
350
+ Most resources are generated from a declarative config in `crud.ts`; only genuinely
351
+ resource-specific behaviour (document lifecycle, downloads, sending) is hand-written.
352
+
353
+ ## Contributing
354
+
355
+ Issues and pull requests welcome. The tool surface is derived from easybill's official
356
+ OpenAPI spec (`https://api.easybill.de/rest/v1/swagger.json`) — when adding a tool, check
357
+ field names and types against the spec rather than guessing, and mind that monetary fields
358
+ are cents even where the spec types them as floats.
359
+
360
+ ## Disclaimer
361
+
362
+ This is an **unofficial**, community-maintained project. It is not affiliated with,
363
+ endorsed by, or supported by easybill GmbH. "easybill" is a trademark of its respective
364
+ owner and is used here only to describe what this software talks to.
365
+
366
+ The software is provided as-is under the MIT license, without warranty. It can create,
367
+ modify and delete records in your accounting system, and can send invoices to your
368
+ customers. You are responsible for what you let it do — start read-only, and review what
369
+ write tools produce before relying on it.
370
+
371
+ ## License
372
+
373
+ [MIT](LICENSE) © stack74
@@ -0,0 +1,50 @@
1
+ /** Shared constants and runtime configuration for the easybill MCP server. */
2
+ /** Overridable so the server can be pointed at a proxy or a test double. */
3
+ export declare const API_BASE_URL: string;
4
+ export declare const SERVER_NAME = "easybill-mcp-server";
5
+ export declare const SERVER_VERSION = "1.0.0";
6
+ /** Maximum characters in a single tool response before it gets truncated. */
7
+ export declare const CHARACTER_LIMIT: number;
8
+ /** HTTP request timeout. */
9
+ export declare const TIMEOUT_MS: number;
10
+ /**
11
+ * Client-side throttle. easybill allows 10 req/min (PLUS) and 60 req/min (BUSINESS).
12
+ * Throttling locally is cheaper than burning retries on HTTP 429.
13
+ */
14
+ export declare const RATE_LIMIT_PER_MINUTE: number;
15
+ /** Retries for a 429 / transient network failure. */
16
+ export declare const MAX_RETRIES: number;
17
+ /** Create/update/delete tools are only registered when this is explicitly enabled. */
18
+ export declare const WRITES_ENABLED: boolean;
19
+ /**
20
+ * easybill expects and returns all dates in Europe/Berlin.
21
+ * date = Y-m-d e.g. 2016-12-31
22
+ * datetime = Y-m-d H:i:s e.g. 2016-12-31 03:13:37
23
+ */
24
+ export declare const DATE_HINT = "Format YYYY-MM-DD (timezone Europe/Berlin)";
25
+ export declare const DATE_RANGE_HINT = "Single date 'YYYY-MM-DD' or an inclusive range 'YYYY-MM-DD,YYYY-MM-DD'";
26
+ /** Document types used across the documents API. */
27
+ export declare const DOCUMENT_TYPES: readonly ["INVOICE", "RECURRING", "CREDIT", "OFFER", "REMINDER", "DUNNING", "STORNO", "STORNO_CREDIT", "DELIVERY", "PDF", "CHARGE", "CHARGE_CONFIRM", "LETTER", "ORDER", "PROFORMA_INVOICE", "STORNO_PROFORMA_INVOICE"];
28
+ /** Types an existing document can be converted into. */
29
+ export declare const CONVERTIBLE_TYPES: readonly ["DUNNING", "REMINDER", "CHARGE_CONFIRM", "CHARGE", "CREDIT", "DELIVERY", "INVOICE", "ORDER"];
30
+ /**
31
+ * Compact field sets for list responses. Document has 69 and Customer 79 fields;
32
+ * returning them all for 100 rows floods the agent's context with no benefit.
33
+ * Callers can override with `fields` (explicit list) or `fields: ["all"]`.
34
+ */
35
+ export declare const SUMMARY_FIELDS: {
36
+ readonly document: readonly ["id", "number", "type", "status", "title", "document_date", "due_date", "customer_id", "project_id", "amount", "amount_net", "currency", "paid_amount", "paid_at", "is_draft", "is_archive", "cancel_id"];
37
+ readonly customer: readonly ["id", "number", "display_name", "company_name", "first_name", "last_name", "emails", "phone_1", "street", "zip_code", "city", "country", "group_id", "vat_identifier", "archived"];
38
+ readonly position: readonly ["id", "number", "type", "description", "unit", "sale_price", "cost_price", "vat_percent", "price_type", "group_id", "stock", "stock_count", "archived"];
39
+ readonly contact: readonly ["id", "company_name", "salutation", "first_name", "last_name", "department", "emails", "phone_1", "mobile", "street", "zip_code", "city", "country"];
40
+ readonly project: readonly ["id", "name", "customer_id", "status", "due_at", "hourly_rate", "budget_amount", "budget_time", "consumed_amount", "consumed_time"];
41
+ readonly payment: readonly ["id", "document_id", "amount", "payment_at", "type", "provider", "reference", "notice", "is_overdue_fee", "login_id"];
42
+ readonly timeTracking: readonly ["id", "number", "description", "date_from_at", "date_thru_at", "timer_value", "hourly_rate", "position_id", "project_id", "cleared_at", "login_id"];
43
+ readonly attachment: readonly ["id", "file_name", "size", "created_at", "document_id", "customer_id", "project_id"];
44
+ readonly task: readonly ["id", "name", "status", "status_percent", "priority", "category", "start_at", "end_at", "finish_at", "customer_id", "project_id", "login_id"];
45
+ readonly stock: readonly ["id", "position_id", "stock_count", "note", "stored_at", "created_at", "document_id", "document_position_id"];
46
+ readonly textTemplate: readonly ["id", "title", "text", "can_modify"];
47
+ readonly customerGroup: readonly ["id", "number", "name", "display_name", "description"];
48
+ readonly serialNumber: readonly ["id", "serial_number", "position_id", "document_id", "used_at", "created_at"];
49
+ readonly pdfTemplate: readonly ["id", "name", "pdf_template", "document_type"];
50
+ };
@@ -0,0 +1,204 @@
1
+ /** Shared constants and runtime configuration for the easybill MCP server. */
2
+ /** Overridable so the server can be pointed at a proxy or a test double. */
3
+ export const API_BASE_URL = (process.env.EASYBILL_BASE_URL?.trim() || "https://api.easybill.de/rest/v1").replace(/\/+$/, "");
4
+ export const SERVER_NAME = "easybill-mcp-server";
5
+ export const SERVER_VERSION = "1.0.0";
6
+ function intFromEnv(name, fallback, min) {
7
+ const raw = process.env[name];
8
+ if (!raw)
9
+ return fallback;
10
+ const parsed = Number.parseInt(raw, 10);
11
+ if (Number.isNaN(parsed) || parsed < min)
12
+ return fallback;
13
+ return parsed;
14
+ }
15
+ /** Maximum characters in a single tool response before it gets truncated. */
16
+ export const CHARACTER_LIMIT = intFromEnv("EASYBILL_CHARACTER_LIMIT", 25_000, 1_000);
17
+ /** HTTP request timeout. */
18
+ export const TIMEOUT_MS = intFromEnv("EASYBILL_TIMEOUT_MS", 30_000, 1_000);
19
+ /**
20
+ * Client-side throttle. easybill allows 10 req/min (PLUS) and 60 req/min (BUSINESS).
21
+ * Throttling locally is cheaper than burning retries on HTTP 429.
22
+ */
23
+ export const RATE_LIMIT_PER_MINUTE = intFromEnv("EASYBILL_RATE_LIMIT_PER_MINUTE", 60, 1);
24
+ /** Retries for a 429 / transient network failure. */
25
+ export const MAX_RETRIES = intFromEnv("EASYBILL_MAX_RETRIES", 3, 0);
26
+ /** Create/update/delete tools are only registered when this is explicitly enabled. */
27
+ export const WRITES_ENABLED = /^(1|true|yes)$/i.test(process.env.EASYBILL_ENABLE_WRITES ?? "");
28
+ /**
29
+ * easybill expects and returns all dates in Europe/Berlin.
30
+ * date = Y-m-d e.g. 2016-12-31
31
+ * datetime = Y-m-d H:i:s e.g. 2016-12-31 03:13:37
32
+ */
33
+ export const DATE_HINT = "Format YYYY-MM-DD (timezone Europe/Berlin)";
34
+ export const DATE_RANGE_HINT = "Single date 'YYYY-MM-DD' or an inclusive range 'YYYY-MM-DD,YYYY-MM-DD'";
35
+ /** Document types used across the documents API. */
36
+ export const DOCUMENT_TYPES = [
37
+ "INVOICE",
38
+ "RECURRING",
39
+ "CREDIT",
40
+ "OFFER",
41
+ "REMINDER",
42
+ "DUNNING",
43
+ "STORNO",
44
+ "STORNO_CREDIT",
45
+ "DELIVERY",
46
+ "PDF",
47
+ "CHARGE",
48
+ "CHARGE_CONFIRM",
49
+ "LETTER",
50
+ "ORDER",
51
+ "PROFORMA_INVOICE",
52
+ "STORNO_PROFORMA_INVOICE",
53
+ ];
54
+ /** Types an existing document can be converted into. */
55
+ export const CONVERTIBLE_TYPES = [
56
+ "DUNNING",
57
+ "REMINDER",
58
+ "CHARGE_CONFIRM",
59
+ "CHARGE",
60
+ "CREDIT",
61
+ "DELIVERY",
62
+ "INVOICE",
63
+ "ORDER",
64
+ ];
65
+ /**
66
+ * Compact field sets for list responses. Document has 69 and Customer 79 fields;
67
+ * returning them all for 100 rows floods the agent's context with no benefit.
68
+ * Callers can override with `fields` (explicit list) or `fields: ["all"]`.
69
+ */
70
+ export const SUMMARY_FIELDS = {
71
+ document: [
72
+ "id",
73
+ "number",
74
+ "type",
75
+ "status",
76
+ "title",
77
+ "document_date",
78
+ "due_date",
79
+ "customer_id",
80
+ "project_id",
81
+ "amount",
82
+ "amount_net",
83
+ "currency",
84
+ "paid_amount",
85
+ "paid_at",
86
+ "is_draft",
87
+ "is_archive",
88
+ "cancel_id",
89
+ ],
90
+ customer: [
91
+ "id",
92
+ "number",
93
+ "display_name",
94
+ "company_name",
95
+ "first_name",
96
+ "last_name",
97
+ "emails",
98
+ "phone_1",
99
+ "street",
100
+ "zip_code",
101
+ "city",
102
+ "country",
103
+ "group_id",
104
+ "vat_identifier",
105
+ "archived",
106
+ ],
107
+ position: [
108
+ "id",
109
+ "number",
110
+ "type",
111
+ "description",
112
+ "unit",
113
+ "sale_price",
114
+ "cost_price",
115
+ "vat_percent",
116
+ "price_type",
117
+ "group_id",
118
+ "stock",
119
+ "stock_count",
120
+ "archived",
121
+ ],
122
+ contact: [
123
+ "id",
124
+ "company_name",
125
+ "salutation",
126
+ "first_name",
127
+ "last_name",
128
+ "department",
129
+ "emails",
130
+ "phone_1",
131
+ "mobile",
132
+ "street",
133
+ "zip_code",
134
+ "city",
135
+ "country",
136
+ ],
137
+ project: [
138
+ "id",
139
+ "name",
140
+ "customer_id",
141
+ "status",
142
+ "due_at",
143
+ "hourly_rate",
144
+ "budget_amount",
145
+ "budget_time",
146
+ "consumed_amount",
147
+ "consumed_time",
148
+ ],
149
+ payment: [
150
+ "id",
151
+ "document_id",
152
+ "amount",
153
+ "payment_at",
154
+ "type",
155
+ "provider",
156
+ "reference",
157
+ "notice",
158
+ "is_overdue_fee",
159
+ "login_id",
160
+ ],
161
+ timeTracking: [
162
+ "id",
163
+ "number",
164
+ "description",
165
+ "date_from_at",
166
+ "date_thru_at",
167
+ "timer_value",
168
+ "hourly_rate",
169
+ "position_id",
170
+ "project_id",
171
+ "cleared_at",
172
+ "login_id",
173
+ ],
174
+ attachment: ["id", "file_name", "size", "created_at", "document_id", "customer_id", "project_id"],
175
+ task: [
176
+ "id",
177
+ "name",
178
+ "status",
179
+ "status_percent",
180
+ "priority",
181
+ "category",
182
+ "start_at",
183
+ "end_at",
184
+ "finish_at",
185
+ "customer_id",
186
+ "project_id",
187
+ "login_id",
188
+ ],
189
+ stock: [
190
+ "id",
191
+ "position_id",
192
+ "stock_count",
193
+ "note",
194
+ "stored_at",
195
+ "created_at",
196
+ "document_id",
197
+ "document_position_id",
198
+ ],
199
+ textTemplate: ["id", "title", "text", "can_modify"],
200
+ customerGroup: ["id", "number", "name", "display_name", "description"],
201
+ serialNumber: ["id", "serial_number", "position_id", "document_id", "used_at", "created_at"],
202
+ pdfTemplate: ["id", "name", "pdf_template", "document_type"],
203
+ };
204
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAE9E,4EAA4E;AAC5E,MAAM,CAAC,MAAM,YAAY,GAAG,CAC1B,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAE,IAAI,EAAE,IAAI,iCAAiC,CAC3E,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AAEtB,MAAM,CAAC,MAAM,WAAW,GAAG,qBAAqB,CAAC;AACjD,MAAM,CAAC,MAAM,cAAc,GAAG,OAAO,CAAC;AAEtC,SAAS,UAAU,CAAC,IAAY,EAAE,QAAgB,EAAE,GAAW;IAC7D,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC9B,IAAI,CAAC,GAAG;QAAE,OAAO,QAAQ,CAAC;IAC1B,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;IACxC,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,MAAM,GAAG,GAAG;QAAE,OAAO,QAAQ,CAAC;IAC1D,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,6EAA6E;AAC7E,MAAM,CAAC,MAAM,eAAe,GAAG,UAAU,CAAC,0BAA0B,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;AAErF,4BAA4B;AAC5B,MAAM,CAAC,MAAM,UAAU,G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IAAI;QACJ,aAAa;QACb,aAAa;QACb,MAAM;QACN,WAAW;QACX,YAAY;QACZ,aAAa;QACb,sBAAsB;KACvB;IACD,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,CAAC;IACnD,aAAa,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,cAAc,EAAE,aAAa,CAAC;IACtE,YAAY,EAAE,CAAC,IAAI,EAAE,eAAe,EAAE,aAAa,EAAE,aAAa,EAAE,SAAS,EAAE,YAAY,CAAC;IAC5F,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,cAAc,EAAE,eAAe,CAAC;CACpD,CAAC"}
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * MCP server for the easybill REST API.
4
+ *
5
+ * Exposes invoices and other documents, customers, contacts, the article
6
+ * catalogue, payments, projects, time tracking, attachments and templates.
7
+ *
8
+ * Transport: stdio (local). Never log to stdout — it carries the MCP protocol.
9
+ *
10
+ * Environment:
11
+ * EASYBILL_API_KEY (required)
12
+ * EASYBILL_ENABLE_WRITES (optional, default off — read-only)
13
+ * EASYBILL_RATE_LIMIT_PER_MINUTE (optional, default 60)
14
+ * EASYBILL_CHARACTER_LIMIT (optional, default 25000)
15
+ * EASYBILL_TIMEOUT_MS (optional, default 30000)
16
+ */
17
+ export {};