gitlab-mcp 0.1.3 → 0.1.4

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.
Files changed (2) hide show
  1. package/build/index.js +1 -43
  2. package/package.json +1 -1
package/build/index.js CHANGED
@@ -271,7 +271,6 @@ if (!GITLAB_PERSONAL_ACCESS_TOKEN) {
271
271
  }
272
272
  /**
273
273
  * Common headers for GitLab API requests
274
- * GitLab API 공통 헤더 (Common headers for GitLab API)
275
274
  */
276
275
  const DEFAULT_HEADERS = {
277
276
  Accept: "application/json",
@@ -280,7 +279,6 @@ const DEFAULT_HEADERS = {
280
279
  };
281
280
  /**
282
281
  * Utility function for handling GitLab API errors
283
- * API 에러 처리를 위한 유틸리티 함수 (Utility function for handling API errors)
284
282
  *
285
283
  * @param {import("node-fetch").Response} response - The response from GitLab API
286
284
  * @throws {Error} Throws an error with response details if the request failed
@@ -303,14 +301,12 @@ async function handleGitLabError(response) {
303
301
  }
304
302
  /**
305
303
  * Create a fork of a GitLab project
306
- * 프로젝트 포크 생성 (Create a project fork)
307
304
  *
308
305
  * @param {string} projectId - The ID or URL-encoded path of the project
309
306
  * @param {string} [namespace] - The namespace to fork the project to
310
307
  * @returns {Promise<GitLabFork>} The created fork
311
308
  */
312
309
  async function forkProject(projectId, namespace) {
313
- // API 엔드포인트 URL 생성
314
310
  const url = new URL(`${GITLAB_API_URL}/projects/${encodeURIComponent(projectId)}/fork`);
315
311
  if (namespace) {
316
312
  url.searchParams.append("namespace", namespace);
@@ -319,7 +315,6 @@ async function forkProject(projectId, namespace) {
319
315
  method: "POST",
320
316
  headers: DEFAULT_HEADERS,
321
317
  });
322
- // 이미 존재하는 프로젝트인 경우 처리
323
318
  if (response.status === 409) {
324
319
  throw new Error("Project already exists in the target namespace");
325
320
  }
@@ -329,7 +324,6 @@ async function forkProject(projectId, namespace) {
329
324
  }
330
325
  /**
331
326
  * Create a new branch in a GitLab project
332
- * 새로운 브랜치 생성 (Create a new branch)
333
327
  *
334
328
  * @param {string} projectId - The ID or URL-encoded path of the project
335
329
  * @param {z.infer<typeof CreateBranchOptionsSchema>} options - Branch creation options
@@ -350,7 +344,6 @@ async function createBranch(projectId, options) {
350
344
  }
351
345
  /**
352
346
  * Get the default branch for a GitLab project
353
- * 프로젝트의 기본 브랜치 조회 (Get the default branch of a project)
354
347
  *
355
348
  * @param {string} projectId - The ID or URL-encoded path of the project
356
349
  * @returns {Promise<string>} The name of the default branch
@@ -366,7 +359,6 @@ async function getDefaultBranchRef(projectId) {
366
359
  }
367
360
  /**
368
361
  * Get the contents of a file from a GitLab project
369
- * 파일 내용 조회 (Get file contents)
370
362
  *
371
363
  * @param {string} projectId - The ID or URL-encoded path of the project
372
364
  * @param {string} filePath - The path of the file to get
@@ -375,7 +367,6 @@ async function getDefaultBranchRef(projectId) {
375
367
  */
376
368
  async function getFileContents(projectId, filePath, ref) {
377
369
  const encodedPath = encodeURIComponent(filePath);
378
- // ref가 없는 경우 default branch를 가져옴
379
370
  if (!ref) {
380
371
  ref = await getDefaultBranchRef(projectId);
381
372
  }
@@ -384,14 +375,12 @@ async function getFileContents(projectId, filePath, ref) {
384
375
  const response = await fetch(url.toString(), {
385
376
  headers: DEFAULT_HEADERS,
386
377
  });
387
- // 파일을 찾을 수 없는 경우 처리
388
378
  if (response.status === 404) {
389
379
  throw new Error(`File not found: ${filePath}`);
390
380
  }
391
381
  await handleGitLabError(response);
392
382
  const data = await response.json();
393
383
  const parsedData = GitLabContentSchema.parse(data);
394
- // Base64로 인코딩된 파일 내용을 UTF-8로 디코딩
395
384
  if (!Array.isArray(parsedData) && parsedData.content) {
396
385
  parsedData.content = Buffer.from(parsedData.content, "base64").toString("utf8");
397
386
  parsedData.encoding = "utf8";
@@ -400,7 +389,6 @@ async function getFileContents(projectId, filePath, ref) {
400
389
  }
401
390
  /**
402
391
  * Create a new issue in a GitLab project
403
- * 이슈 생성 (Create an issue)
404
392
  *
405
393
  * @param {string} projectId - The ID or URL-encoded path of the project
406
394
  * @param {z.infer<typeof CreateIssueOptionsSchema>} options - Issue creation options
@@ -419,7 +407,6 @@ async function createIssue(projectId, options) {
419
407
  labels: options.labels?.join(","),
420
408
  }),
421
409
  });
422
- // 잘못된 요청 처리
423
410
  if (response.status === 400) {
424
411
  const errorBody = await response.text();
425
412
  throw new Error(`Invalid request: ${errorBody}`);
@@ -430,7 +417,6 @@ async function createIssue(projectId, options) {
430
417
  }
431
418
  /**
432
419
  * List issues in a GitLab project
433
- * 프로젝트의 이슈 목록 조회
434
420
  *
435
421
  * @param {string} projectId - The ID or URL-encoded path of the project
436
422
  * @param {Object} options - Options for listing issues
@@ -459,7 +445,6 @@ async function listIssues(projectId, options = {}) {
459
445
  }
460
446
  /**
461
447
  * Get a single issue from a GitLab project
462
- * 단일 이슈 조회
463
448
  *
464
449
  * @param {string} projectId - The ID or URL-encoded path of the project
465
450
  * @param {number} issueIid - The internal ID of the project issue
@@ -476,7 +461,6 @@ async function getIssue(projectId, issueIid) {
476
461
  }
477
462
  /**
478
463
  * Update an issue in a GitLab project
479
- * 이슈 업데이트
480
464
  *
481
465
  * @param {string} projectId - The ID or URL-encoded path of the project
482
466
  * @param {number} issueIid - The internal ID of the project issue
@@ -501,7 +485,6 @@ async function updateIssue(projectId, issueIid, options) {
501
485
  }
502
486
  /**
503
487
  * Delete an issue from a GitLab project
504
- * 이슈 삭제
505
488
  *
506
489
  * @param {string} projectId - The ID or URL-encoded path of the project
507
490
  * @param {number} issueIid - The internal ID of the project issue
@@ -517,7 +500,6 @@ async function deleteIssue(projectId, issueIid) {
517
500
  }
518
501
  /**
519
502
  * List all issue links for a specific issue
520
- * 이슈 관계 목록 조회
521
503
  *
522
504
  * @param {string} projectId - The ID or URL-encoded path of the project
523
505
  * @param {number} issueIid - The internal ID of the project issue
@@ -534,7 +516,6 @@ async function listIssueLinks(projectId, issueIid) {
534
516
  }
535
517
  /**
536
518
  * Get a specific issue link
537
- * 특정 이슈 관계 조회
538
519
  *
539
520
  * @param {string} projectId - The ID or URL-encoded path of the project
540
521
  * @param {number} issueIid - The internal ID of the project issue
@@ -552,7 +533,6 @@ async function getIssueLink(projectId, issueIid, issueLinkId) {
552
533
  }
553
534
  /**
554
535
  * Create an issue link between two issues
555
- * 이슈 관계 생성
556
536
  *
557
537
  * @param {string} projectId - The ID or URL-encoded path of the project
558
538
  * @param {number} issueIid - The internal ID of the project issue
@@ -578,7 +558,6 @@ async function createIssueLink(projectId, issueIid, targetProjectId, targetIssue
578
558
  }
579
559
  /**
580
560
  * Delete an issue link
581
- * 이슈 관계 삭제
582
561
  *
583
562
  * @param {string} projectId - The ID or URL-encoded path of the project
584
563
  * @param {number} issueIid - The internal ID of the project issue
@@ -595,7 +574,6 @@ async function deleteIssueLink(projectId, issueIid, issueLinkId) {
595
574
  }
596
575
  /**
597
576
  * Create a new merge request in a GitLab project
598
- * 병합 요청 생성
599
577
  *
600
578
  * @param {string} projectId - The ID or URL-encoded path of the project
601
579
  * @param {z.infer<typeof CreateMergeRequestOptionsSchema>} options - Merge request creation options
@@ -632,7 +610,6 @@ async function createMergeRequest(projectId, options) {
632
610
  }
633
611
  /**
634
612
  * List merge request discussion items
635
- * 병합 요청 토론 목록 조회
636
613
  *
637
614
  * @param {string} projectId - The ID or URL-encoded path of the project
638
615
  * @param {number} mergeRequestIid - The IID of a merge request
@@ -650,7 +627,6 @@ async function listMergeRequestDiscussions(projectId, mergeRequestIid) {
650
627
  }
651
628
  /**
652
629
  * Modify an existing merge request thread note
653
- * 병합 요청 토론 노트 수정
654
630
  *
655
631
  * @param {string} projectId - The ID or URL-encoded path of the project
656
632
  * @param {number} mergeRequestIid - The IID of a merge request
@@ -677,7 +653,6 @@ async function updateMergeRequestNote(projectId, mergeRequestIid, discussionId,
677
653
  }
678
654
  /**
679
655
  * Create or update a file in a GitLab project
680
- * 파일 생성 또는 업데이트
681
656
  *
682
657
  * @param {string} projectId - The ID or URL-encoded path of the project
683
658
  * @param {string} filePath - The path of the file to create or update
@@ -751,7 +726,6 @@ async function createOrUpdateFile(projectId, filePath, content, commitMessage, b
751
726
  }
752
727
  /**
753
728
  * Create a tree structure in a GitLab project repository
754
- * 저장소에 트리 구조 생성
755
729
  *
756
730
  * @param {string} projectId - The ID or URL-encoded path of the project
757
731
  * @param {FileOperation[]} files - Array of file operations
@@ -791,7 +765,6 @@ async function createTree(projectId, files, ref) {
791
765
  }
792
766
  /**
793
767
  * Create a commit in a GitLab project repository
794
- * 저장소에 커밋 생성
795
768
  *
796
769
  * @param {string} projectId - The ID or URL-encoded path of the project
797
770
  * @param {string} message - The commit message
@@ -902,7 +875,6 @@ async function createRepository(options) {
902
875
  }
903
876
  /**
904
877
  * Get merge request details
905
- * MR 조회 함수 (Function to retrieve merge request)
906
878
  *
907
879
  * @param {string} projectId - The ID or URL-encoded path of the project
908
880
  * @param {number} mergeRequestIid - The internal ID of the merge request
@@ -939,7 +911,6 @@ async function getMergeRequestDiffs(projectId, mergeRequestIid, view) {
939
911
  }
940
912
  /**
941
913
  * Update a merge request
942
- * MR 업데이트 함수 (Function to update merge request)
943
914
  *
944
915
  * @param {string} projectId - The ID or URL-encoded path of the project
945
916
  * @param {number} mergeRequestIid - The internal ID of the merge request
@@ -958,7 +929,6 @@ async function updateMergeRequest(projectId, mergeRequestIid, options) {
958
929
  }
959
930
  /**
960
931
  * Create a new note (comment) on an issue or merge request
961
- * 📦 새로운 함수: createNote - 이슈 또는 병합 요청에 노트(댓글)를 추가하는 함수
962
932
  * (New function: createNote - Function to add a note (comment) to an issue or merge request)
963
933
  *
964
934
  * @param {string} projectId - The ID or URL-encoded path of the project
@@ -967,9 +937,7 @@ async function updateMergeRequest(projectId, mergeRequestIid, options) {
967
937
  * @param {string} body - The content of the note
968
938
  * @returns {Promise<any>} The created note
969
939
  */
970
- async function createNote(projectId, noteableType, // 'issue' 또는 'merge_request' 타입 명시
971
- noteableIid, body) {
972
- // ⚙️ 응답 타입은 GitLab API 문서에 따라 조정 가능
940
+ async function createNote(projectId, noteableType, noteableIid, body) {
973
941
  const url = new URL(`${GITLAB_API_URL}/projects/${encodeURIComponent(projectId)}/${noteableType}s/${noteableIid}/notes` // Using plural form (issues/merge_requests) as per GitLab API documentation
974
942
  );
975
943
  const response = await fetch(url.toString(), {
@@ -985,7 +953,6 @@ noteableIid, body) {
985
953
  }
986
954
  /**
987
955
  * List all namespaces
988
- * 사용 가능한 모든 네임스페이스 목록 조회
989
956
  *
990
957
  * @param {Object} options - Options for listing namespaces
991
958
  * @param {string} [options.search] - Search query to filter namespaces
@@ -1013,7 +980,6 @@ async function listNamespaces(options) {
1013
980
  }
1014
981
  /**
1015
982
  * Get details on a namespace
1016
- * 네임스페이스 상세 정보 조회
1017
983
  *
1018
984
  * @param {string} id - The ID or URL-encoded path of the namespace
1019
985
  * @returns {Promise<GitLabNamespace>} The namespace details
@@ -1029,7 +995,6 @@ async function getNamespace(id) {
1029
995
  }
1030
996
  /**
1031
997
  * Verify if a namespace exists
1032
- * 네임스페이스 존재 여부 확인
1033
998
  *
1034
999
  * @param {string} namespacePath - The path of the namespace to check
1035
1000
  * @param {number} [parentId] - The ID of the parent namespace
@@ -1049,7 +1014,6 @@ async function verifyNamespaceExistence(namespacePath, parentId) {
1049
1014
  }
1050
1015
  /**
1051
1016
  * Get a single project
1052
- * 단일 프로젝트 조회
1053
1017
  *
1054
1018
  * @param {string} projectId - The ID or URL-encoded path of the project
1055
1019
  * @param {Object} options - Options for getting project details
@@ -1078,7 +1042,6 @@ async function getProject(projectId, options = {}) {
1078
1042
  }
1079
1043
  /**
1080
1044
  * List projects
1081
- * 프로젝트 목록 조회
1082
1045
  *
1083
1046
  * @param {Object} options - Options for listing projects
1084
1047
  * @returns {Promise<GitLabProject[]>} List of projects
@@ -1637,7 +1600,6 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
1637
1600
  });
1638
1601
  /**
1639
1602
  * Initialize and run the server
1640
- * 서버 초기화 및 실행
1641
1603
  */
1642
1604
  async function runServer() {
1643
1605
  if (isSSE) {
@@ -1647,10 +1609,6 @@ async function runServer() {
1647
1609
  console.log("Establishing new SSE connection");
1648
1610
  transport = new SSEServerTransport("/messages", res);
1649
1611
  await server.connect(transport);
1650
- server.onclose = async () => {
1651
- await server.close();
1652
- process.exit(0);
1653
- };
1654
1612
  });
1655
1613
  app.post("/messages", async (req, res) => {
1656
1614
  await transport?.handlePostMessage(req, res);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gitlab-mcp",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "Model Context Protocol server for GitLab integration",
5
5
  "main": "./build/index.js",
6
6
  "type": "module",