clokio-mcp 0.33.0 → 0.34.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/README.md CHANGED
@@ -90,8 +90,8 @@ acting. An explicit code on a tool call always takes precedence.
90
90
  Optional: set `CLOKIO_TOOLSETS` to register only the tool groups you need, e.g.
91
91
  `CLOKIO_TOOLSETS=tasks`. This cuts the per-session tool-list cost - a
92
92
  task-focused session drops from 137 tools to 48. Optional groups are `tasks`,
93
- `employees`, `attendance` (which includes leave, time entries and logging time), `docs` and
94
- `tickets`;
93
+ `employees`, `attendance` (which includes leave, time entries and logging time), `docs`,
94
+ `tickets` and `invoices` (read only: needs `invoices:read` and billing access);
95
95
  combine them with commas. If your key cannot open documents (no acts-as
96
96
  employee and no explicit docs scopes), leaving `docs` out saves 33 tools it
97
97
  cannot use. The `projects` group (project/client lookups, task statuses
@@ -112,6 +112,7 @@ are marked mutating (deletes are `destructive`).
112
112
  | **Attendance** | daily, range, per-employee, monthly summary, clock in/out, break start/end, time entries (local times in the person's zone; edit / delete your own), leaves (with `days`, half days counted 0.5), days of leave taken per type and year (`clokio_get_leave_days_taken`; the old name `clokio_get_leave_balances` still works; Clokio tracks no quota or remaining balance; leave and time-entry lists take `employee_code` and at most 92 days per call), **log time on a task**, start / stop / read the timer (see [Logging time](#logging-time)) |
113
113
  | **Documents** (see [Documents](#documents) for who a key acts as) | list, tree, search, get (Markdown / HTML / JSON), create, replace content, update meta, move, archive, restore, delete, templates + create from template, members (by `employee_code`) and teams (list/add/update/remove, shareable teams), public share link, comments (list/add/resolve/reopen), versions (list/get/restore), attachments (list/upload/download) |
114
114
  | **Tickets** (see [Tickets](#tickets)) | list (filters incl. several labels, created dates, needs reply, sort + cursor), **open a new ticket by email or WhatsApp template** (sent, or as a draft a person sends; `Idempotency-Key` per call, `destructive`), a WhatsApp number's approved templates with the slots to fill, get (with its newest messages; internal notes labelled, everything the customer wrote wrapped as untrusted), more messages, **reply to the customer** (fresh `Idempotency-Key` per call, `destructive`), **files on an outgoing email** (`file_paths` or `attachment_ids` on a new email and a reply), internal note (with mentions), update state / assignee (resolve without the satisfaction survey), **a contact's client with its projects, open tasks and recently done tasks** ("what is the status of my task?"), add / remove one label, contacts list / get / create / update, inboxes, ticket labels (list / create), saved replies, download a file a customer sent, save / delete your own reply draft, list the tasks opened from a ticket, **open a task from a ticket** (with its files; `Idempotency-Key` per call), **reports** (overview, agents, satisfaction + its ratings, workload) |
115
+ | **Invoices** (`invoices` toolset, read only) | list invoices (client, number, months, several statuses), get one (with `include_employees`), a task's billing, a client's month-by-month billing summary, one month across all clients, what a client has unbilled in a month. Needs `invoices:read` and billing access for the key's person; "paid" is a status set in Clokio, not a payment record; totals are per currency; no iCount data |
115
116
 
116
117
  ### Conventions
117
118
 
package/dist/index.js CHANGED
@@ -18,6 +18,7 @@ import { ClokioApiError, loadConfig, request } from './client.js';
18
18
  import { VERSION } from './version.js';
19
19
  import { registerTaskTools } from './tools/tasks.js';
20
20
  import { registerProjectTools } from './tools/projects.js';
21
+ import { registerInvoiceTools } from './tools/invoices.js';
21
22
  import { registerEmployeeTools } from './tools/employees.js';
22
23
  import { registerAttendanceTools } from './tools/attendance.js';
23
24
  import { registerDocTools } from './tools/docs.js';
@@ -36,7 +37,7 @@ import { registerTicketTools } from './tools/tickets.js';
36
37
  * to resolve names to ids, so it is always registered. Naming a toolset that
37
38
  * does not exist is refused at startup rather than silently ignored.
38
39
  */
39
- const OPTIONAL_TOOLSETS = ['tasks', 'employees', 'attendance', 'docs', 'tickets'];
40
+ const OPTIONAL_TOOLSETS = ['tasks', 'employees', 'attendance', 'docs', 'tickets', 'invoices'];
40
41
  function selectedToolsets() {
41
42
  const raw = process.env.CLOKIO_TOOLSETS?.trim();
42
43
  if (!raw) {
@@ -125,6 +126,8 @@ async function main() {
125
126
  registerDocTools(server, config);
126
127
  if (toolsets.has('tickets'))
127
128
  registerTicketTools(server, config);
129
+ if (toolsets.has('invoices'))
130
+ registerInvoiceTools(server, config);
128
131
  const transport = new StdioServerTransport();
129
132
  await server.connect(transport);
130
133
  // stderr is safe for logs on stdio transport (stdout carries the protocol).
@@ -0,0 +1,94 @@
1
+ import { z } from 'zod';
2
+ import { request } from '../client.js';
3
+ import { registerTool } from './helpers.js';
4
+ /**
5
+ * The read-only invoices toolset (0.34.0). Every tool is a GET over the
6
+ * backend's /invoices family; nothing here creates, sends, marks paid or
7
+ * cancels an invoice.
8
+ */
9
+ const ACCESS = 'Needs the invoices:read scope AND billing access for the key\'s person (otherwise 403 NO_BILLING_ACCESS). ' +
10
+ 'Read only. These are Clokio\'s own invoices; no iCount data. "paid" is a status someone set in Clokio, ' +
11
+ 'not a payment record.';
12
+ const month = (what) => z.string().regex(/^\d{4}-(0[1-9]|1[0-2])$/, 'month must be YYYY-MM (month 01-12)').describe(what);
13
+ const id = z.number().int().positive();
14
+ const includeEmployees = z
15
+ .boolean()
16
+ .optional()
17
+ .describe('true: each line also lists who worked it and for how many hours (include=employees); ' +
18
+ 'a task line lists everyone who worked that task in the period, even when the task is split over several lines.');
19
+ export function registerInvoiceTools(server, config) {
20
+ registerTool(server, config, {
21
+ name: 'clokio_list_invoices',
22
+ description: 'List Clokio invoices, newest first, optionally by client, exact number, period months and status. ' +
23
+ 'Paginated: {data, meta}. ' + ACCESS,
24
+ schema: {
25
+ client_id: id.optional(),
26
+ number: z.string().min(1).max(50).optional().describe('Exact invoice number, e.g. INV-0012'),
27
+ from_month: month('First period month, YYYY-MM').optional(),
28
+ to_month: month('Last period month, YYYY-MM; at most 24 months after from_month').optional(),
29
+ status: z.array(z.enum(['draft', 'finalized', 'sent', 'paid', 'cancelled'])).min(1).optional()
30
+ .describe('One or more statuses'),
31
+ per_page: z.number().int().min(1).max(100).optional(),
32
+ page: z.number().int().min(1).optional(),
33
+ },
34
+ handler: (args, cfg) => request(cfg, '/invoices', {
35
+ query: {
36
+ client_id: args.client_id,
37
+ number: args.number,
38
+ from_month: args.from_month,
39
+ to_month: args.to_month,
40
+ status: args.status,
41
+ per_page: args.per_page,
42
+ page: args.page,
43
+ },
44
+ }),
45
+ });
46
+ registerTool(server, config, {
47
+ name: 'clokio_get_invoice',
48
+ description: 'One invoice with its lines (include_employees adds who worked each line). ' + ACCESS,
49
+ schema: { id, include_employees: includeEmployees },
50
+ handler: (args, cfg) => request(cfg, `/invoices/${args.id}`, { query: { include: args.include_employees ? 'employees' : undefined } }),
51
+ });
52
+ registerTool(server, config, {
53
+ name: 'clokio_get_task_billing',
54
+ description: "A task's billing history: its invoice lines (newest period first), totals by status, and its unbilled hours and months. Amounts are keyed by currency. " + ACCESS,
55
+ schema: { task_id: id },
56
+ handler: (args, cfg) => request(cfg, `/tasks/${args.task_id}/billing`),
57
+ });
58
+ registerTool(server, config, {
59
+ name: 'clokio_get_client_billing_summary',
60
+ description: "A client's month-by-month billing (every month in the span, default the last 12 full months, at most 24): " +
61
+ 'per month the invoice, billable hours and estimated amount; totals keyed by currency. Money totals are per currency, never summed ' +
62
+ 'across currencies. ' + ACCESS,
63
+ schema: {
64
+ client_id: id,
65
+ from_month: month('First month, YYYY-MM').optional(),
66
+ to_month: month('Last month, YYYY-MM').optional(),
67
+ },
68
+ handler: (args, cfg) => request(cfg, `/clients/${args.client_id}/billing-summary`, {
69
+ query: { from_month: args.from_month, to_month: args.to_month },
70
+ }),
71
+ });
72
+ registerTool(server, config, {
73
+ name: 'clokio_get_billing_month',
74
+ description: 'One month across all clients, as the web /invoices screen: per client hours, estimated amount and invoice, the client ids not yet invoiced, and totals. Money totals are per currency, never summed. ' +
75
+ ACCESS,
76
+ schema: { month: month('The month, YYYY-MM; not in the future') },
77
+ handler: (args, cfg) => request(cfg, '/invoices/month', { query: { month: args.month } }),
78
+ });
79
+ registerTool(server, config, {
80
+ name: 'clokio_get_client_unbilled',
81
+ description: "What is still unbilled for a client in a month: the web invoice review's lines, from finished web-timer entries; " +
82
+ 'non-billable ones appear with is_billable false and price 0; subtotal counts billable lines only. client_id 0 is the "No Client" bucket. If an invoice already exists for that month the ' +
83
+ 'answer is existing_invoice and no lines. Amounts are in one currency per answer; each line carries its own. ' +
84
+ ACCESS,
85
+ schema: {
86
+ client_id: z.number().int().min(0),
87
+ month: month('The month, YYYY-MM; not in the future'),
88
+ include_employees: includeEmployees,
89
+ },
90
+ handler: (args, cfg) => request(cfg, `/clients/${args.client_id}/unbilled`, {
91
+ query: { month: args.month, include: args.include_employees ? 'employees' : undefined },
92
+ }),
93
+ });
94
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clokio-mcp",
3
- "version": "0.33.0",
3
+ "version": "0.34.0",
4
4
  "description": "Model Context Protocol (MCP) server for Clokio - manage tasks, projects, clients, employees, attendance and documents from Claude and any MCP client.",
5
5
  "type": "module",
6
6
  "bin": {