@zereight/mcp-gitlab 1.0.3 β 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 +153 -24
- package/build/index.js +37 -1
- package/build/schemas.js +8 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Better GitLab MCP Server
|
|
2
|
+
|
|
3
|
+
## @zereight/mcp-gitlab
|
|
2
4
|
|
|
3
5
|
[](https://smithery.ai/server/@zereight/gitlab-mcp)
|
|
4
6
|
|
|
@@ -6,37 +8,160 @@ GitLab MCP(Model Context Protocol) Server.
|
|
|
6
8
|
|
|
7
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>
|
|
8
10
|
|
|
9
|
-
##
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
|
23
152
|
|
|
24
153
|
## Environment Variable Configuration
|
|
25
154
|
|
|
26
155
|
Before running the server, you need to set the following environment variables:
|
|
27
156
|
|
|
28
|
-
```
|
|
157
|
+
```
|
|
29
158
|
GITLAB_PERSONAL_ACCESS_TOKEN=your_gitlab_token
|
|
30
159
|
GITLAB_API_URL=your_gitlab_api_url # Default: https://gitlab.com/api/v4
|
|
31
160
|
```
|
|
32
161
|
|
|
33
|
-
##
|
|
162
|
+
## Usage
|
|
34
163
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
## How to use
|
|
38
|
-
|
|
39
|
-
## Using with Claude App, Cline, Roo Code
|
|
164
|
+
### Using with Claude App, Cline, Roo Code
|
|
40
165
|
|
|
41
166
|
When using with the Claude App, you need to set up your API key and URLs directly.
|
|
42
167
|
|
|
@@ -55,13 +180,17 @@ When using with the Claude App, you need to set up your API key and URLs directl
|
|
|
55
180
|
}
|
|
56
181
|
```
|
|
57
182
|
|
|
58
|
-
|
|
183
|
+
### Using with Cursor
|
|
59
184
|
|
|
60
185
|
When using with Cursor, you can set up environment variables and run the server as follows:
|
|
61
186
|
|
|
62
|
-
```
|
|
187
|
+
```
|
|
63
188
|
env GITLAB_PERSONAL_ACCESS_TOKEN=your_gitlab_token GITLAB_API_URL=your_gitlab_api_url npx @zereight/mcp-gitlab
|
|
64
189
|
```
|
|
65
190
|
|
|
66
191
|
- `GITLAB_PERSONAL_ACCESS_TOKEN`: Your GitLab personal access token.
|
|
67
192
|
- `GITLAB_API_URL`: Your GitLab API URL. (Default: `https://gitlab.com/api/v4`)
|
|
193
|
+
|
|
194
|
+
## License
|
|
195
|
+
|
|
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
|
+
});
|