@zereight/mcp-gitlab 1.0.2 → 1.0.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.
package/README.md CHANGED
@@ -1,22 +1,196 @@
1
- # @zereight/mcp-gitlab
1
+ # Better GitLab MCP Server
2
2
 
3
- GitLab MCP(Model Context Protocol) 서버입니다.
3
+ ## @zereight/mcp-gitlab
4
4
 
5
- ## 설치 및 실행
5
+ [![smithery badge](https://smithery.ai/badge/@zereight/gitlab-mcp)](https://smithery.ai/server/@zereight/gitlab-mcp)
6
6
 
7
- ```bash
8
- npx @zereight/mcp-gitlab
7
+ GitLab MCP(Model Context Protocol) Server.
8
+
9
+ <a href="https://glama.ai/mcp/servers/7jwbk4r6d7"><img width="380" height="200" src="https://glama.ai/mcp/servers/7jwbk4r6d7/badge" alt="gitlab mcp MCP server" /></a>
10
+
11
+ ## Features ✨
12
+
13
+ - **Automatic Branch Creation**: Automatically creates a branch if it doesn't exist when creating/updating files or pushing changes. 🌿
14
+ - **Comprehensive Error Handling**: Provides clear error messages for common issues. ⚠️
15
+ - **Git History Preservation**: Operates without force-pushing, maintaining Git history. 📜
16
+ - **Batch Operations**: Supports both single and multi-file operations. 묶음
17
+ - **Versatile Search**: Supports project search functionality. 🔍
18
+
19
+ ## Tools 🛠️
20
+
21
+ 1. `create_or_update_file`
22
+
23
+ - Create or update a single file in a GitLab project. 📝
24
+ - Inputs:
25
+ - `project_id` (string): Project ID or namespace/project_path
26
+ - `file_path` (string): Path to create/update the file
27
+ - `content` (string): File content
28
+ - `commit_message` (string): Commit message
29
+ - `branch` (string): Branch to create/update the file in
30
+ - `previous_path` (optional string): Previous file path when renaming a file
31
+ - Returns: File content and commit details
32
+
33
+ 2. `push_files`
34
+
35
+ - Push multiple files in a single commit. 📤
36
+ - Inputs:
37
+ - `project_id` (string): Project ID or namespace/project_path
38
+ - `branch` (string): Branch to push to
39
+ - `files` (array): Array of files to push, each with `file_path` and `content` properties
40
+ - `commit_message` (string): Commit message
41
+ - Returns: Updated branch reference
42
+
43
+ 3. `search_repositories`
44
+
45
+ - Search for GitLab projects. 🔍
46
+ - Inputs:
47
+ - `search` (string): Search query
48
+ - `page` (optional number): Page number (default: 1)
49
+ - `per_page` (optional number): Results per page (default: 20, max: 100)
50
+ - Returns: Project search results
51
+
52
+ 4. `create_repository`
53
+
54
+ - Create a new GitLab project. ➕
55
+ - Inputs:
56
+ - `name` (string): Project name
57
+ - `description` (optional string): Project description
58
+ - `visibility` (optional string): Project visibility level (public, private, internal)
59
+ - `initialize_with_readme` (optional boolean): Initialize with README
60
+ - Returns: Details of the created project
61
+
62
+ 5. `get_file_contents`
63
+
64
+ - Get the contents of a file or directory. 📂
65
+ - Inputs:
66
+ - `project_id` (string): Project ID or namespace/project_path
67
+ - `file_path` (string): Path to the file/directory
68
+ - `ref` (optional string): Branch, tag, or commit SHA (default: default branch)
69
+ - Returns: File/directory content
70
+
71
+ 6. `create_issue`
72
+
73
+ - Create a new issue. 🐛
74
+ - Inputs:
75
+ - `project_id` (string): Project ID or namespace/project_path
76
+ - `title` (string): Issue title
77
+ - `description` (string): Issue description
78
+ - `assignee_ids` (optional number[]): Array of assignee IDs
79
+ - `milestone_id` (optional number): Milestone ID
80
+ - `labels` (optional string[]): Array of labels
81
+ - Returns: Details of the created issue
82
+
83
+ 7. `create_merge_request`
84
+
85
+ - Create a new merge request. 🚀
86
+ - Inputs:
87
+ - `project_id` (string): Project ID or namespace/project_path
88
+ - `title` (string): Merge request title
89
+ - `description` (string): Merge request description
90
+ - `source_branch` (string): Branch with changes
91
+ - `target_branch` (string): Branch to merge into
92
+ - `allow_collaboration` (optional boolean): Allow collaborators to push commits to the source branch
93
+ - `draft` (optional boolean): Create as a draft merge request
94
+ - Returns: Details of the created merge request
95
+
96
+ 8. `fork_repository`
97
+
98
+ - Fork a project. 🍴
99
+ - Inputs:
100
+ - `project_id` (string): Project ID or namespace/project_path to fork
101
+ - `namespace` (optional string): Namespace to fork into (default: user namespace)
102
+ - Returns: Details of the forked project
103
+
104
+ 9. `create_branch`
105
+
106
+ - Create a new branch. 🌿
107
+ - Inputs:
108
+ - `project_id` (string): Project ID or namespace/project_path
109
+ - `name` (string): New branch name
110
+ - `ref` (optional string): Ref to create the branch from (branch, tag, commit SHA, default: default branch)
111
+ - Returns: Created branch reference
112
+
113
+ 10. `get_merge_request`
114
+
115
+ - Get details of a merge request. ℹ️
116
+ - Inputs:
117
+ - `project_id` (string): Project ID or namespace/project_path
118
+ - `merge_request_iid` (number): Merge request IID
119
+ - Returns: Merge request details
120
+
121
+ 11. `get_merge_request_diffs`
122
+
123
+ - Get changes (diffs) of a merge request. diff
124
+ - Inputs:
125
+ - `project_id` (string): Project ID or namespace/project_path
126
+ - `merge_request_iid` (number): Merge request IID
127
+ - `view` (optional string): Diff view type ('inline' or 'parallel')
128
+ - Returns: Array of merge request diff information
129
+
130
+ 12. `update_merge_request`
131
+
132
+ - Update a merge request. 🔄
133
+ - Inputs:
134
+ - `project_id` (string): Project ID or namespace/project_path
135
+ - `merge_request_iid` (number): Merge request IID
136
+ - `title` (optional string): New title
137
+ - `description` (string): New description
138
+ - `target_branch` (optional string): New target branch
139
+ - `state_event` (optional string): Merge request state change event ('close', 'reopen')
140
+ - `remove_source_branch` (optional boolean): Remove source branch after merge
141
+ - `allow_collaboration` (optional boolean): Allow collaborators to push commits to the source branch
142
+ - Returns: Updated merge request details
143
+
144
+ 13. `create_note`
145
+ - Create a new note (comment) to an issue or merge request. 💬
146
+ - Inputs:
147
+ - `project_id` (string): Project ID or namespace/project_path
148
+ - `noteable_type` (string): Type of noteable ("issue" or "merge_request")
149
+ - `noteable_iid` (number): IID of the issue or merge request
150
+ - `body` (string): Note content
151
+ - Returns: Details of the created note
152
+
153
+ ## Environment Variable Configuration
154
+
155
+ Before running the server, you need to set the following environment variables:
156
+
157
+ ```
158
+ GITLAB_PERSONAL_ACCESS_TOKEN=your_gitlab_token
159
+ GITLAB_API_URL=your_gitlab_api_url # Default: https://gitlab.com/api/v4
160
+ ```
161
+
162
+ ## Usage
163
+
164
+ ### Using with Claude App, Cline, Roo Code
165
+
166
+ When using with the Claude App, you need to set up your API key and URLs directly.
167
+
168
+ ```json
169
+ {
170
+ "mcpServers": {
171
+ "GitLab communication server": {
172
+ "command": "npx",
173
+ "args": ["-y", "@zereight/mcp-gitlab"],
174
+ "env": {
175
+ "GITLAB_PERSONAL_ACCESS_TOKEN": "your_gitlab_token",
176
+ "GITLAB_API_URL": "your_gitlab_api_url"
177
+ }
178
+ }
179
+ }
180
+ }
9
181
  ```
10
182
 
11
- ## 환경 변수 설정
183
+ ### Using with Cursor
12
184
 
13
- 서버를 실행하기 전에 다음 환경 변수를 설정해야 합니다:
185
+ When using with Cursor, you can set up environment variables and run the server as follows:
14
186
 
15
- ```bash
16
- GITLAB_TOKEN=your_gitlab_token
17
- GITLAB_API_URL=your_gitlab_api_url # 기본값: https://gitlab.com/api/v4
18
187
  ```
188
+ env GITLAB_PERSONAL_ACCESS_TOKEN=your_gitlab_token GITLAB_API_URL=your_gitlab_api_url npx @zereight/mcp-gitlab
189
+ ```
190
+
191
+ - `GITLAB_PERSONAL_ACCESS_TOKEN`: Your GitLab personal access token.
192
+ - `GITLAB_API_URL`: Your GitLab API URL. (Default: `https://gitlab.com/api/v4`)
19
193
 
20
- ## 라이선스
194
+ ## License
21
195
 
22
196
  MIT License
package/build/index.js CHANGED
@@ -5,7 +5,7 @@ import { CallToolRequestSchema, ListToolsRequestSchema, } from "@modelcontextpro
5
5
  import fetch from "node-fetch";
6
6
  import { z } from "zod";
7
7
  import { zodToJsonSchema } from "zod-to-json-schema";
8
- import { GitLabForkSchema, GitLabReferenceSchema, GitLabRepositorySchema, GitLabIssueSchema, GitLabMergeRequestSchema, GitLabContentSchema, GitLabCreateUpdateFileResponseSchema, GitLabSearchResponseSchema, GitLabTreeSchema, GitLabCommitSchema, CreateOrUpdateFileSchema, SearchRepositoriesSchema, CreateRepositorySchema, GetFileContentsSchema, PushFilesSchema, CreateIssueSchema, CreateMergeRequestSchema, ForkRepositorySchema, CreateBranchSchema, GitLabMergeRequestDiffSchema, GetMergeRequestSchema, GetMergeRequestDiffsSchema, UpdateMergeRequestSchema, } from "./schemas.js";
8
+ import { GitLabForkSchema, GitLabReferenceSchema, GitLabRepositorySchema, GitLabIssueSchema, GitLabMergeRequestSchema, GitLabContentSchema, GitLabCreateUpdateFileResponseSchema, GitLabSearchResponseSchema, GitLabTreeSchema, GitLabCommitSchema, CreateOrUpdateFileSchema, SearchRepositoriesSchema, CreateRepositorySchema, GetFileContentsSchema, PushFilesSchema, CreateIssueSchema, CreateMergeRequestSchema, ForkRepositorySchema, CreateBranchSchema, GitLabMergeRequestDiffSchema, GetMergeRequestSchema, GetMergeRequestDiffsSchema, UpdateMergeRequestSchema, CreateNoteSchema, } from "./schemas.js";
9
9
  const server = new Server({
10
10
  name: "gitlab-mcp-server",
11
11
  version: "0.0.1",
@@ -341,6 +341,19 @@ async function updateMergeRequest(projectId, mergeRequestIid, options) {
341
341
  await handleGitLabError(response);
342
342
  return GitLabMergeRequestSchema.parse(await response.json());
343
343
  }
344
+ // 📦 새로운 함수: createNote - 이슈 또는 병합 요청에 노트(댓글)를 추가하는 함수
345
+ async function createNote(projectId, noteableType, // 'issue' 또는 'merge_request' 타입 명시
346
+ noteableIid, body) {
347
+ // ⚙️ 응답 타입은 GitLab API 문서에 따라 조정 가능
348
+ const url = new URL(`${GITLAB_API_URL}/projects/${encodeURIComponent(projectId)}/${noteableType}/${noteableIid}/notes`);
349
+ const response = await fetch(url.toString(), {
350
+ method: "POST",
351
+ headers: DEFAULT_HEADERS,
352
+ body: JSON.stringify({ body }),
353
+ });
354
+ await handleGitLabError(response);
355
+ return await response.json(); // ⚙️ 응답 타입은 GitLab API 문서에 따라 조정 가능, 필요하면 스키마 정의
356
+ }
344
357
  server.setRequestHandler(ListToolsRequestSchema, async () => {
345
358
  return {
346
359
  tools: [
@@ -404,6 +417,11 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
404
417
  description: "Update a merge request",
405
418
  inputSchema: zodToJsonSchema(UpdateMergeRequestSchema),
406
419
  },
420
+ {
421
+ name: "create_note",
422
+ description: "Create a new note (comment) to an issue or merge request",
423
+ inputSchema: zodToJsonSchema(CreateNoteSchema),
424
+ },
407
425
  ],
408
426
  };
409
427
  });
@@ -515,6 +533,24 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
515
533
  ],
516
534
  };
517
535
  }
536
+ case "create_note": {
537
+ try {
538
+ const args = CreateNoteSchema.parse(request.params.arguments);
539
+ const { project_id, noteable_type, noteable_iid, body } = args;
540
+ const note = await createNote(project_id, noteable_type, noteable_iid, body);
541
+ return {
542
+ content: [{ type: "text", text: JSON.stringify(note, null, 2) }],
543
+ };
544
+ }
545
+ catch (error) {
546
+ if (error instanceof z.ZodError) {
547
+ throw new Error(`Invalid arguments: ${error.errors
548
+ .map((e) => `${e.path.join(".")}: ${e.message}`)
549
+ .join(", ")}`);
550
+ }
551
+ throw error;
552
+ }
553
+ }
518
554
  default:
519
555
  throw new Error(`Unknown tool: ${request.params.name}`);
520
556
  }
package/build/schemas.js CHANGED
@@ -346,3 +346,11 @@ export const UpdateMergeRequestSchema = GetMergeRequestSchema.extend({
346
346
  export const GetMergeRequestDiffsSchema = GetMergeRequestSchema.extend({
347
347
  view: z.enum(["inline", "parallel"]).optional().describe("Diff view type"),
348
348
  });
349
+ export const CreateNoteSchema = z.object({
350
+ project_id: z.string().describe("Project ID or namespace/project_path"),
351
+ noteable_type: z
352
+ .enum(["issue", "merge_request"])
353
+ .describe("Type of noteable (issue or merge_request)"),
354
+ noteable_iid: z.number().describe("IID of the issue or merge request"),
355
+ body: z.string().describe("Note content"),
356
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zereight/mcp-gitlab",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "MCP server for using the GitLab API",
5
5
  "license": "MIT",
6
6
  "author": "zereight",