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
package/dist/index.js
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
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
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
18
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
19
|
+
import { API_BASE_URL, RATE_LIMIT_PER_MINUTE, SERVER_NAME, SERVER_VERSION, WRITES_ENABLED, } from "./constants.js";
|
|
20
|
+
import { SERVER_INSTRUCTIONS } from "./instructions.js";
|
|
21
|
+
import { EasybillClient, formatApiError } from "./services/client.js";
|
|
22
|
+
import { registerCatalogTools } from "./tools/catalog.js";
|
|
23
|
+
import { registerCustomerTools } from "./tools/customers.js";
|
|
24
|
+
import { registerDocumentTools } from "./tools/documents.js";
|
|
25
|
+
import { registerFileTools } from "./tools/files.js";
|
|
26
|
+
import { registerFinanceTools } from "./tools/finance.js";
|
|
27
|
+
import { registerMetaTools } from "./tools/meta.js";
|
|
28
|
+
import { registrationStats } from "./tools/registry.js";
|
|
29
|
+
import { registerSearchTools } from "./tools/search.js";
|
|
30
|
+
import { registerWorkTools } from "./tools/work.js";
|
|
31
|
+
const USAGE = `${SERVER_NAME} v${SERVER_VERSION}
|
|
32
|
+
|
|
33
|
+
An MCP server for the easybill REST API (https://www.easybill.de/api/).
|
|
34
|
+
Speaks the Model Context Protocol over stdio; run it from an MCP client, not by hand.
|
|
35
|
+
|
|
36
|
+
Required environment:
|
|
37
|
+
EASYBILL_API_KEY Your easybill API key.
|
|
38
|
+
Get one in easybill under Einstellungen -> App-Center -> API.
|
|
39
|
+
|
|
40
|
+
Optional environment:
|
|
41
|
+
EASYBILL_ENABLE_WRITES=true Enable create/update/delete tools. Default: read-only.
|
|
42
|
+
EASYBILL_RATE_LIMIT_PER_MINUTE Client-side throttle. Use 10 for PLUS, 60 for BUSINESS.
|
|
43
|
+
EASYBILL_CHARACTER_LIMIT Max characters per response before truncation (default 25000).
|
|
44
|
+
EASYBILL_TIMEOUT_MS HTTP timeout in milliseconds (default 30000).
|
|
45
|
+
EASYBILL_MAX_RETRIES Retries on 429/5xx (default 3).
|
|
46
|
+
|
|
47
|
+
Flags:
|
|
48
|
+
--help, -h Show this help.
|
|
49
|
+
--version, -v Print the version.
|
|
50
|
+
--selftest Make a few READ-ONLY calls against easybill and report what came back.
|
|
51
|
+
Verifies credentials and connectivity without an MCP client.
|
|
52
|
+
|
|
53
|
+
Register with Claude Code:
|
|
54
|
+
claude mcp add easybill --env EASYBILL_API_KEY=your_key -- node ${process.argv[1] ?? "dist/index.js"}
|
|
55
|
+
`;
|
|
56
|
+
/**
|
|
57
|
+
* Read-only smoke test against the live API.
|
|
58
|
+
*
|
|
59
|
+
* Prints to stdout because this mode is meant to be run by a human in a terminal,
|
|
60
|
+
* never inside an MCP session.
|
|
61
|
+
*/
|
|
62
|
+
async function selftest(client) {
|
|
63
|
+
const log = (line) => void process.stdout.write(`${line}\n`);
|
|
64
|
+
log(`${SERVER_NAME} v${SERVER_VERSION} self-test`);
|
|
65
|
+
log(`API: ${API_BASE_URL}`);
|
|
66
|
+
log(`Throttle: ${RATE_LIMIT_PER_MINUTE} req/min | writes ${WRITES_ENABLED ? "ENABLED" : "disabled"}`);
|
|
67
|
+
log("");
|
|
68
|
+
// Ordered cheapest-first so an auth failure costs a single request.
|
|
69
|
+
const probes = [
|
|
70
|
+
{ label: "Auth check (customer groups)", path: "/customer-groups", query: { limit: 1 } },
|
|
71
|
+
{ label: "Customers", path: "/customers", query: { limit: 3 } },
|
|
72
|
+
{ label: "Invoices", path: "/documents", query: { limit: 3, type: "INVOICE" } },
|
|
73
|
+
{ label: "Unpaid invoices", path: "/documents", query: { limit: 1, type: "INVOICE", paid_at: "null" } },
|
|
74
|
+
{ label: "Articles (positions)", path: "/positions", query: { limit: 3 } },
|
|
75
|
+
];
|
|
76
|
+
let failures = 0;
|
|
77
|
+
for (const probe of probes) {
|
|
78
|
+
try {
|
|
79
|
+
const list = await client.request(probe.path, {
|
|
80
|
+
...(probe.query ? { query: probe.query } : {}),
|
|
81
|
+
});
|
|
82
|
+
const total = list?.total ?? 0;
|
|
83
|
+
const sample = list?.items?.[0];
|
|
84
|
+
const label = sample === undefined
|
|
85
|
+
? "(none in account)"
|
|
86
|
+
: String(sample.display_name ?? sample.number ?? sample.name ?? sample.title ?? `id ${String(sample.id)}`);
|
|
87
|
+
log(` OK ${probe.label}: total=${total} first=${label}`);
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
failures++;
|
|
91
|
+
log(` FAIL ${probe.label}: ${formatApiError(error)}`);
|
|
92
|
+
// A bad key fails every probe — stop rather than burning the rate limit.
|
|
93
|
+
if (failures === 1 && probe.path === "/customer-groups") {
|
|
94
|
+
log("\nAuth failed on the first call, skipping the rest.");
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
log("");
|
|
100
|
+
if (failures === 0) {
|
|
101
|
+
log("All probes passed. The server is ready to register with an MCP client.");
|
|
102
|
+
return 0;
|
|
103
|
+
}
|
|
104
|
+
log(`${failures} probe(s) failed — see the messages above.`);
|
|
105
|
+
return 1;
|
|
106
|
+
}
|
|
107
|
+
async function main() {
|
|
108
|
+
if (process.argv.includes("--help") || process.argv.includes("-h")) {
|
|
109
|
+
process.stdout.write(USAGE);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
if (process.argv.includes("--version") || process.argv.includes("-v")) {
|
|
113
|
+
process.stdout.write(`${SERVER_VERSION}\n`);
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
const apiKey = process.env.EASYBILL_API_KEY?.trim();
|
|
117
|
+
if (!apiKey) {
|
|
118
|
+
console.error("ERROR: EASYBILL_API_KEY environment variable is required.\n" +
|
|
119
|
+
"Create an API key in easybill under Einstellungen -> App-Center -> API,\n" +
|
|
120
|
+
"then pass it to the server, e.g.:\n" +
|
|
121
|
+
" claude mcp add easybill --env EASYBILL_API_KEY=your_key -- node /path/to/dist/index.js\n\n" +
|
|
122
|
+
"Run with --help for all options.");
|
|
123
|
+
process.exit(1);
|
|
124
|
+
}
|
|
125
|
+
const client = new EasybillClient(apiKey);
|
|
126
|
+
if (process.argv.includes("--selftest")) {
|
|
127
|
+
process.exitCode = await selftest(client);
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
const server = new McpServer({ name: SERVER_NAME, version: SERVER_VERSION }, { instructions: SERVER_INSTRUCTIONS });
|
|
131
|
+
// Customer lookup registers first: resolving who the customer is comes before
|
|
132
|
+
// anything else in almost every real task.
|
|
133
|
+
registerSearchTools(server, client);
|
|
134
|
+
registerCustomerTools(server, client);
|
|
135
|
+
registerDocumentTools(server, client);
|
|
136
|
+
registerCatalogTools(server, client);
|
|
137
|
+
registerFinanceTools(server, client);
|
|
138
|
+
registerWorkTools(server, client);
|
|
139
|
+
registerFileTools(server, client);
|
|
140
|
+
registerMetaTools(server, client);
|
|
141
|
+
const transport = new StdioServerTransport();
|
|
142
|
+
await server.connect(transport);
|
|
143
|
+
// stderr only — stdout is the protocol channel.
|
|
144
|
+
console.error(`${SERVER_NAME} v${SERVER_VERSION} ready on stdio | ` +
|
|
145
|
+
`${registrationStats.read} read + ${registrationStats.write} write tools | ` +
|
|
146
|
+
`writes ${WRITES_ENABLED ? "ENABLED" : "disabled (read-only)"}` +
|
|
147
|
+
(WRITES_ENABLED ? "" : ` — ${registrationStats.skipped} write tools withheld`) +
|
|
148
|
+
` | throttle ${RATE_LIMIT_PER_MINUTE} req/min`);
|
|
149
|
+
}
|
|
150
|
+
main().catch((error) => {
|
|
151
|
+
console.error(`Fatal error: ${error instanceof Error ? error.message : String(error)}`);
|
|
152
|
+
process.exit(1);
|
|
153
|
+
});
|
|
154
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EACL,YAAY,EACZ,qBAAqB,EACrB,WAAW,EACX,cAAc,EACd,cAAc,GACf,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,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AAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACxF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server-level instructions, sent to the client during initialization.
|
|
3
|
+
*
|
|
4
|
+
* Individual tool descriptions explain single endpoints well, but they cannot tell
|
|
5
|
+
* an agent where to START. Without this, a request like "make an offer for this
|
|
6
|
+
* inquiry" tends to open with a broad easybill_list_documents call — wasted requests
|
|
7
|
+
* against a 10/min rate limit, and the wrong first question.
|
|
8
|
+
*
|
|
9
|
+
* Keep this focused on ordering and decision points, not field reference.
|
|
10
|
+
*/
|
|
11
|
+
export declare const SERVER_INSTRUCTIONS = "easybill is a German invoicing and accounting system. This server exposes its REST API.\n\n# Before you start\n\nTwo rules that prevent most mistakes:\n\n1. **All monetary values are integers in CENTS.** 1999 means 19.99 EUR. Never send decimal euros.\n Times in time tracking are in minutes.\n2. **The rate limit is low** \u2014 10 requests/minute on easybill's PLUS plan, 60 on BUSINESS.\n Never \"browse\" or \"explore\" the data to orient yourself. Go straight to the specific\n filtered call that answers the question. A broad list costs the same as a precise one\n but tells you less.\n\n# Workflows\n\n## Creating an offer or invoice for someone (e.g. from an inbound inquiry)\n\nDo these in order. Do NOT start by listing documents \u2014 that tells you nothing about\nwhether the customer exists.\n\n1. **Find the customer**: `easybill_find_customer` with the company or person name.\n - One certain match -> use its `id`.\n - Several matches -> ask the user which one. Do not guess.\n - No match -> continue to step 2.\n2. **Create the customer** (only if it does not exist): `easybill_create_customer`.\n Required: `last_name` AND `company_name` \u2014 pass an empty string for whichever does\n not apply. Include address and email when you have them.\n3. **Create the document**: `easybill_create_document` with `customer_id`, `type`\n (`OFFER` for a quote, `INVOICE` for a bill), and `items` for the line items.\n This produces a **draft** \u2014 it has no official number yet and is still editable.\n4. **Review with the user** before finalising. Show them the amounts and line items.\n5. **Complete it**: `easybill_complete_document` \u2014 easybill then assigns the official\n document number and locks the document.\n6. **Send it** only if asked: `easybill_send_document`. This dispatches real email, fax\n or post to a real recipient. Always confirm the recipient first.\n\nWhen an inquiry does not specify prices, do not invent them. Look up the relevant articles\nwith `easybill_list_positions` and reference them by `position_id` in the line items, or\nask the user what to charge.\n\n## Answering a question about existing data\n\nPick the one filtered call that answers it:\n\n- Unpaid invoices -> `easybill_list_documents` with `type='INVOICE'`, `paid_at='null'`\n- Revenue in a period -> `easybill_list_documents` with `type='INVOICE'`,\n `document_date='2026-01-01,2026-12-31'`\n- One customer's history -> `easybill_list_documents` with `customer_id=<id>`\n (resolve the id via `easybill_find_customer` first)\n- Real invoices only -> add `is_draft='0'` and `cancel_id='null'` to exclude drafts and\n cancelled documents\n- Unbilled work -> `easybill_list_time_trackings`, then keep entries where `cleared_at` is null\n\nSum money in cents and divide by 100 only when presenting the result.\n\n## Recording a payment\n\n`easybill_create_document_payment` with `document_id` and `amount` (in cents). This is what\nmarks an invoice as paid. Partial payments are fine \u2014 easybill tracks the running total in\nthe document's `paid_amount`.\n\n## Voiding an invoice\n\nUse `easybill_cancel_document`, which creates a proper STORNO document. Do **not** use\n`easybill_delete_document` on a completed invoice \u2014 that is not legally valid, and easybill\nwill usually refuse it anyway.\n\n# Modes\n\nIf a create/update/delete tool seems to be missing, the server is running in read-only mode.\nCall `easybill_get_server_info` to confirm and to see how to enable writes. Do not tell the\nuser a write failed for another reason without checking this first.\n\n# Context\n\n`Document` has 69 fields and `Customer` 79. List tools return a compact subset by default.\nPass `fields` to pick specific columns, or `fields: [\"all\"]` when you genuinely need\neverything. Prefer narrow `fields` and a small `limit` over paging through bulk data.";
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server-level instructions, sent to the client during initialization.
|
|
3
|
+
*
|
|
4
|
+
* Individual tool descriptions explain single endpoints well, but they cannot tell
|
|
5
|
+
* an agent where to START. Without this, a request like "make an offer for this
|
|
6
|
+
* inquiry" tends to open with a broad easybill_list_documents call — wasted requests
|
|
7
|
+
* against a 10/min rate limit, and the wrong first question.
|
|
8
|
+
*
|
|
9
|
+
* Keep this focused on ordering and decision points, not field reference.
|
|
10
|
+
*/
|
|
11
|
+
export const SERVER_INSTRUCTIONS = `easybill is a German invoicing and accounting system. This server exposes its REST API.
|
|
12
|
+
|
|
13
|
+
# Before you start
|
|
14
|
+
|
|
15
|
+
Two rules that prevent most mistakes:
|
|
16
|
+
|
|
17
|
+
1. **All monetary values are integers in CENTS.** 1999 means 19.99 EUR. Never send decimal euros.
|
|
18
|
+
Times in time tracking are in minutes.
|
|
19
|
+
2. **The rate limit is low** — 10 requests/minute on easybill's PLUS plan, 60 on BUSINESS.
|
|
20
|
+
Never "browse" or "explore" the data to orient yourself. Go straight to the specific
|
|
21
|
+
filtered call that answers the question. A broad list costs the same as a precise one
|
|
22
|
+
but tells you less.
|
|
23
|
+
|
|
24
|
+
# Workflows
|
|
25
|
+
|
|
26
|
+
## Creating an offer or invoice for someone (e.g. from an inbound inquiry)
|
|
27
|
+
|
|
28
|
+
Do these in order. Do NOT start by listing documents — that tells you nothing about
|
|
29
|
+
whether the customer exists.
|
|
30
|
+
|
|
31
|
+
1. **Find the customer**: \`easybill_find_customer\` with the company or person name.
|
|
32
|
+
- One certain match -> use its \`id\`.
|
|
33
|
+
- Several matches -> ask the user which one. Do not guess.
|
|
34
|
+
- No match -> continue to step 2.
|
|
35
|
+
2. **Create the customer** (only if it does not exist): \`easybill_create_customer\`.
|
|
36
|
+
Required: \`last_name\` AND \`company_name\` — pass an empty string for whichever does
|
|
37
|
+
not apply. Include address and email when you have them.
|
|
38
|
+
3. **Create the document**: \`easybill_create_document\` with \`customer_id\`, \`type\`
|
|
39
|
+
(\`OFFER\` for a quote, \`INVOICE\` for a bill), and \`items\` for the line items.
|
|
40
|
+
This produces a **draft** — it has no official number yet and is still editable.
|
|
41
|
+
4. **Review with the user** before finalising. Show them the amounts and line items.
|
|
42
|
+
5. **Complete it**: \`easybill_complete_document\` — easybill then assigns the official
|
|
43
|
+
document number and locks the document.
|
|
44
|
+
6. **Send it** only if asked: \`easybill_send_document\`. This dispatches real email, fax
|
|
45
|
+
or post to a real recipient. Always confirm the recipient first.
|
|
46
|
+
|
|
47
|
+
When an inquiry does not specify prices, do not invent them. Look up the relevant articles
|
|
48
|
+
with \`easybill_list_positions\` and reference them by \`position_id\` in the line items, or
|
|
49
|
+
ask the user what to charge.
|
|
50
|
+
|
|
51
|
+
## Answering a question about existing data
|
|
52
|
+
|
|
53
|
+
Pick the one filtered call that answers it:
|
|
54
|
+
|
|
55
|
+
- Unpaid invoices -> \`easybill_list_documents\` with \`type='INVOICE'\`, \`paid_at='null'\`
|
|
56
|
+
- Revenue in a period -> \`easybill_list_documents\` with \`type='INVOICE'\`,
|
|
57
|
+
\`document_date='2026-01-01,2026-12-31'\`
|
|
58
|
+
- One customer's history -> \`easybill_list_documents\` with \`customer_id=<id>\`
|
|
59
|
+
(resolve the id via \`easybill_find_customer\` first)
|
|
60
|
+
- Real invoices only -> add \`is_draft='0'\` and \`cancel_id='null'\` to exclude drafts and
|
|
61
|
+
cancelled documents
|
|
62
|
+
- Unbilled work -> \`easybill_list_time_trackings\`, then keep entries where \`cleared_at\` is null
|
|
63
|
+
|
|
64
|
+
Sum money in cents and divide by 100 only when presenting the result.
|
|
65
|
+
|
|
66
|
+
## Recording a payment
|
|
67
|
+
|
|
68
|
+
\`easybill_create_document_payment\` with \`document_id\` and \`amount\` (in cents). This is what
|
|
69
|
+
marks an invoice as paid. Partial payments are fine — easybill tracks the running total in
|
|
70
|
+
the document's \`paid_amount\`.
|
|
71
|
+
|
|
72
|
+
## Voiding an invoice
|
|
73
|
+
|
|
74
|
+
Use \`easybill_cancel_document\`, which creates a proper STORNO document. Do **not** use
|
|
75
|
+
\`easybill_delete_document\` on a completed invoice — that is not legally valid, and easybill
|
|
76
|
+
will usually refuse it anyway.
|
|
77
|
+
|
|
78
|
+
# Modes
|
|
79
|
+
|
|
80
|
+
If a create/update/delete tool seems to be missing, the server is running in read-only mode.
|
|
81
|
+
Call \`easybill_get_server_info\` to confirm and to see how to enable writes. Do not tell the
|
|
82
|
+
user a write failed for another reason without checking this first.
|
|
83
|
+
|
|
84
|
+
# Context
|
|
85
|
+
|
|
86
|
+
\`Document\` has 69 fields and \`Customer\` 79. List tools return a compact subset by default.
|
|
87
|
+
Pass \`fields\` to pick specific columns, or \`fields: ["all"]\` when you genuinely need
|
|
88
|
+
everything. Prefer narrow \`fields\` and a small \`limit\` over paging through bulk data.`;
|
|
89
|
+
//# sourceMappingURL=instructions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instructions.js","sourceRoot":"","sources":["../src/instructions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,MAAM,CAAC,MAAM,mBAAmB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0FA6EuD,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/** Zod building blocks reused across every tool. */
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
export declare const responseFormatSchema: z.ZodDefault<z.ZodEnum<{
|
|
4
|
+
markdown: "markdown";
|
|
5
|
+
json: "json";
|
|
6
|
+
}>>;
|
|
7
|
+
export declare const fieldsSchema: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
8
|
+
export declare const limitSchema: z.ZodDefault<z.ZodNumber>;
|
|
9
|
+
export declare const pageSchema: z.ZodDefault<z.ZodNumber>;
|
|
10
|
+
/** Standard read-list parameters every list tool accepts. */
|
|
11
|
+
export declare const listBaseShape: {
|
|
12
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
13
|
+
page: z.ZodDefault<z.ZodNumber>;
|
|
14
|
+
fields: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
15
|
+
response_format: z.ZodDefault<z.ZodEnum<{
|
|
16
|
+
markdown: "markdown";
|
|
17
|
+
json: "json";
|
|
18
|
+
}>>;
|
|
19
|
+
};
|
|
20
|
+
/** Standard single-record parameters. */
|
|
21
|
+
export declare const recordBaseShape: {
|
|
22
|
+
fields: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
23
|
+
response_format: z.ZodDefault<z.ZodEnum<{
|
|
24
|
+
markdown: "markdown";
|
|
25
|
+
json: "json";
|
|
26
|
+
}>>;
|
|
27
|
+
};
|
|
28
|
+
export declare const idSchema: (resource: string) => z.ZodNumber;
|
|
29
|
+
/**
|
|
30
|
+
* A filter that easybill accepts as a single value or comma-separated list.
|
|
31
|
+
* Accepts a scalar or array; the client joins arrays with commas.
|
|
32
|
+
*/
|
|
33
|
+
export declare const multiFilter: (description: string) => z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>]>>;
|
|
34
|
+
export declare const dateFilter: (field: string) => z.ZodOptional<z.ZodString>;
|
|
35
|
+
/**
|
|
36
|
+
* Free-form object for create/update bodies.
|
|
37
|
+
*
|
|
38
|
+
* easybill's Document and Customer models carry 69 and 79 fields; enumerating
|
|
39
|
+
* them all in a Zod schema would bloat every tool description past usefulness.
|
|
40
|
+
* Instead the important fields are documented in the tool description and the
|
|
41
|
+
* body is passed through, letting easybill's own validation report problems
|
|
42
|
+
* (surfaced verbatim via formatApiError).
|
|
43
|
+
*/
|
|
44
|
+
export declare const dataSchema: (hint: string) => z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/** Zod building blocks reused across every tool. */
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { DATE_RANGE_HINT } from "../constants.js";
|
|
4
|
+
import { RESPONSE_FORMATS } from "../services/format.js";
|
|
5
|
+
export const responseFormatSchema = z
|
|
6
|
+
.enum(RESPONSE_FORMATS)
|
|
7
|
+
.default("markdown")
|
|
8
|
+
.describe("Output format: 'markdown' for readable prose, 'json' for machine-readable data");
|
|
9
|
+
export const fieldsSchema = z
|
|
10
|
+
.array(z.string())
|
|
11
|
+
.optional()
|
|
12
|
+
.describe("Limit returned columns to these field names (e.g. ['number','amount','paid_at']). " +
|
|
13
|
+
"Pass ['all'] for every field. Omit for a compact default set. Fewer fields = less context used.");
|
|
14
|
+
export const limitSchema = z
|
|
15
|
+
.number()
|
|
16
|
+
.int()
|
|
17
|
+
.min(1)
|
|
18
|
+
.max(1000)
|
|
19
|
+
.default(25)
|
|
20
|
+
.describe("Items per page, 1-1000 (default 25). Keep this small unless you need bulk data.");
|
|
21
|
+
export const pageSchema = z
|
|
22
|
+
.number()
|
|
23
|
+
.int()
|
|
24
|
+
.min(1)
|
|
25
|
+
.default(1)
|
|
26
|
+
.describe("Page number, starting at 1. Use 'next_page' from a previous response to continue.");
|
|
27
|
+
/** Standard read-list parameters every list tool accepts. */
|
|
28
|
+
export const listBaseShape = {
|
|
29
|
+
limit: limitSchema,
|
|
30
|
+
page: pageSchema,
|
|
31
|
+
fields: fieldsSchema,
|
|
32
|
+
response_format: responseFormatSchema,
|
|
33
|
+
};
|
|
34
|
+
/** Standard single-record parameters. */
|
|
35
|
+
export const recordBaseShape = {
|
|
36
|
+
fields: fieldsSchema,
|
|
37
|
+
response_format: responseFormatSchema,
|
|
38
|
+
};
|
|
39
|
+
export const idSchema = (resource) => z.number().int().positive().describe(`The numeric easybill ID of the ${resource}`);
|
|
40
|
+
/**
|
|
41
|
+
* A filter that easybill accepts as a single value or comma-separated list.
|
|
42
|
+
* Accepts a scalar or array; the client joins arrays with commas.
|
|
43
|
+
*/
|
|
44
|
+
export const multiFilter = (description) => z
|
|
45
|
+
.union([z.string(), z.number(), z.array(z.union([z.string(), z.number()]))])
|
|
46
|
+
.optional()
|
|
47
|
+
.describe(`${description} Accepts one value or a list of values.`);
|
|
48
|
+
export const dateFilter = (field) => z.string().optional().describe(`Filter by ${field}. ${DATE_RANGE_HINT}`);
|
|
49
|
+
/**
|
|
50
|
+
* Free-form object for create/update bodies.
|
|
51
|
+
*
|
|
52
|
+
* easybill's Document and Customer models carry 69 and 79 fields; enumerating
|
|
53
|
+
* them all in a Zod schema would bloat every tool description past usefulness.
|
|
54
|
+
* Instead the important fields are documented in the tool description and the
|
|
55
|
+
* body is passed through, letting easybill's own validation report problems
|
|
56
|
+
* (surfaced verbatim via formatApiError).
|
|
57
|
+
*/
|
|
58
|
+
export const dataSchema = (hint) => z.record(z.string(), z.unknown()).describe(hint);
|
|
59
|
+
//# sourceMappingURL=common.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/schemas/common.ts"],"names":[],"mappings":"AAAA,oDAAoD;AAEpD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC;KAClC,IAAI,CAAC,gBAAgB,CAAC;KACtB,OAAO,CAAC,UAAU,CAAC;KACnB,QAAQ,CAAC,gFAAgF,CAAC,CAAC;AAE9F,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC;KAC1B,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;KACjB,QAAQ,EAAE;KACV,QAAQ,CACP,oFAAoF;IAClF,iGAAiG,CACpG,CAAC;AAEJ,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC;KACzB,MAAM,EAAE;KACR,GAAG,EAAE;KACL,GAAG,CAAC,CAAC,CAAC;KACN,GAAG,CAAC,IAAI,CAAC;KACT,OAAO,CAAC,EAAE,CAAC;KACX,QAAQ,CAAC,iFAAiF,CAAC,CAAC;AAE/F,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC;KACxB,MAAM,EAAE;KACR,GAAG,EAAE;KACL,GAAG,CAAC,CA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,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP client for the easybill REST API.
|
|
3
|
+
*
|
|
4
|
+
* Responsibilities:
|
|
5
|
+
* - Bearer authentication from EASYBILL_API_KEY
|
|
6
|
+
* - Proactive client-side throttling (easybill allows only 10-60 req/min)
|
|
7
|
+
* - Retry with backoff on 429 / 5xx / network blips, honouring Retry-After
|
|
8
|
+
* - Mapping HTTP failures onto actionable error messages
|
|
9
|
+
*/
|
|
10
|
+
export type HttpMethod = "GET" | "POST" | "PUT" | "DELETE";
|
|
11
|
+
/** Query parameter values we know how to serialise. */
|
|
12
|
+
export type QueryValue = string | number | boolean | null | undefined | (string | number)[];
|
|
13
|
+
export type QueryParams = Record<string, QueryValue>;
|
|
14
|
+
export interface RequestOptions {
|
|
15
|
+
method?: HttpMethod;
|
|
16
|
+
/** JSON request body. */
|
|
17
|
+
body?: unknown;
|
|
18
|
+
query?: QueryParams;
|
|
19
|
+
/** Overrides the default `application/json` Accept header. */
|
|
20
|
+
accept?: string;
|
|
21
|
+
/** Extra headers, e.g. a multipart Content-Type. */
|
|
22
|
+
headers?: Record<string, string>;
|
|
23
|
+
/** Send `body` verbatim instead of JSON-encoding it (used for file uploads). */
|
|
24
|
+
rawBody?: RequestPayload;
|
|
25
|
+
}
|
|
26
|
+
/** What we ever pass as a fetch body. `BodyInit` is not global in @types/node. */
|
|
27
|
+
type RequestPayload = string | Uint8Array;
|
|
28
|
+
/** An easybill API error carrying enough context for an actionable message. */
|
|
29
|
+
export declare class EasybillApiError extends Error {
|
|
30
|
+
readonly status: number;
|
|
31
|
+
readonly statusText: string;
|
|
32
|
+
readonly path: string;
|
|
33
|
+
readonly detail: string;
|
|
34
|
+
readonly retryAfterSeconds?: number | undefined;
|
|
35
|
+
constructor(status: number, statusText: string, path: string, detail: string, retryAfterSeconds?: number | undefined);
|
|
36
|
+
}
|
|
37
|
+
/** Binary payload returned by the PDF / attachment download endpoints. */
|
|
38
|
+
export interface BinaryResponse {
|
|
39
|
+
data: Buffer;
|
|
40
|
+
contentType: string;
|
|
41
|
+
fileName?: string;
|
|
42
|
+
}
|
|
43
|
+
export declare class EasybillClient {
|
|
44
|
+
private readonly apiKey;
|
|
45
|
+
private readonly limiter;
|
|
46
|
+
constructor(apiKey: string);
|
|
47
|
+
/** Performs a JSON request and returns the decoded body (undefined for 204). */
|
|
48
|
+
request<T>(path: string, options?: RequestOptions): Promise<T>;
|
|
49
|
+
/** Performs a request expecting a binary body (PDF, JPG, attachment content). */
|
|
50
|
+
requestBinary(path: string, options?: RequestOptions): Promise<BinaryResponse>;
|
|
51
|
+
private send;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Turns any thrown error into a message that tells the agent what to do next.
|
|
55
|
+
*/
|
|
56
|
+
export declare function formatApiError(error: unknown): string;
|
|
57
|
+
export {};
|