@denvermullets/jait 1.3.0 → 1.5.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.
@@ -1,5 +1,6 @@
1
1
  import { z } from "zod";
2
- import { apiRequest } from "../api-client.js";
2
+ import { apiRequest, apiRequestWithHeaders } from "../api-client.js";
3
+ import { attachUploads, filePathsSchema, formatAttachments, uploadLocalFiles, } from "../attachments.js";
3
4
  const priorityEnum = z
4
5
  .enum(["urgent", "high", "medium", "low", "no_priority"])
5
6
  .describe("Issue priority");
@@ -18,13 +19,18 @@ export function formatIssue(issue, detailed = false) {
18
19
  lines.push(` Due: ${issue.due_date}`);
19
20
  if (issue.estimate !== null)
20
21
  lines.push(` Estimate: ${issue.estimate}`);
22
+ // List rows carry only the parent's id; detail rows render the full parent below.
23
+ if (!detailed && issue.parent_issue_id)
24
+ lines.push(` Parent issue ID: ${issue.parent_issue_id}`);
21
25
  if (detailed) {
22
26
  if (issue.description)
23
27
  lines.push(` Description: ${issue.description}`);
24
- if (issue.milestone)
25
- lines.push(` Milestone: ${issue.milestone.name}`);
28
+ if (issue.files && issue.files.length > 0)
29
+ lines.push(` Attachments: ${formatAttachments(issue.files)}`);
26
30
  if (issue.parent_issue)
27
- lines.push(` Parent: ${issue.parent_issue.identifier} — ${issue.parent_issue.title}`);
31
+ lines.push(` Parent: ${issue.parent_issue.identifier} (ID: ${issue.parent_issue.id})`);
32
+ if (issue.sub_issues && issue.sub_issues.length > 0)
33
+ lines.push(` Sub-issues: ${issue.sub_issues.map((i) => `${i.identifier} (${i.title}) [${i.lane?.name ?? "?"}, ID: ${i.id}]`).join(", ")}`);
28
34
  // API semantics (from the Rails issue serializer / associations):
29
35
  // blocked_issues = issues THIS issue blocks (its dependents) -> "Blocking:"
30
36
  // blocking_issues = issues that block THIS issue (its blockers) -> "Blocked by:"
@@ -46,6 +52,55 @@ export function formatIssue(issue, detailed = false) {
46
52
  }
47
53
  return lines.join("\n");
48
54
  }
55
+ // create/update respond with the summary serializer, which omits attachments,
56
+ // so list what the attach call returned.
57
+ function attachedNote(attached) {
58
+ if (attached.length === 0)
59
+ return "";
60
+ return `\n Attached: ${formatAttachments(attached)}`;
61
+ }
62
+ function attachmentsPath(teamId, issueId) {
63
+ return `/api/v1/teams/${teamId}/issues/${issueId}/attachments`;
64
+ }
65
+ function formatValue(value) {
66
+ if (value === null || value === undefined || value === "")
67
+ return "none";
68
+ if (typeof value === "object") {
69
+ const v = value;
70
+ return String(v.name ?? v.identifier ?? v.id ?? JSON.stringify(v));
71
+ }
72
+ return String(value);
73
+ }
74
+ export function formatActivityEntry(entry) {
75
+ const when = entry.created_at;
76
+ switch (entry.type) {
77
+ case "comment": {
78
+ const c = entry.comment;
79
+ const who = c?.user?.name ?? "Someone";
80
+ return `${when} — ${who} commented (#${c?.id}): ${c?.body ?? ""}`;
81
+ }
82
+ case "reference": {
83
+ const who = entry.user?.name ?? "Someone";
84
+ const src = entry.source_issue;
85
+ return `${when} — ${who} referenced this from ${src?.identifier} (${src?.title}) in a ${entry.source_type}`;
86
+ }
87
+ default: {
88
+ const who = entry.actor?.name ?? "System";
89
+ const changes = (entry.changes ?? [])
90
+ .map((c) => `${c.field}: ${formatValue(c.from)} → ${formatValue(c.to)}`)
91
+ .join("; ");
92
+ return `${when} — ${who} ${entry.description ?? entry.type}${changes ? ` (${changes})` : ""}`;
93
+ }
94
+ }
95
+ }
96
+ export function formatActivityPage(entries, nextBeforeId) {
97
+ if (entries.length === 0)
98
+ return "No activity found.";
99
+ const lines = entries.map(formatActivityEntry);
100
+ if (nextBeforeId)
101
+ lines.push(`\nOlder entries exist: pass before_id "${nextBeforeId}" to see them.`);
102
+ return lines.join("\n");
103
+ }
49
104
  export function registerIssueTools(server) {
50
105
  server.tool("list_issues", "List issues for a team, with optional filters", {
51
106
  team_id: z.number().describe("Team ID"),
@@ -53,13 +108,18 @@ export function registerIssueTools(server) {
53
108
  assignee_id: z.number().optional().describe("Filter by assignee ID"),
54
109
  project_id: z.number().optional().describe("Filter by project ID"),
55
110
  priority: priorityEnum.optional(),
56
- }, async ({ team_id, lane_id, assignee_id, project_id, priority }) => {
111
+ parent_issue_id: z
112
+ .union([z.number(), z.literal("none")])
113
+ .optional()
114
+ .describe("Filter by parent: an issue ID lists that issue's direct sub-issues; 'none' lists only top-level issues (no parent)"),
115
+ }, async ({ team_id, lane_id, assignee_id, project_id, priority, parent_issue_id, }) => {
57
116
  const issues = await apiRequest(`/api/v1/teams/${team_id}/issues`, {
58
117
  params: {
59
118
  lane_id: lane_id,
60
119
  assignee_id: assignee_id,
61
120
  project_id: project_id,
62
121
  priority,
122
+ parent_issue_id,
63
123
  },
64
124
  });
65
125
  const text = issues.map((i) => formatIssue(i)).join("\n\n");
@@ -114,9 +174,14 @@ export function registerIssueTools(server) {
114
174
  .optional()
115
175
  .describe("Due date in YYYY-MM-DD format"),
116
176
  estimate: z.number().optional().describe("Estimate value"),
117
- milestone_id: z.number().optional().describe("Milestone ID"),
118
- parent_issue_id: z.number().optional().describe("Parent issue ID"),
119
- }, async ({ team_id, title, description, priority, lane_id, assignee_id, project_id, label_ids, due_date, estimate, milestone_id, parent_issue_id, }) => {
177
+ parent_issue_id: z
178
+ .number()
179
+ .optional()
180
+ .describe("Parent issue ID — creates this issue as a sub-issue of that issue (same team only)"),
181
+ file_paths: filePathsSchema,
182
+ }, async ({ team_id, title, description, priority, lane_id, assignee_id, project_id, label_ids, due_date, estimate, parent_issue_id, file_paths, }) => {
183
+ // Upload before creating, so a bad file fails the call with nothing created.
184
+ const uploads = await uploadLocalFiles(file_paths);
120
185
  let resolvedLaneId = lane_id;
121
186
  if (!resolvedLaneId) {
122
187
  const lanes = await apiRequest(`/api/v1/teams/${team_id}/lanes`);
@@ -133,29 +198,28 @@ export function registerIssueTools(server) {
133
198
  }
134
199
  resolvedLaneId = backlog.id;
135
200
  }
201
+ const fields = {
202
+ title,
203
+ description,
204
+ priority: priority || "no_priority",
205
+ lane_id: resolvedLaneId,
206
+ assignee_id,
207
+ project_id,
208
+ label_ids,
209
+ due_date,
210
+ estimate,
211
+ parent_issue_id,
212
+ };
136
213
  const issue = await apiRequest(`/api/v1/teams/${team_id}/issues`, {
137
214
  method: "POST",
138
- body: {
139
- issue: {
140
- title,
141
- description,
142
- priority: priority || "no_priority",
143
- lane_id: resolvedLaneId,
144
- assignee_id,
145
- project_id,
146
- label_ids,
147
- due_date,
148
- estimate,
149
- milestone_id,
150
- parent_issue_id,
151
- },
152
- },
215
+ body: { issue: fields },
153
216
  });
217
+ const attached = await attachUploads(attachmentsPath(team_id, issue.id), uploads);
154
218
  return {
155
219
  content: [
156
220
  {
157
221
  type: "text",
158
- text: `Issue created successfully:\n\n${formatIssue(issue, true)}`,
222
+ text: `Issue created successfully:\n\n${formatIssue(issue, true)}${attachedNote(attached)}`,
159
223
  },
160
224
  ],
161
225
  };
@@ -172,7 +236,14 @@ export function registerIssueTools(server) {
172
236
  label_ids: z.array(z.number()).optional().describe("Set label IDs"),
173
237
  due_date: z.string().optional().describe("Due date in YYYY-MM-DD format"),
174
238
  estimate: z.number().optional().describe("Estimate value"),
175
- }, async ({ team_id, issue_id, title, description, priority, lane_id, assignee_id, project_id, label_ids, due_date, estimate, }) => {
239
+ parent_issue_id: z
240
+ .number()
241
+ .nullable()
242
+ .optional()
243
+ .describe("Set the parent issue (makes this a sub-issue of it, same team only), or null to detach it and make it top-level"),
244
+ file_paths: filePathsSchema,
245
+ }, async ({ team_id, issue_id, title, description, priority, lane_id, assignee_id, project_id, label_ids, due_date, estimate, parent_issue_id, file_paths, }) => {
246
+ const uploads = await uploadLocalFiles(file_paths);
176
247
  const fields = {};
177
248
  if (title !== undefined)
178
249
  fields.title = title;
@@ -192,15 +263,91 @@ export function registerIssueTools(server) {
192
263
  fields.due_date = due_date;
193
264
  if (estimate !== undefined)
194
265
  fields.estimate = estimate;
195
- const issue = await apiRequest(`/api/v1/teams/${team_id}/issues/${issue_id}`, {
196
- method: "PATCH",
197
- body: { issue: fields },
266
+ if (parent_issue_id !== undefined)
267
+ fields.parent_issue_id = parent_issue_id;
268
+ if (Object.keys(fields).length === 0 && uploads.length === 0) {
269
+ return {
270
+ content: [
271
+ { type: "text", text: "Error: Nothing to update." },
272
+ ],
273
+ };
274
+ }
275
+ const issuePath = `/api/v1/teams/${team_id}/issues/${issue_id}`;
276
+ // The API rejects an empty `issue` object, so an attach-only call skips the PATCH.
277
+ const issue = Object.keys(fields).length > 0
278
+ ? await apiRequest(issuePath, {
279
+ method: "PATCH",
280
+ body: { issue: fields },
281
+ })
282
+ : await apiRequest(issuePath);
283
+ const attached = await attachUploads(attachmentsPath(team_id, issue_id), uploads);
284
+ return {
285
+ content: [
286
+ {
287
+ type: "text",
288
+ text: `Issue updated successfully:\n\n${formatIssue(issue, true)}${attachedNote(attached)}`,
289
+ },
290
+ ],
291
+ };
292
+ });
293
+ server.tool("remove_issue_attachment", "Remove a file attached to an issue. Get the attachment ID from get_issue.", {
294
+ team_id: z.number().describe("Team ID"),
295
+ issue_id: z.number().describe("Issue ID"),
296
+ attachment_id: z.number().describe("Attachment ID (shown by get_issue)"),
297
+ }, async ({ team_id, issue_id, attachment_id }) => {
298
+ await apiRequest(`${attachmentsPath(team_id, issue_id)}/${attachment_id}`, {
299
+ method: "DELETE",
198
300
  });
301
+ return {
302
+ content: [
303
+ { type: "text", text: `Attachment ${attachment_id} removed.` },
304
+ ],
305
+ };
306
+ });
307
+ server.tool("move_issue", "Move an issue to another team you belong to. It is renumbered there (new identifier). The lane is matched by name (else the team's first lane), the assignee is kept only if they are a member of the target team, and the project, labels and parent/sub-issue links are cleared.", {
308
+ team_id: z.number().describe("The issue's current team ID"),
309
+ issue_id: z.number().describe("Issue ID"),
310
+ target_team_id: z.number().describe("Team ID to move the issue to"),
311
+ }, async ({ team_id, issue_id, target_team_id }) => {
312
+ const issue = await apiRequest(`/api/v1/teams/${team_id}/issues/${issue_id}/move`, { method: "PATCH", body: { target_team_id } });
313
+ return {
314
+ content: [
315
+ {
316
+ type: "text",
317
+ text: `Issue moved:\n\n${formatIssue(issue, true)}`,
318
+ },
319
+ ],
320
+ };
321
+ });
322
+ server.tool("get_issue_activity", "Get an issue's history: field changes, dependency changes, comments and references from other issues, oldest first. Returns the newest `limit` entries; page back with before_id.", {
323
+ team_id: z.number().describe("Team ID"),
324
+ issue_id: z.number().describe("Issue ID"),
325
+ types: z
326
+ .array(z.enum(["versions", "dependencies", "comments", "references"]))
327
+ .optional()
328
+ .describe("Only these entry types (default: all)"),
329
+ since: z
330
+ .string()
331
+ .optional()
332
+ .describe("Only entries after this ISO 8601 timestamp"),
333
+ limit: z
334
+ .number()
335
+ .int()
336
+ .min(1)
337
+ .max(500)
338
+ .optional()
339
+ .describe("Max entries (default 100)"),
340
+ before_id: z
341
+ .string()
342
+ .optional()
343
+ .describe("Cursor from a previous call, to get older entries"),
344
+ }, async ({ team_id, issue_id, types, since, limit, before_id }) => {
345
+ const { data, headers } = await apiRequestWithHeaders(`/api/v1/teams/${team_id}/issues/${issue_id}/activity`, { params: { types: types?.join(","), since, limit, before_id } });
199
346
  return {
200
347
  content: [
201
348
  {
202
349
  type: "text",
203
- text: `Issue updated successfully:\n\n${formatIssue(issue, true)}`,
350
+ text: formatActivityPage(data, headers.get("X-Next-Before-Id")),
204
351
  },
205
352
  ],
206
353
  };
@@ -29,4 +29,43 @@ export function registerLabelTools(server) {
29
29
  ],
30
30
  };
31
31
  });
32
+ server.tool("update_label", "Rename a label or change its color.", {
33
+ team_id: z.number().describe("Team ID"),
34
+ label_id: z.number().describe("Label ID"),
35
+ name: z.string().optional().describe("New name (must be unique within team)"),
36
+ color: z.string().optional().describe("New hex color code (e.g. #ef4444)"),
37
+ }, async ({ team_id, label_id, name, color }) => {
38
+ const fields = {};
39
+ if (name !== undefined)
40
+ fields.name = name;
41
+ if (color !== undefined)
42
+ fields.color = color;
43
+ if (Object.keys(fields).length === 0) {
44
+ return {
45
+ content: [
46
+ { type: "text", text: "Error: Give a name or a color to change." },
47
+ ],
48
+ };
49
+ }
50
+ const label = await apiRequest(`/api/v1/teams/${team_id}/labels/${label_id}`, { method: "PATCH", body: { label: fields } });
51
+ return {
52
+ content: [
53
+ {
54
+ type: "text",
55
+ text: `Label updated: ${label.name} (${label.color}) — ID: ${label.id}`,
56
+ },
57
+ ],
58
+ };
59
+ });
60
+ server.tool("delete_label", "Delete a label from a team. It is removed from every issue that carries it.", {
61
+ team_id: z.number().describe("Team ID"),
62
+ label_id: z.number().describe("Label ID"),
63
+ }, async ({ team_id, label_id }) => {
64
+ await apiRequest(`/api/v1/teams/${team_id}/labels/${label_id}`, {
65
+ method: "DELETE",
66
+ });
67
+ return {
68
+ content: [{ type: "text", text: `Label ${label_id} deleted.` }],
69
+ };
70
+ });
32
71
  }
@@ -0,0 +1,2 @@
1
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ export declare function registerNotificationTools(server: McpServer): void;
@@ -0,0 +1,62 @@
1
+ import { z } from "zod";
2
+ import { apiRequest } from "../api-client.js";
3
+ function formatNotification(n) {
4
+ const state = n.read_at ? "read" : "UNREAD";
5
+ return `[${state}] #${n.id} ${n.created_at} — ${n.message}\n ${n.issue.identifier}: ${n.issue.title} (issue ID: ${n.issue.id}, team ID: ${n.issue.team_id})`;
6
+ }
7
+ export function registerNotificationTools(server) {
8
+ server.tool("list_notifications", "List your notifications (assignments, comments, mentions, status changes on issues you follow), newest first.", {
9
+ unread_only: z.boolean().optional().describe("Only unread notifications"),
10
+ limit: z
11
+ .number()
12
+ .int()
13
+ .min(1)
14
+ .max(200)
15
+ .optional()
16
+ .describe("Max notifications (default 50)"),
17
+ before_id: z
18
+ .number()
19
+ .optional()
20
+ .describe("Only notifications older than this notification ID, for paging"),
21
+ }, async ({ unread_only, limit, before_id }) => {
22
+ const res = await apiRequest("/api/v1/notifications", {
23
+ params: { unread: unread_only ? 1 : undefined, limit, before_id },
24
+ });
25
+ const header = `${res.meta.unread_count} unread`;
26
+ const body = res.notifications.map(formatNotification).join("\n\n");
27
+ return {
28
+ content: [
29
+ { type: "text", text: body ? `${header}\n\n${body}` : `${header}. No notifications found.` },
30
+ ],
31
+ };
32
+ });
33
+ server.tool("get_unread_notification_count", "Get how many unread notifications you have.", {}, async () => {
34
+ const res = await apiRequest("/api/v1/notifications/unread_count");
35
+ return {
36
+ content: [{ type: "text", text: `${res.unread_count} unread notifications.` }],
37
+ };
38
+ });
39
+ server.tool("mark_notification_read", "Mark one notification as read.", { notification_id: z.number().describe("Notification ID") }, async ({ notification_id }) => {
40
+ const n = await apiRequest(`/api/v1/notifications/${notification_id}/read`, { method: "PATCH" });
41
+ return {
42
+ content: [{ type: "text", text: `Marked read:\n${formatNotification(n)}` }],
43
+ };
44
+ });
45
+ server.tool("mark_all_notifications_read", "Mark all your notifications as read, optionally only those for one team or created before a time.", {
46
+ team_id: z.number().optional().describe("Only this team's notifications"),
47
+ before: z
48
+ .string()
49
+ .optional()
50
+ .describe("Only notifications created before this ISO 8601 timestamp"),
51
+ }, async ({ team_id, before }) => {
52
+ const res = await apiRequest("/api/v1/notifications/read_all", { method: "PATCH", params: { team_id, before } });
53
+ return {
54
+ content: [
55
+ {
56
+ type: "text",
57
+ text: `Marked ${res.marked} notifications read; ${res.unread_count} still unread.`,
58
+ },
59
+ ],
60
+ };
61
+ });
62
+ }
@@ -1,5 +1,7 @@
1
1
  import { z } from "zod";
2
- import { apiRequest } from "../api-client.js";
2
+ import { apiRequest, apiRequestWithHeaders } from "../api-client.js";
3
+ import { attachUploads, filePathsSchema, formatAttachments, uploadLocalFiles, } from "../attachments.js";
4
+ import { formatActivityPage } from "./issues.js";
3
5
  const projectStatusEnum = z
4
6
  .enum(["backlog", "started", "paused", "completed", "cancelled"])
5
7
  .describe("Project status");
@@ -25,10 +27,10 @@ function formatProject(project, detailed = false) {
25
27
  if (project.roadmap_commitment)
26
28
  lines.push(` Roadmap: ${project.roadmap_commitment}`);
27
29
  if (detailed) {
28
- if (project.milestone)
29
- lines.push(` Milestone: ${project.milestone.name}`);
30
30
  if (project.labels?.length > 0)
31
31
  lines.push(` Labels: ${project.labels.map((l) => l.name).join(", ")}`);
32
+ if (project.files && project.files.length > 0)
33
+ lines.push(` Attachments: ${formatAttachments(project.files)}`);
32
34
  if (project.issues_count !== undefined)
33
35
  lines.push(` Issues: ${project.issues_count}`);
34
36
  lines.push(` Created: ${project.created_at}`);
@@ -60,7 +62,6 @@ export function registerProjectTools(server) {
60
62
  status: projectStatusEnum.optional().describe("Defaults to backlog"),
61
63
  priority: priorityEnum.optional().describe("Defaults to no_priority"),
62
64
  lead_id: z.number().optional().describe("Project lead user ID"),
63
- milestone_id: z.number().optional().describe("Milestone ID"),
64
65
  start_date: z
65
66
  .string()
66
67
  .optional()
@@ -71,7 +72,7 @@ export function registerProjectTools(server) {
71
72
  .describe("Due date in YYYY-MM-DD format"),
72
73
  label_ids: z.array(z.number()).optional().describe("Label IDs"),
73
74
  roadmap_commitment: roadmapCommitmentEnum.optional(),
74
- }, async ({ team_id, name, description, status, priority, lead_id, milestone_id, start_date, due_date, label_ids, roadmap_commitment, }) => {
75
+ }, async ({ team_id, name, description, status, priority, lead_id, start_date, due_date, label_ids, roadmap_commitment, }) => {
75
76
  const project = await apiRequest(`/api/v1/teams/${team_id}/projects`, {
76
77
  method: "POST",
77
78
  body: {
@@ -81,7 +82,6 @@ export function registerProjectTools(server) {
81
82
  status: status || "backlog",
82
83
  priority: priority || "no_priority",
83
84
  lead_id,
84
- milestone_id,
85
85
  start_date,
86
86
  due_date,
87
87
  label_ids,
@@ -106,7 +106,6 @@ export function registerProjectTools(server) {
106
106
  status: projectStatusEnum.optional(),
107
107
  priority: priorityEnum.optional(),
108
108
  lead_id: z.number().optional().describe("New lead user ID"),
109
- milestone_id: z.number().optional().describe("Milestone ID"),
110
109
  start_date: z
111
110
  .string()
112
111
  .optional()
@@ -117,7 +116,7 @@ export function registerProjectTools(server) {
117
116
  .describe("Due date in YYYY-MM-DD format"),
118
117
  label_ids: z.array(z.number()).optional().describe("Set label IDs"),
119
118
  roadmap_commitment: roadmapCommitmentEnum.nullable().optional(),
120
- }, async ({ team_id, project_id, name, description, status, priority, lead_id, milestone_id, start_date, due_date, label_ids, roadmap_commitment, }) => {
119
+ }, async ({ team_id, project_id, name, description, status, priority, lead_id, start_date, due_date, label_ids, roadmap_commitment, }) => {
121
120
  const fields = {};
122
121
  if (name !== undefined)
123
122
  fields.name = name;
@@ -129,8 +128,6 @@ export function registerProjectTools(server) {
129
128
  fields.priority = priority;
130
129
  if (lead_id !== undefined)
131
130
  fields.lead_id = lead_id;
132
- if (milestone_id !== undefined)
133
- fields.milestone_id = milestone_id;
134
131
  if (start_date !== undefined)
135
132
  fields.start_date = start_date;
136
133
  if (due_date !== undefined)
@@ -163,4 +160,61 @@ export function registerProjectTools(server) {
163
160
  ],
164
161
  };
165
162
  });
163
+ server.tool("add_project_attachments", "Attach local files to a project. Existing attachments are kept.", {
164
+ team_id: z.number().describe("Team ID"),
165
+ project_id: z.number().describe("Project ID"),
166
+ file_paths: filePathsSchema.unwrap().min(1),
167
+ }, async ({ team_id, project_id, file_paths }) => {
168
+ const uploads = await uploadLocalFiles(file_paths);
169
+ const attached = await attachUploads(`/api/v1/teams/${team_id}/projects/${project_id}/attachments`, uploads);
170
+ return {
171
+ content: [
172
+ {
173
+ type: "text",
174
+ text: `Attached to project ${project_id}: ${formatAttachments(attached)}`,
175
+ },
176
+ ],
177
+ };
178
+ });
179
+ server.tool("remove_project_attachment", "Remove a file attached to a project. Get the attachment ID from get_project.", {
180
+ team_id: z.number().describe("Team ID"),
181
+ project_id: z.number().describe("Project ID"),
182
+ attachment_id: z.number().describe("Attachment ID (shown by get_project)"),
183
+ }, async ({ team_id, project_id, attachment_id }) => {
184
+ await apiRequest(`/api/v1/teams/${team_id}/projects/${project_id}/attachments/${attachment_id}`, { method: "DELETE" });
185
+ return {
186
+ content: [
187
+ { type: "text", text: `Attachment ${attachment_id} removed.` },
188
+ ],
189
+ };
190
+ });
191
+ server.tool("get_project_activity", "Get a project's change history (name, description, status, priority, lead, dates, roadmap commitment), oldest first. Returns the newest `limit` entries; page back with before_id.", {
192
+ team_id: z.number().describe("Team ID"),
193
+ project_id: z.number().describe("Project ID"),
194
+ since: z
195
+ .string()
196
+ .optional()
197
+ .describe("Only entries after this ISO 8601 timestamp"),
198
+ limit: z
199
+ .number()
200
+ .int()
201
+ .min(1)
202
+ .max(500)
203
+ .optional()
204
+ .describe("Max entries (default 100)"),
205
+ before_id: z
206
+ .string()
207
+ .optional()
208
+ .describe("Cursor from a previous call, to get older entries"),
209
+ }, async ({ team_id, project_id, since, limit, before_id }) => {
210
+ const { data, headers } = await apiRequestWithHeaders(`/api/v1/teams/${team_id}/projects/${project_id}/activity`, { params: { since, limit, before_id } });
211
+ return {
212
+ content: [
213
+ {
214
+ type: "text",
215
+ text: formatActivityPage(data, headers.get("X-Next-Before-Id")),
216
+ },
217
+ ],
218
+ };
219
+ });
166
220
  }
@@ -0,0 +1,2 @@
1
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ export declare function registerRecurringIssueTools(server: McpServer): void;
@@ -0,0 +1,132 @@
1
+ import { z } from "zod";
2
+ import { apiRequest } from "../api-client.js";
3
+ const priorityEnum = z
4
+ .enum(["urgent", "high", "medium", "low", "no_priority"])
5
+ .describe("Priority of each issue it files");
6
+ function formatRecurringIssue(r) {
7
+ const lines = [
8
+ `**${r.title}** — ID: ${r.id}${r.active ? "" : " (paused)"}`,
9
+ ` Schedule: ${r.schedule_summary} (${r.time_zone}) | Next: ${r.next_run_on ?? "none"}`,
10
+ ` Priority: ${r.priority}`,
11
+ ];
12
+ if (r.assignee)
13
+ lines.push(` Assignee: ${r.assignee.name}`);
14
+ if (r.project)
15
+ lines.push(` Project: ${r.project.name}`);
16
+ if (r.lane)
17
+ lines.push(` Lane: ${r.lane.name}`);
18
+ if (r.label_ids.length > 0)
19
+ lines.push(` Label IDs: ${r.label_ids.join(", ")}`);
20
+ if (r.last_run_at)
21
+ lines.push(` Last filed: ${r.last_run_at}`);
22
+ if (r.description)
23
+ lines.push(` Description: ${r.description}`);
24
+ return lines.join("\n");
25
+ }
26
+ // Shared by create and update; every field is optional here and create
27
+ // marks its required ones below.
28
+ const scheduleFields = {
29
+ title: z.string().describe("Title of each issue it files"),
30
+ description: z.string().describe("Description of each issue it files"),
31
+ priority: priorityEnum,
32
+ assignee_id: z.number().describe("Assignee user ID"),
33
+ project_id: z.number().describe("Project ID"),
34
+ lane_id: z.number().describe("Lane the issues start in (default: the team's first lane)"),
35
+ label_ids: z.array(z.number()).describe("Label IDs"),
36
+ frequency: z.enum(["daily", "weekly", "monthly"]).describe("How often it repeats"),
37
+ interval: z
38
+ .number()
39
+ .int()
40
+ .min(1)
41
+ .max(365)
42
+ .describe("Every N days/weeks/months (default 1)"),
43
+ weekday: z
44
+ .number()
45
+ .int()
46
+ .min(0)
47
+ .max(6)
48
+ .describe("For weekly: day of week, 0 = Sunday … 6 = Saturday"),
49
+ day_of_month: z
50
+ .number()
51
+ .int()
52
+ .min(1)
53
+ .max(31)
54
+ .describe("For monthly: day of month (clamped to the month's last day)"),
55
+ time_zone: z
56
+ .string()
57
+ .describe("Rails time zone name, e.g. 'Eastern Time (US & Canada)' (default: yours)"),
58
+ starts_on: z
59
+ .string()
60
+ .describe("YYYY-MM-DD; the first issue is filed on the first matching day on or after this (never before today)"),
61
+ };
62
+ function toBody(args) {
63
+ const fields = {};
64
+ for (const [key, value] of Object.entries(args)) {
65
+ if (value !== undefined)
66
+ fields[key] = value;
67
+ }
68
+ return fields;
69
+ }
70
+ export function registerRecurringIssueTools(server) {
71
+ server.tool("list_recurring_issues", "List a team's recurring issue templates (issues filed automatically on a schedule).", { team_id: z.number().describe("Team ID") }, async ({ team_id }) => {
72
+ const list = await apiRequest(`/api/v1/teams/${team_id}/recurring_issues`);
73
+ const text = list.map(formatRecurringIssue).join("\n\n");
74
+ return {
75
+ content: [{ type: "text", text: text || "No recurring issues found." }],
76
+ };
77
+ });
78
+ server.tool("create_recurring_issue", "Create a recurring issue: a template that files a fresh issue on a schedule (e.g. every Friday). Weekly needs weekday; monthly needs day_of_month.", {
79
+ team_id: z.number().describe("Team ID"),
80
+ ...scheduleFields,
81
+ description: scheduleFields.description.optional(),
82
+ priority: scheduleFields.priority.optional(),
83
+ assignee_id: scheduleFields.assignee_id.optional(),
84
+ project_id: scheduleFields.project_id.optional(),
85
+ lane_id: scheduleFields.lane_id.optional(),
86
+ label_ids: scheduleFields.label_ids.optional(),
87
+ interval: scheduleFields.interval.optional(),
88
+ weekday: scheduleFields.weekday.optional(),
89
+ day_of_month: scheduleFields.day_of_month.optional(),
90
+ time_zone: scheduleFields.time_zone.optional(),
91
+ }, async ({ team_id, ...args }) => {
92
+ const r = await apiRequest(`/api/v1/teams/${team_id}/recurring_issues`, {
93
+ method: "POST",
94
+ body: { recurring_issue: { interval: 1, ...toBody(args) } },
95
+ });
96
+ return {
97
+ content: [
98
+ { type: "text", text: `Recurring issue created:\n\n${formatRecurringIssue(r)}` },
99
+ ],
100
+ };
101
+ });
102
+ server.tool("update_recurring_issue", "Update a recurring issue template, or pause/resume it with `active`. Changing the frequency, interval, weekday or day_of_month only takes effect on the next run date when starts_on is also given.", {
103
+ team_id: z.number().describe("Team ID"),
104
+ recurring_issue_id: z.number().describe("Recurring issue ID"),
105
+ ...Object.fromEntries(Object.entries(scheduleFields).map(([k, v]) => [k, v.optional()])),
106
+ active: z.boolean().optional().describe("false pauses it, true resumes it"),
107
+ }, async ({ team_id, recurring_issue_id, ...args }) => {
108
+ const fields = toBody(args);
109
+ if (Object.keys(fields).length === 0) {
110
+ return {
111
+ content: [{ type: "text", text: "Error: Nothing to update." }],
112
+ };
113
+ }
114
+ const r = await apiRequest(`/api/v1/teams/${team_id}/recurring_issues/${recurring_issue_id}`, { method: "PATCH", body: { recurring_issue: fields } });
115
+ return {
116
+ content: [
117
+ { type: "text", text: `Recurring issue updated:\n\n${formatRecurringIssue(r)}` },
118
+ ],
119
+ };
120
+ });
121
+ server.tool("delete_recurring_issue", "Delete a recurring issue template. Issues it already filed are kept.", {
122
+ team_id: z.number().describe("Team ID"),
123
+ recurring_issue_id: z.number().describe("Recurring issue ID"),
124
+ }, async ({ team_id, recurring_issue_id }) => {
125
+ await apiRequest(`/api/v1/teams/${team_id}/recurring_issues/${recurring_issue_id}`, { method: "DELETE" });
126
+ return {
127
+ content: [
128
+ { type: "text", text: `Recurring issue ${recurring_issue_id} deleted.` },
129
+ ],
130
+ };
131
+ });
132
+ }