@denvermullets/jait 1.4.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.
- package/dist/api-client.d.ts +5 -1
- package/dist/api-client.js +21 -20
- package/dist/attachments.d.ts +9 -2
- package/dist/attachments.js +93 -29
- package/dist/index.js +8 -0
- package/dist/tools/comments.d.ts +20 -0
- package/dist/tools/comments.js +85 -25
- package/dist/tools/decisions.d.ts +2 -0
- package/dist/tools/decisions.js +64 -0
- package/dist/tools/issues.d.ts +46 -6
- package/dist/tools/issues.js +163 -27
- package/dist/tools/labels.js +39 -0
- package/dist/tools/notifications.d.ts +2 -0
- package/dist/tools/notifications.js +62 -0
- package/dist/tools/projects.js +64 -10
- package/dist/tools/recurring-issues.d.ts +2 -0
- package/dist/tools/recurring-issues.js +132 -0
- package/dist/tools/sub-issues.d.ts +32 -0
- package/dist/tools/sub-issues.js +90 -0
- package/package.json +4 -4
package/dist/api-client.d.ts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
interface RequestOptions {
|
|
2
2
|
method?: string;
|
|
3
3
|
body?: Record<string, unknown>;
|
|
4
|
-
form?: FormData;
|
|
5
4
|
params?: Record<string, string | number | undefined>;
|
|
6
5
|
}
|
|
6
|
+
export declare function apiBaseUrl(): string;
|
|
7
7
|
export declare function apiRequest<T>(path: string, options?: RequestOptions): Promise<T>;
|
|
8
|
+
export declare function apiRequestWithHeaders<T>(path: string, options?: RequestOptions): Promise<{
|
|
9
|
+
data: T;
|
|
10
|
+
headers: Headers;
|
|
11
|
+
}>;
|
|
8
12
|
export {};
|
package/dist/api-client.js
CHANGED
|
@@ -1,19 +1,26 @@
|
|
|
1
1
|
import { readToken } from "./config-store.js";
|
|
2
2
|
const DEFAULT_API_URL = "https://justanotherissuetracker.com";
|
|
3
3
|
function getConfig() {
|
|
4
|
-
const apiUrl = process.env.MTASKS_API_URL || DEFAULT_API_URL;
|
|
5
4
|
const apiToken = process.env.MTASKS_API_TOKEN || readToken();
|
|
6
5
|
if (!apiToken) {
|
|
7
6
|
throw new Error("No token found. Run 'npx @denvermullets/jait login <token>' or set MTASKS_API_TOKEN.");
|
|
8
7
|
}
|
|
9
8
|
return {
|
|
10
|
-
baseUrl:
|
|
9
|
+
baseUrl: apiBaseUrl(),
|
|
11
10
|
token: apiToken,
|
|
12
11
|
};
|
|
13
12
|
}
|
|
13
|
+
export function apiBaseUrl() {
|
|
14
|
+
return (process.env.MTASKS_API_URL || DEFAULT_API_URL).replace(/\/$/, "");
|
|
15
|
+
}
|
|
14
16
|
export async function apiRequest(path, options = {}) {
|
|
17
|
+
return (await apiRequestWithHeaders(path, options)).data;
|
|
18
|
+
}
|
|
19
|
+
// Same as apiRequest, plus the response headers (for cursors such as
|
|
20
|
+
// X-Next-Before-Id on the activity feeds).
|
|
21
|
+
export async function apiRequestWithHeaders(path, options = {}) {
|
|
15
22
|
const { baseUrl, token } = getConfig();
|
|
16
|
-
const { method = "GET", body,
|
|
23
|
+
const { method = "GET", body, params } = options;
|
|
17
24
|
const url = new URL(`${baseUrl}${path}`);
|
|
18
25
|
if (params) {
|
|
19
26
|
for (const [key, value] of Object.entries(params)) {
|
|
@@ -22,17 +29,14 @@ export async function apiRequest(path, options = {}) {
|
|
|
22
29
|
}
|
|
23
30
|
}
|
|
24
31
|
}
|
|
25
|
-
const headers = {
|
|
26
|
-
Authorization: `Bearer ${token}`,
|
|
27
|
-
Accept: "application/json",
|
|
28
|
-
};
|
|
29
|
-
// For multipart, fetch sets Content-Type itself so it can include the boundary.
|
|
30
|
-
if (!form)
|
|
31
|
-
headers["Content-Type"] = "application/json";
|
|
32
32
|
const response = await fetch(url.toString(), {
|
|
33
33
|
method,
|
|
34
|
-
headers
|
|
35
|
-
|
|
34
|
+
headers: {
|
|
35
|
+
Authorization: `Bearer ${token}`,
|
|
36
|
+
Accept: "application/json",
|
|
37
|
+
"Content-Type": "application/json",
|
|
38
|
+
},
|
|
39
|
+
body: body ? JSON.stringify(body) : undefined,
|
|
36
40
|
});
|
|
37
41
|
if (!response.ok) {
|
|
38
42
|
const errorBody = await response.text();
|
|
@@ -49,12 +53,9 @@ export async function apiRequest(path, options = {}) {
|
|
|
49
53
|
}
|
|
50
54
|
// Some endpoints (e.g. a 204 No Content on DELETE) return an empty body.
|
|
51
55
|
// Guard against JSON.parse throwing "Unexpected end of JSON input".
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
return undefined;
|
|
58
|
-
}
|
|
59
|
-
return JSON.parse(text);
|
|
56
|
+
const text = response.status === 204 ? "" : await response.text();
|
|
57
|
+
return {
|
|
58
|
+
data: (text ? JSON.parse(text) : undefined),
|
|
59
|
+
headers: response.headers,
|
|
60
|
+
};
|
|
60
61
|
}
|
package/dist/attachments.d.ts
CHANGED
|
@@ -2,15 +2,22 @@ import { z } from "zod";
|
|
|
2
2
|
export declare const filePathsSchema: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
3
3
|
export interface LocalFile {
|
|
4
4
|
filename: string;
|
|
5
|
+
contentType: string;
|
|
5
6
|
data: Uint8Array<ArrayBuffer>;
|
|
6
7
|
}
|
|
8
|
+
export interface UploadedFile {
|
|
9
|
+
filename: string;
|
|
10
|
+
signedId: string;
|
|
11
|
+
}
|
|
7
12
|
export interface Attachment {
|
|
8
13
|
id: number;
|
|
9
14
|
filename: string;
|
|
10
15
|
content_type: string;
|
|
11
16
|
byte_size: number;
|
|
12
|
-
|
|
17
|
+
download_url: string;
|
|
13
18
|
}
|
|
19
|
+
export declare function contentTypeFor(filename: string): string | undefined;
|
|
14
20
|
export declare function readLocalFiles(paths: string[]): Promise<LocalFile[]>;
|
|
15
|
-
export declare function
|
|
21
|
+
export declare function uploadLocalFiles(paths: string[] | undefined): Promise<UploadedFile[]>;
|
|
22
|
+
export declare function attachUploads(path: string, uploads: UploadedFile[]): Promise<Attachment[]>;
|
|
16
23
|
export declare function formatAttachments(attachments: Attachment[]): string;
|
package/dist/attachments.js
CHANGED
|
@@ -1,19 +1,53 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
1
2
|
import { readFile, stat } from "node:fs/promises";
|
|
2
3
|
import { homedir } from "node:os";
|
|
3
|
-
import { basename, resolve } from "node:path";
|
|
4
|
+
import { basename, extname, resolve } from "node:path";
|
|
4
5
|
import { z } from "zod";
|
|
6
|
+
import { apiBaseUrl, apiRequest } from "./api-client.js";
|
|
5
7
|
export const filePathsSchema = z
|
|
6
8
|
.array(z.string())
|
|
7
9
|
.optional()
|
|
8
|
-
.describe("Local file paths to attach (absolute, or ~/...).
|
|
10
|
+
.describe("Local file paths to attach (absolute, or ~/...). Max 25 MB each; images, PDFs, video, text/markdown/csv/json, zip and Office files. Existing attachments are kept.");
|
|
11
|
+
// Mirrors ALLOWED_CONTENT_TYPES in the Rails app's
|
|
12
|
+
// app/controllers/api/v1/direct_uploads_controller.rb (SVG/HTML are refused there).
|
|
13
|
+
const CONTENT_TYPES = {
|
|
14
|
+
".png": "image/png",
|
|
15
|
+
".jpg": "image/jpeg",
|
|
16
|
+
".jpeg": "image/jpeg",
|
|
17
|
+
".gif": "image/gif",
|
|
18
|
+
".webp": "image/webp",
|
|
19
|
+
".heic": "image/heic",
|
|
20
|
+
".avif": "image/avif",
|
|
21
|
+
".pdf": "application/pdf",
|
|
22
|
+
".txt": "text/plain",
|
|
23
|
+
".log": "text/plain",
|
|
24
|
+
".md": "text/markdown",
|
|
25
|
+
".markdown": "text/markdown",
|
|
26
|
+
".csv": "text/csv",
|
|
27
|
+
".json": "application/json",
|
|
28
|
+
".zip": "application/zip",
|
|
29
|
+
".doc": "application/msword",
|
|
30
|
+
".docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
31
|
+
".xls": "application/vnd.ms-excel",
|
|
32
|
+
".xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
33
|
+
".ppt": "application/vnd.ms-powerpoint",
|
|
34
|
+
".pptx": "application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
|
35
|
+
".mp4": "video/mp4",
|
|
36
|
+
".mov": "video/quicktime",
|
|
37
|
+
".webm": "video/webm",
|
|
38
|
+
};
|
|
39
|
+
const MAX_BYTES = 25 * 1024 * 1024;
|
|
9
40
|
function expandPath(path) {
|
|
10
41
|
if (path === "~" || path.startsWith("~/")) {
|
|
11
42
|
return resolve(homedir(), path.slice(2));
|
|
12
43
|
}
|
|
13
44
|
return resolve(path);
|
|
14
45
|
}
|
|
15
|
-
|
|
16
|
-
|
|
46
|
+
export function contentTypeFor(filename) {
|
|
47
|
+
return CONTENT_TYPES[extname(filename).toLowerCase()];
|
|
48
|
+
}
|
|
49
|
+
// Reads and validates every file up front so a bad path or type fails the
|
|
50
|
+
// call before anything is written, rather than leaving a half-done change.
|
|
17
51
|
export async function readLocalFiles(paths) {
|
|
18
52
|
return Promise.all(paths.map(async (path) => {
|
|
19
53
|
const fullPath = expandPath(path);
|
|
@@ -21,34 +55,64 @@ export async function readLocalFiles(paths) {
|
|
|
21
55
|
if (!info?.isFile()) {
|
|
22
56
|
throw new Error(`Attachment not found or not a file: ${path}`);
|
|
23
57
|
}
|
|
58
|
+
const filename = basename(fullPath);
|
|
59
|
+
const contentType = contentTypeFor(filename);
|
|
60
|
+
if (!contentType) {
|
|
61
|
+
throw new Error(`Unsupported attachment type: ${filename}. Allowed: ${Object.keys(CONTENT_TYPES).join(" ")}`);
|
|
62
|
+
}
|
|
63
|
+
if (info.size === 0 || info.size > MAX_BYTES) {
|
|
64
|
+
throw new Error(`Attachment must be between 1 byte and 25 MB: ${path}`);
|
|
65
|
+
}
|
|
24
66
|
const buffer = await readFile(fullPath);
|
|
25
|
-
return { filename
|
|
67
|
+
return { filename, contentType, data: new Uint8Array(buffer) };
|
|
26
68
|
}));
|
|
27
69
|
}
|
|
28
|
-
//
|
|
29
|
-
//
|
|
30
|
-
//
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
70
|
+
// ActiveStorage direct upload: register the blob with the API, PUT the bytes
|
|
71
|
+
// to the storage URL it hands back, and return the signed id that the attach
|
|
72
|
+
// endpoints take. The storage URL is pre-signed, so no Authorization header.
|
|
73
|
+
async function uploadFile(file) {
|
|
74
|
+
const checksum = createHash("md5").update(file.data).digest("base64");
|
|
75
|
+
const blob = await apiRequest("/api/v1/direct_uploads", {
|
|
76
|
+
method: "POST",
|
|
77
|
+
body: {
|
|
78
|
+
blob: {
|
|
79
|
+
filename: file.filename,
|
|
80
|
+
byte_size: file.data.byteLength,
|
|
81
|
+
checksum,
|
|
82
|
+
content_type: file.contentType,
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
const target = new URL(blob.direct_upload.url, apiBaseUrl());
|
|
87
|
+
const response = await fetch(target, {
|
|
88
|
+
method: "PUT",
|
|
89
|
+
headers: blob.direct_upload.headers,
|
|
90
|
+
body: file.data,
|
|
91
|
+
});
|
|
92
|
+
if (!response.ok) {
|
|
93
|
+
throw new Error(`Upload of ${file.filename} failed: ${response.status} ${await response.text()}`);
|
|
50
94
|
}
|
|
51
|
-
return
|
|
95
|
+
return { filename: file.filename, signedId: blob.signed_id };
|
|
96
|
+
}
|
|
97
|
+
// Validates every path, then uploads. Uploaded-but-unattached blobs are
|
|
98
|
+
// harmless (ActiveStorage purges orphans), so a later failure leaves no mess.
|
|
99
|
+
export async function uploadLocalFiles(paths) {
|
|
100
|
+
if (!paths || paths.length === 0)
|
|
101
|
+
return [];
|
|
102
|
+
const files = await readLocalFiles(paths);
|
|
103
|
+
const uploaded = [];
|
|
104
|
+
for (const file of files)
|
|
105
|
+
uploaded.push(await uploadFile(file));
|
|
106
|
+
return uploaded;
|
|
107
|
+
}
|
|
108
|
+
// POST {signed_ids} to an issue's or project's attachments endpoint.
|
|
109
|
+
export async function attachUploads(path, uploads) {
|
|
110
|
+
if (uploads.length === 0)
|
|
111
|
+
return [];
|
|
112
|
+
return apiRequest(path, {
|
|
113
|
+
method: "POST",
|
|
114
|
+
body: { signed_ids: uploads.map((u) => u.signedId) },
|
|
115
|
+
});
|
|
52
116
|
}
|
|
53
117
|
function formatBytes(bytes) {
|
|
54
118
|
if (bytes < 1024)
|
|
@@ -59,6 +123,6 @@ function formatBytes(bytes) {
|
|
|
59
123
|
}
|
|
60
124
|
export function formatAttachments(attachments) {
|
|
61
125
|
return attachments
|
|
62
|
-
.map((a) => `${a.filename} (${a.content_type}, ${formatBytes(a.byte_size)})`)
|
|
126
|
+
.map((a) => `${a.filename} (${a.content_type}, ${formatBytes(a.byte_size)}, attachment ID: ${a.id})`)
|
|
63
127
|
.join(", ");
|
|
64
128
|
}
|
package/dist/index.js
CHANGED
|
@@ -8,7 +8,11 @@ import { registerMemberTools } from "./tools/members.js";
|
|
|
8
8
|
import { registerLabelTools } from "./tools/labels.js";
|
|
9
9
|
import { registerProjectTools } from "./tools/projects.js";
|
|
10
10
|
import { registerIssueDependencyTools } from "./tools/issue-dependencies.js";
|
|
11
|
+
import { registerSubIssueTools } from "./tools/sub-issues.js";
|
|
11
12
|
import { registerCommentTools } from "./tools/comments.js";
|
|
13
|
+
import { registerDecisionTools } from "./tools/decisions.js";
|
|
14
|
+
import { registerNotificationTools } from "./tools/notifications.js";
|
|
15
|
+
import { registerRecurringIssueTools } from "./tools/recurring-issues.js";
|
|
12
16
|
import { writeToken, clearToken } from "./config-store.js";
|
|
13
17
|
const [, , cmd, arg] = process.argv;
|
|
14
18
|
if (cmd === "login") {
|
|
@@ -32,10 +36,14 @@ const server = new McpServer({
|
|
|
32
36
|
registerTeamTools(server);
|
|
33
37
|
registerIssueTools(server);
|
|
34
38
|
registerIssueDependencyTools(server);
|
|
39
|
+
registerSubIssueTools(server);
|
|
35
40
|
registerCommentTools(server);
|
|
36
41
|
registerLaneTools(server);
|
|
37
42
|
registerMemberTools(server);
|
|
38
43
|
registerLabelTools(server);
|
|
39
44
|
registerProjectTools(server);
|
|
45
|
+
registerDecisionTools(server);
|
|
46
|
+
registerNotificationTools(server);
|
|
47
|
+
registerRecurringIssueTools(server);
|
|
40
48
|
const transport = new StdioServerTransport();
|
|
41
49
|
await server.connect(transport);
|
package/dist/tools/comments.d.ts
CHANGED
|
@@ -1,2 +1,22 @@
|
|
|
1
1
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import { type Attachment } from "../attachments.js";
|
|
3
|
+
interface CommentUser {
|
|
4
|
+
id: number;
|
|
5
|
+
name: string;
|
|
6
|
+
email: string;
|
|
7
|
+
}
|
|
8
|
+
export interface Comment {
|
|
9
|
+
id: number;
|
|
10
|
+
body: string | null;
|
|
11
|
+
parent_id: number | null;
|
|
12
|
+
user: CommentUser | null;
|
|
13
|
+
files?: Attachment[];
|
|
14
|
+
created_at: string;
|
|
15
|
+
updated_at: string;
|
|
16
|
+
replies?: Comment[];
|
|
17
|
+
owner_type?: "Issue" | "Project";
|
|
18
|
+
owner_id?: number;
|
|
19
|
+
}
|
|
20
|
+
export declare function formatComment(comment: Comment, indent?: number): string;
|
|
2
21
|
export declare function registerCommentTools(server: McpServer): void;
|
|
22
|
+
export {};
|
package/dist/tools/comments.js
CHANGED
|
@@ -1,37 +1,56 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { apiRequest } from "../api-client.js";
|
|
3
|
-
import {
|
|
4
|
-
function formatComment(comment, indent = 0) {
|
|
3
|
+
import { filePathsSchema, formatAttachments, uploadLocalFiles, } from "../attachments.js";
|
|
4
|
+
export function formatComment(comment, indent = 0) {
|
|
5
5
|
const pad = " ".repeat(indent);
|
|
6
6
|
const author = comment.user ? comment.user.name : "Unknown";
|
|
7
|
+
const owner = comment.owner_type
|
|
8
|
+
? ` on ${comment.owner_type.toLowerCase()} ${comment.owner_id}`
|
|
9
|
+
: "";
|
|
10
|
+
const reply = comment.parent_id && indent === 0 ? ` (reply to #${comment.parent_id})` : "";
|
|
7
11
|
const lines = [
|
|
8
|
-
`${pad}#${comment.id} by ${author} at ${comment.created_at}`,
|
|
12
|
+
`${pad}#${comment.id} by ${author}${owner}${reply} at ${comment.created_at}`,
|
|
9
13
|
`${pad} ${comment.body ?? ""}`,
|
|
10
14
|
];
|
|
11
|
-
if (comment.
|
|
12
|
-
lines.push(`${pad} Attachments: ${formatAttachments(comment.
|
|
15
|
+
if (comment.files && comment.files.length > 0) {
|
|
16
|
+
lines.push(`${pad} Attachments: ${formatAttachments(comment.files)}`);
|
|
13
17
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
lines.push(formatComment(reply, indent + 1));
|
|
17
|
-
}
|
|
18
|
+
for (const r of comment.replies ?? []) {
|
|
19
|
+
lines.push(formatComment(r, indent + 1));
|
|
18
20
|
}
|
|
19
21
|
return lines.join("\n");
|
|
20
22
|
}
|
|
23
|
+
// Issue and project comments share one shape; only the owner path differs.
|
|
24
|
+
const ownerSchema = {
|
|
25
|
+
team_id: z.number().describe("Team ID"),
|
|
26
|
+
issue_id: z
|
|
27
|
+
.number()
|
|
28
|
+
.optional()
|
|
29
|
+
.describe("Issue ID (give exactly one of issue_id or project_id)"),
|
|
30
|
+
project_id: z
|
|
31
|
+
.number()
|
|
32
|
+
.optional()
|
|
33
|
+
.describe("Project ID (give exactly one of issue_id or project_id)"),
|
|
34
|
+
};
|
|
35
|
+
function commentsPath(args) {
|
|
36
|
+
const { team_id, issue_id, project_id } = args;
|
|
37
|
+
if ((issue_id === undefined) === (project_id === undefined)) {
|
|
38
|
+
throw new Error("Give exactly one of issue_id or project_id.");
|
|
39
|
+
}
|
|
40
|
+
return issue_id !== undefined
|
|
41
|
+
? `/api/v1/teams/${team_id}/issues/${issue_id}/comments`
|
|
42
|
+
: `/api/v1/teams/${team_id}/projects/${project_id}/comments`;
|
|
43
|
+
}
|
|
21
44
|
export function registerCommentTools(server) {
|
|
22
|
-
server.tool("list_comments", "List all comments on an issue, with replies nested under their parent.", {
|
|
23
|
-
|
|
24
|
-
issue_id: z.number().describe("Issue ID"),
|
|
25
|
-
}, async ({ team_id, issue_id }) => {
|
|
26
|
-
const comments = await apiRequest(`/api/v1/teams/${team_id}/issues/${issue_id}/comments`);
|
|
45
|
+
server.tool("list_comments", "List all comments on an issue or a project, with replies nested under their parent.", ownerSchema, async (args) => {
|
|
46
|
+
const comments = await apiRequest(commentsPath(args));
|
|
27
47
|
const text = comments.map((c) => formatComment(c)).join("\n\n");
|
|
28
48
|
return {
|
|
29
|
-
content: [{ type: "text", text: text || "No comments
|
|
49
|
+
content: [{ type: "text", text: text || "No comments found." }],
|
|
30
50
|
};
|
|
31
51
|
});
|
|
32
|
-
server.tool("create_comment", "Post a new comment on an issue. The author is derived from the API token. Pass parent_id to reply to an existing comment, and file_paths to attach local files.", {
|
|
33
|
-
|
|
34
|
-
issue_id: z.number().describe("Issue ID"),
|
|
52
|
+
server.tool("create_comment", "Post a new comment on an issue or a project. The author is derived from the API token. Pass parent_id to reply to an existing comment, and file_paths to attach local files.", {
|
|
53
|
+
...ownerSchema,
|
|
35
54
|
body: z
|
|
36
55
|
.string()
|
|
37
56
|
.optional()
|
|
@@ -41,19 +60,60 @@ export function registerCommentTools(server) {
|
|
|
41
60
|
.optional()
|
|
42
61
|
.describe("Parent comment ID to reply to"),
|
|
43
62
|
file_paths: filePathsSchema,
|
|
44
|
-
}, async ({
|
|
45
|
-
const
|
|
46
|
-
const
|
|
47
|
-
const comment = await apiRequest(
|
|
48
|
-
|
|
49
|
-
|
|
63
|
+
}, async ({ body, parent_id, file_paths, ...owner }) => {
|
|
64
|
+
const path = commentsPath(owner);
|
|
65
|
+
const uploads = await uploadLocalFiles(file_paths);
|
|
66
|
+
const comment = await apiRequest(path, {
|
|
67
|
+
method: "POST",
|
|
68
|
+
body: {
|
|
69
|
+
comment: { body, parent_id },
|
|
70
|
+
files: uploads.map((u) => u.signedId),
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
return {
|
|
74
|
+
content: [
|
|
75
|
+
{ type: "text", text: `Comment posted:\n${formatComment(comment)}` },
|
|
76
|
+
],
|
|
77
|
+
};
|
|
78
|
+
});
|
|
79
|
+
server.tool("delete_comment", "Delete a comment on an issue, along with its replies. Only the comment's author or a team admin can do this.", {
|
|
80
|
+
team_id: z.number().describe("Team ID"),
|
|
81
|
+
issue_id: z.number().describe("Issue ID"),
|
|
82
|
+
comment_id: z.number().describe("Comment ID"),
|
|
83
|
+
}, async ({ team_id, issue_id, comment_id }) => {
|
|
84
|
+
await apiRequest(`/api/v1/teams/${team_id}/issues/${issue_id}/comments/${comment_id}`, { method: "DELETE" });
|
|
85
|
+
return {
|
|
86
|
+
content: [
|
|
87
|
+
{ type: "text", text: `Comment ${comment_id} deleted (with any replies).` },
|
|
88
|
+
],
|
|
89
|
+
};
|
|
90
|
+
});
|
|
91
|
+
server.tool("remove_comment_attachment", "Remove a file from a comment on an issue or a project. Only the comment's author or a team admin can do this. Get the attachment ID from list_comments.", {
|
|
92
|
+
...ownerSchema,
|
|
93
|
+
comment_id: z.number().describe("Comment ID"),
|
|
94
|
+
attachment_id: z.number().describe("Attachment ID (shown by list_comments)"),
|
|
95
|
+
}, async ({ comment_id, attachment_id, ...owner }) => {
|
|
96
|
+
await apiRequest(`${commentsPath(owner)}/${comment_id}/attachments/${attachment_id}`, { method: "DELETE" });
|
|
50
97
|
return {
|
|
51
98
|
content: [
|
|
52
99
|
{
|
|
53
100
|
type: "text",
|
|
54
|
-
text: `
|
|
101
|
+
text: `Attachment ${attachment_id} removed from comment ${comment_id}.`,
|
|
55
102
|
},
|
|
56
103
|
],
|
|
57
104
|
};
|
|
58
105
|
});
|
|
106
|
+
server.tool("list_team_comments", "List every issue and project comment in a team as one flat feed, oldest change first. Use updated_since to see only recent comments.", {
|
|
107
|
+
team_id: z.number().describe("Team ID"),
|
|
108
|
+
updated_since: z
|
|
109
|
+
.string()
|
|
110
|
+
.optional()
|
|
111
|
+
.describe("Only comments created or edited at/after this ISO 8601 timestamp"),
|
|
112
|
+
}, async ({ team_id, updated_since }) => {
|
|
113
|
+
const comments = await apiRequest(`/api/v1/teams/${team_id}/comments`, { params: { updated_since } });
|
|
114
|
+
const text = comments.map((c) => formatComment(c)).join("\n\n");
|
|
115
|
+
return {
|
|
116
|
+
content: [{ type: "text", text: text || "No comments found." }],
|
|
117
|
+
};
|
|
118
|
+
});
|
|
59
119
|
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { apiRequest } from "../api-client.js";
|
|
4
|
+
const ownerSchema = {
|
|
5
|
+
team_id: z.number().describe("Team ID"),
|
|
6
|
+
issue_id: z
|
|
7
|
+
.number()
|
|
8
|
+
.optional()
|
|
9
|
+
.describe("Issue ID (give exactly one of issue_id or project_id)"),
|
|
10
|
+
project_id: z
|
|
11
|
+
.number()
|
|
12
|
+
.optional()
|
|
13
|
+
.describe("Project ID (give exactly one of issue_id or project_id)"),
|
|
14
|
+
};
|
|
15
|
+
function decisionsPath(args) {
|
|
16
|
+
const { team_id, issue_id, project_id } = args;
|
|
17
|
+
if ((issue_id === undefined) === (project_id === undefined)) {
|
|
18
|
+
throw new Error("Give exactly one of issue_id or project_id.");
|
|
19
|
+
}
|
|
20
|
+
return issue_id !== undefined
|
|
21
|
+
? `/api/v1/teams/${team_id}/issues/${issue_id}/decisions`
|
|
22
|
+
: `/api/v1/teams/${team_id}/projects/${project_id}/decisions`;
|
|
23
|
+
}
|
|
24
|
+
export function registerDecisionTools(server) {
|
|
25
|
+
server.tool("create_decision", "Pin a decision (a short statement of what was decided) to an issue or a project. Keep the returned decision ID: there is no way to list decisions later, and unpin_decision needs it.", {
|
|
26
|
+
...ownerSchema,
|
|
27
|
+
body: z.string().describe("The decision text (markdown allowed)"),
|
|
28
|
+
pinned_by_email: z
|
|
29
|
+
.string()
|
|
30
|
+
.optional()
|
|
31
|
+
.describe("Email of the team member to credit as pinning it"),
|
|
32
|
+
}, async ({ body, pinned_by_email, ...owner }) => {
|
|
33
|
+
const decision = await apiRequest(decisionsPath(owner), {
|
|
34
|
+
method: "POST",
|
|
35
|
+
body: {
|
|
36
|
+
// The API requires a unique source-message id (decisions normally
|
|
37
|
+
// come from pinned Hourglass chat messages); mint one per call.
|
|
38
|
+
hourglass_message_id: `mcp-${randomUUID()}`,
|
|
39
|
+
body_snapshot: body,
|
|
40
|
+
pinned_by_email,
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
const by = decision.pinned_by_user ? ` by ${decision.pinned_by_user.name}` : "";
|
|
44
|
+
return {
|
|
45
|
+
content: [
|
|
46
|
+
{
|
|
47
|
+
type: "text",
|
|
48
|
+
text: `Decision pinned${by} — ID: ${decision.id}\n ${decision.body_snapshot}`,
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
};
|
|
52
|
+
});
|
|
53
|
+
server.tool("unpin_decision", "Unpin a decision from an issue or a project. It is kept as unpinned, not deleted.", {
|
|
54
|
+
...ownerSchema,
|
|
55
|
+
decision_id: z.number().describe("Decision ID (from create_decision)"),
|
|
56
|
+
}, async ({ decision_id, ...owner }) => {
|
|
57
|
+
await apiRequest(`${decisionsPath(owner)}/${decision_id}`, {
|
|
58
|
+
method: "DELETE",
|
|
59
|
+
});
|
|
60
|
+
return {
|
|
61
|
+
content: [{ type: "text", text: `Decision ${decision_id} unpinned.` }],
|
|
62
|
+
};
|
|
63
|
+
});
|
|
64
|
+
}
|
package/dist/tools/issues.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
2
|
import { type Attachment } from "../attachments.js";
|
|
3
|
-
interface Issue {
|
|
3
|
+
export interface Issue {
|
|
4
4
|
id: number;
|
|
5
5
|
identifier: string;
|
|
6
6
|
title: string;
|
|
@@ -28,16 +28,21 @@ interface Issue {
|
|
|
28
28
|
id: number;
|
|
29
29
|
name: string;
|
|
30
30
|
}[];
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
files?: Attachment[];
|
|
32
|
+
parent_issue_id?: number | null;
|
|
33
|
+
parent_issue?: {
|
|
33
34
|
id: number;
|
|
34
|
-
|
|
35
|
+
identifier: string;
|
|
35
36
|
} | null;
|
|
36
|
-
|
|
37
|
+
sub_issues?: {
|
|
37
38
|
id: number;
|
|
38
39
|
identifier: string;
|
|
39
40
|
title: string;
|
|
40
|
-
|
|
41
|
+
lane: {
|
|
42
|
+
id: number;
|
|
43
|
+
name: string;
|
|
44
|
+
} | null;
|
|
45
|
+
}[];
|
|
41
46
|
blocking_issues?: {
|
|
42
47
|
id: number;
|
|
43
48
|
identifier: string;
|
|
@@ -57,5 +62,40 @@ interface Issue {
|
|
|
57
62
|
updated_at: string;
|
|
58
63
|
}
|
|
59
64
|
export declare function formatIssue(issue: Issue, detailed?: boolean): string;
|
|
65
|
+
interface ActivityChange {
|
|
66
|
+
field: string;
|
|
67
|
+
from: unknown;
|
|
68
|
+
to: unknown;
|
|
69
|
+
}
|
|
70
|
+
export interface ActivityEntry {
|
|
71
|
+
type: "version" | "dependency" | "comment" | "reference";
|
|
72
|
+
id: number;
|
|
73
|
+
cursor: string;
|
|
74
|
+
created_at: string;
|
|
75
|
+
actor?: {
|
|
76
|
+
id: number;
|
|
77
|
+
name: string;
|
|
78
|
+
} | null;
|
|
79
|
+
user?: {
|
|
80
|
+
id: number;
|
|
81
|
+
name: string;
|
|
82
|
+
} | null;
|
|
83
|
+
description?: string;
|
|
84
|
+
changes?: ActivityChange[];
|
|
85
|
+
comment?: {
|
|
86
|
+
id: number;
|
|
87
|
+
body: string | null;
|
|
88
|
+
user: {
|
|
89
|
+
name: string;
|
|
90
|
+
} | null;
|
|
91
|
+
};
|
|
92
|
+
source_issue?: {
|
|
93
|
+
identifier: string;
|
|
94
|
+
title: string;
|
|
95
|
+
};
|
|
96
|
+
source_type?: string;
|
|
97
|
+
}
|
|
98
|
+
export declare function formatActivityEntry(entry: ActivityEntry): string;
|
|
99
|
+
export declare function formatActivityPage(entries: ActivityEntry[], nextBeforeId: string | null): string;
|
|
60
100
|
export declare function registerIssueTools(server: McpServer): void;
|
|
61
101
|
export {};
|