exponential-mcp 0.18.0 → 0.19.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
@@ -231,6 +231,17 @@ settings page: list, create, update, set_holders, delete, and import_many
231
231
  (upsert by title, with a dry run). Writes need your own API key, not an agent
232
232
  key, and owner/admin, except that a holder may edit their own Position's remit.
233
233
 
234
+ `labels` also manages ticket label rules. A rule adds a label to each ticket
235
+ whose repo, epic, type or product matches. Rules only add labels.
236
+
237
+ - `list_rules`: any member.
238
+ - `create_rule`, `delete_rule`: owners and admins only.
239
+ - `apply_rules`: makes the rules match a list. It adds the missing rules and
240
+ keeps the rest, so you can run it again. It deletes rules only with `prune`.
241
+ `dryRun` writes nothing.
242
+
243
+ Other accounts get "Only workspace owners and admins can change label rules."
244
+
234
245
  `databases` is the typed write path for tables inside pages (ADR-0078): a
235
246
  database is a block in a page body and each row is a page. **Values are typed
236
247
  per property** — a select takes an option name, a date an ISO string, a person
@@ -1,6 +1,32 @@
1
+ import { type ExponentialClient } from 'exponential-sdk';
1
2
  import { type Domain } from './framework.js';
3
+ declare const RULE_KINDS: readonly ["REPO", "EPIC", "TYPE", "PRODUCT"];
4
+ export declare const FORBIDDEN_RULES_MESSAGE = "Only workspace owners and admins can change label rules.";
5
+ type WantedRule = {
6
+ kind: (typeof RULE_KINDS)[number];
7
+ match: string;
8
+ tagId: string;
9
+ };
10
+ /**
11
+ * Make a workspace's rules match `rules`: add the missing ones, keep the
12
+ * rest, and delete rules not in the list only when `prune` is set.
13
+ */
14
+ export declare function applyLabelRules(client: ExponentialClient, params: {
15
+ workspaceId: string;
16
+ rules: WantedRule[];
17
+ dryRun?: boolean;
18
+ prune?: boolean;
19
+ }): Promise<{
20
+ dryRun: boolean;
21
+ prune: boolean;
22
+ added: unknown[];
23
+ kept: import("exponential-sdk").TicketLabelRule[];
24
+ deleted: unknown[];
25
+ notInList: import("exponential-sdk").TicketLabelRule[];
26
+ }>;
2
27
  /** The server's tagEntityTypeSchema, in its order. */
3
28
  export declare const ENTITY_TYPES: readonly ["action", "ticket", "feature", "epic", "project", "goal", "resource", "recurringTask", "decision"];
4
29
  /** Entity types that take Pillars only; the server rejects a plain label on them. */
5
30
  export declare const PILLAR_ONLY_ENTITY_TYPES: readonly ["project", "goal", "resource", "recurringTask"];
6
31
  export declare const labels: Domain;
32
+ export {};
@@ -1,5 +1,79 @@
1
1
  import { z } from 'zod';
2
+ import { normaliseLabelRuleMatch } from 'exponential-sdk';
2
3
  import { id, op, workspaceId } from './framework.js';
4
+ const RULE_KINDS = ['REPO', 'EPIC', 'TYPE', 'PRODUCT'];
5
+ export const FORBIDDEN_RULES_MESSAGE = 'Only workspace owners and admins can change label rules.';
6
+ const ruleKind = z
7
+ .enum(RULE_KINDS)
8
+ .describe("What the rule compares: the ticket's linked PR repo, epic, type or product");
9
+ const ruleMatch = z
10
+ .string()
11
+ .min(1)
12
+ .max(300)
13
+ .describe('REPO: owner/name or a GitHub URL. TYPE: a ticket type, any case (BUG). EPIC: an epic ID. PRODUCT: a product ID.');
14
+ const ruleTagId = id('Label (tag) to add; from list. Global or from this workspace');
15
+ /** A FORBIDDEN from the server becomes the one message an admin needs. */
16
+ async function asAdmin(call) {
17
+ try {
18
+ return await call();
19
+ }
20
+ catch (error) {
21
+ const code = error?.data?.code;
22
+ if (code === 'FORBIDDEN')
23
+ throw new Error(FORBIDDEN_RULES_MESSAGE);
24
+ throw error;
25
+ }
26
+ }
27
+ /**
28
+ * Make a workspace's rules match `rules`: add the missing ones, keep the
29
+ * rest, and delete rules not in the list only when `prune` is set.
30
+ */
31
+ export async function applyLabelRules(client, params) {
32
+ const key = (kind, match, tagId) => `${kind}\u0000${match}\u0000${tagId}`;
33
+ const wanted = new Map();
34
+ for (const [index, rule] of params.rules.entries()) {
35
+ const match = normaliseLabelRuleMatch(rule.kind, rule.match);
36
+ if (!match)
37
+ throw new Error(`Rule ${index + 1}: "${rule.match}" is not a valid ${rule.kind} match.`);
38
+ wanted.set(key(rule.kind, match, rule.tagId), { ...rule, match });
39
+ }
40
+ const existing = await client.labels.listRules(params.workspaceId);
41
+ // The server stores matches normalised; normalise again so an older or
42
+ // hand-entered row still compares equal.
43
+ const existingKey = (r) => key(r.kind, normaliseLabelRuleMatch(r.kind, r.match) ?? r.match, r.tag.id);
44
+ const existingKeys = new Set(existing.map(existingKey));
45
+ const toAdd = [...wanted.entries()].filter(([k]) => !existingKeys.has(k)).map(([, r]) => r);
46
+ const kept = existing.filter((r) => wanted.has(existingKey(r)));
47
+ const extra = existing.filter((r) => !wanted.has(existingKey(r)));
48
+ const added = [];
49
+ const deleted = [];
50
+ if (params.dryRun) {
51
+ added.push(...toAdd);
52
+ if (params.prune)
53
+ deleted.push(...extra);
54
+ }
55
+ else {
56
+ await asAdmin(async () => {
57
+ for (const rule of toAdd) {
58
+ added.push(await client.labels.createRule({ workspaceId: params.workspaceId, ...rule }));
59
+ }
60
+ if (params.prune) {
61
+ for (const rule of extra) {
62
+ await client.labels.deleteRule(rule.id);
63
+ deleted.push(rule);
64
+ }
65
+ }
66
+ });
67
+ }
68
+ return {
69
+ dryRun: params.dryRun === true,
70
+ prune: params.prune === true,
71
+ added,
72
+ kept,
73
+ deleted,
74
+ notInList: params.prune ? [] : extra,
75
+ };
76
+ }
3
77
  /** The server's tagEntityTypeSchema, in its order. */
4
78
  export const ENTITY_TYPES = [
5
79
  'action',
@@ -52,7 +126,7 @@ const category = z
52
126
  .describe('Tag category; null means a plain label');
53
127
  export const labels = {
54
128
  name: 'labels',
55
- description: 'Labels and Pillars (both are tags). A tag whose category is "pillar" is a Pillar (a standing area of the workspace); any other tag is a label. Actions, tickets, features, epics and decisions (`decisions`) take Pillars and labels; projects, goals, resources and recurring tasks take Pillars only. There are global system tags and per-workspace tags. Creating or promoting a Pillar needs a workspace admin, in the app.',
129
+ description: 'Labels and Pillars (both are tags). A tag whose category is "pillar" is a Pillar (a standing area of the workspace); any other tag is a label. Actions, tickets, features, epics and decisions (`decisions`) take Pillars and labels; projects, goals, resources and recurring tasks take Pillars only. There are global system tags and per-workspace tags. Creating or promoting a Pillar needs a workspace admin, in the app. Ticket label rules (list_rules, create_rule, delete_rule, apply_rules) add a label to tickets automatically; only owners and admins change them.',
56
130
  operations: {
57
131
  list: op({
58
132
  effect: 'read',
@@ -94,5 +168,37 @@ export const labels = {
94
168
  }),
95
169
  run: (client, params) => client.labels.listForEntity(params),
96
170
  }),
171
+ list_rules: op({
172
+ effect: 'read',
173
+ summary: "List a workspace's ticket label rules. A rule adds its label to each ticket whose repo, epic, type or product matches, on create and when that field changes. Rules only add labels. Each rule has matchLabel: the epic or product name. Any member can read.",
174
+ params: z.object({ workspaceId }),
175
+ run: (client, params) => client.labels.listRules(params.workspaceId),
176
+ }),
177
+ create_rule: op({
178
+ effect: 'write',
179
+ summary: 'Add a ticket label rule. Owners and admins only. Adding a rule that exists returns the existing one. New rules do not relabel existing tickets.',
180
+ params: z.object({ workspaceId, kind: ruleKind, match: ruleMatch, tagId: ruleTagId }),
181
+ run: (client, params) => asAdmin(() => client.labels.createRule(params)),
182
+ }),
183
+ delete_rule: op({
184
+ effect: 'delete',
185
+ summary: 'Delete a ticket label rule. Owners and admins only. Tickets keep the labels it added.',
186
+ params: z.object({ id: id('Rule (from list_rules)') }),
187
+ run: (client, params) => asAdmin(() => client.labels.deleteRule(params.id)),
188
+ }),
189
+ apply_rules: op({
190
+ effect: 'delete',
191
+ summary: "Make a workspace's ticket label rules match a list. Adds the missing rules and keeps the rest; safe to repeat. Deletes rules not in the list only with prune. dryRun writes nothing. Returns { added, kept, deleted, notInList }. Owners and admins only.",
192
+ params: z.object({
193
+ workspaceId,
194
+ rules: z
195
+ .array(z.object({ kind: ruleKind, match: ruleMatch, tagId: ruleTagId }))
196
+ .max(500)
197
+ .describe('The whole rule set you want'),
198
+ dryRun: z.boolean().optional().describe('Show the changes and write nothing'),
199
+ prune: z.boolean().optional().describe('Also delete rules that are not in the list'),
200
+ }),
201
+ run: (client, params) => applyLabelRules(client, params),
202
+ }),
97
203
  },
98
204
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "exponential-mcp",
3
- "version": "0.18.0",
3
+ "version": "0.19.0",
4
4
  "description": "MCP server for Exponential - connect Claude to your projects, actions, goals, CRM, tickets and more",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -47,7 +47,7 @@
47
47
  "dependencies": {
48
48
  "@modelcontextprotocol/sdk": "^1.30.0",
49
49
  "commander": "^12.0.0",
50
- "exponential-sdk": "^1.39.0",
50
+ "exponential-sdk": "^1.40.0",
51
51
  "zod": "^3.22.0",
52
52
  "zod-to-json-schema": "^3.25.2"
53
53
  },