@@ -87,6 +87,7 @@ import {
8787 GitLabDiscussionNoteSchema , // Added
8888 GitLabDiscussionSchema ,
8989 UpdateMergeRequestNoteSchema , // Added
90+ AddMergeRequestThreadNoteSchema , // Added
9091 ListMergeRequestDiscussionsSchema ,
9192 type GitLabFork ,
9293 type GitLabReference ,
@@ -280,6 +281,11 @@ const allTools = [
280281 description : "Modify an existing merge request thread note" ,
281282 inputSchema : zodToJsonSchema ( UpdateMergeRequestNoteSchema ) ,
282283 } ,
284+ {
285+ name : "add_merge_request_thread_note" ,
286+ description : "Add a new note to an existing merge request thread" ,
287+ inputSchema : zodToJsonSchema ( AddMergeRequestThreadNoteSchema ) ,
288+ } ,
283289 {
284290 name : "list_issues" ,
285291 description : "List issues in a GitLab project with filtering options" ,
@@ -1060,6 +1066,47 @@ async function updateMergeRequestNote(
10601066 return GitLabDiscussionNoteSchema . parse ( data ) ;
10611067}
10621068
1069+ /**
1070+ * Add a new note to an existing merge request thread
1071+ * 기존 병합 요청 스레드에 새 노트 추가
1072+ *
1073+ * @param {string } projectId - The ID or URL-encoded path of the project
1074+ * @param {number } mergeRequestIid - The IID of a merge request
1075+ * @param {string } discussionId - The ID of a thread
1076+ * @param {string } body - The content of the new note
1077+ * @param {string } [createdAt] - The creation date of the note (ISO 8601 format)
1078+ * @returns {Promise<GitLabDiscussionNote> } The created note
1079+ */
1080+ async function addMergeRequestThreadNote (
1081+ projectId : string ,
1082+ mergeRequestIid : number ,
1083+ discussionId : string ,
1084+ body : string ,
1085+ createdAt ? : string
1086+ ) : Promise < GitLabDiscussionNote > {
1087+ projectId = decodeURIComponent ( projectId ) ; // Decode project ID
1088+ const url = new URL (
1089+ `${ GITLAB_API_URL } /projects/${ encodeURIComponent (
1090+ projectId
1091+ ) } /merge_requests/${ mergeRequestIid } /discussions/${ discussionId } /notes`
1092+ ) ;
1093+
1094+ const payload : { body : string ; created_at ?: string } = { body } ;
1095+ if ( createdAt ) {
1096+ payload . created_at = createdAt ;
1097+ }
1098+
1099+ const response = await fetch ( url . toString ( ) , {
1100+ ...DEFAULT_FETCH_CONFIG ,
1101+ method : "POST" ,
1102+ body : JSON . stringify ( payload ) ,
1103+ } ) ;
1104+
1105+ await handleGitLabError ( response ) ;
1106+ const data = await response . json ( ) ;
1107+ return GitLabDiscussionNoteSchema . parse ( data ) ;
1108+ }
1109+
10631110/**
10641111 * Create or update a file in a GitLab project
10651112 * 파일 생성 또는 업데이트
@@ -2337,6 +2384,22 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
23372384 content : [ { type : "text" , text : JSON . stringify ( note , null , 2 ) } ] ,
23382385 } ;
23392386 }
2387+
2388+ case "add_merge_request_thread_note" : {
2389+ const args = AddMergeRequestThreadNoteSchema . parse (
2390+ request . params . arguments
2391+ ) ;
2392+ const note = await addMergeRequestThreadNote (
2393+ args . project_id ,
2394+ args . merge_request_iid ,
2395+ args . discussion_id ,
2396+ args . body ,
2397+ args . created_at
2398+ ) ;
2399+ return {
2400+ content : [ { type : "text" , text : JSON . stringify ( note , null , 2 ) } ] ,
2401+ } ;
2402+ }
23402403
23412404 case "get_merge_request" : {
23422405 const args = GetMergeRequestSchema . parse ( request . params . arguments ) ;
0 commit comments