Skip to content

Commit 4c349a3

Browse files
author
Nicholas Crum
committed
feat: support resolving merge request notes
1 parent 95ad321 commit 4c349a3

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

index.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,7 +1027,7 @@ async function updateMergeRequestNote(
10271027
mergeRequestIid: number,
10281028
discussionId: string,
10291029
noteId: number,
1030-
body: string,
1030+
body?: string,
10311031
resolved?: boolean
10321032
): Promise<GitLabDiscussionNote> {
10331033
projectId = decodeURIComponent(projectId); // Decode project ID
@@ -1037,8 +1037,11 @@ async function updateMergeRequestNote(
10371037
)}/merge_requests/${mergeRequestIid}/discussions/${discussionId}/notes/${noteId}`
10381038
);
10391039

1040-
const payload: { body: string; resolved?: boolean } = { body };
1041-
if (resolved !== undefined) {
1040+
// Only one of body or resolved can be sent according to GitLab API
1041+
const payload: { body?: string; resolved?: boolean } = {};
1042+
if (body !== undefined) {
1043+
payload.body = body;
1044+
} else if (resolved !== undefined) {
10421045
payload.resolved = resolved;
10431046
}
10441047

@@ -2270,8 +2273,8 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
22702273
args.merge_request_iid,
22712274
args.discussion_id,
22722275
args.note_id,
2273-
args.body,
2274-
args.resolved // Pass resolved if provided
2276+
args.body, // Now optional
2277+
args.resolved // Now one of body or resolved must be provided, not both
22752278
);
22762279
return {
22772280
content: [{ type: "text", text: JSON.stringify(note, null, 2) }],

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

schemas.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -475,8 +475,12 @@ export const UpdateMergeRequestNoteSchema = ProjectParamsSchema.extend({
475475
merge_request_iid: z.number().describe("The IID of a merge request"),
476476
discussion_id: z.string().describe("The ID of a thread"),
477477
note_id: z.number().describe("The ID of a thread note"),
478-
body: z.string().describe("The content of the note or reply"),
479-
resolved: z.boolean().optional().describe("Resolve or unresolve the note"), // Optional based on API docs
478+
body: z.string().optional().describe("The content of the note or reply"),
479+
resolved: z.boolean().optional().describe("Resolve or unresolve the note"),
480+
}).refine(data => data.body !== undefined || data.resolved !== undefined, {
481+
message: "At least one of 'body' or 'resolved' must be provided"
482+
}).refine(data => !(data.body !== undefined && data.resolved !== undefined), {
483+
message: "Only one of 'body' or 'resolved' can be provided, not both"
480484
});
481485

482486
// API Operation Parameter Schemas

0 commit comments

Comments
 (0)