@zereight/mcp-gitlab 1.0.24 → 1.0.25

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 (3) hide show
  1. package/README.md +6 -8
  2. package/build/index.js +199 -172
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -10,7 +10,7 @@ GitLab MCP(Model Context Protocol) Server. **Includes bug fixes and improvements
10
10
 
11
11
  ## Usage
12
12
 
13
- ### Using with Claude App, Cline, Roo Code
13
+ ### Using with Claude App, Cline, Roo Code, Cursor
14
14
 
15
15
  When using with the Claude App, you need to set up your API key and URLs directly.
16
16
 
@@ -22,23 +22,20 @@ When using with the Claude App, you need to set up your API key and URLs directl
22
22
  "args": ["-y", "@zereight/mcp-gitlab"],
23
23
  "env": {
24
24
  "GITLAB_PERSONAL_ACCESS_TOKEN": "your_gitlab_token",
25
- "GITLAB_API_URL": "your_gitlab_api_url"
25
+ "GITLAB_API_URL": "your_gitlab_api_url",
26
+ "GITLAB_READ_ONLY_MODE": "true"
26
27
  }
27
28
  }
28
29
  }
29
30
  }
30
31
  ```
31
32
 
32
- ### Using with Cursor
33
+ ### Environment Variables
33
34
 
34
- When using with Cursor, you can set up environment variables and run the server as follows:
35
-
36
- ```
37
- env GITLAB_PERSONAL_ACCESS_TOKEN=your_gitlab_token GITLAB_API_URL=your_gitlab_api_url npx @zereight/mcp-gitlab
38
- ```
39
35
 
40
36
  - `GITLAB_PERSONAL_ACCESS_TOKEN`: Your GitLab personal access token.
41
37
  - `GITLAB_API_URL`: Your GitLab API URL. (Default: `https://gitlab.com/api/v4`)
38
+ - `GITLAB_READ_ONLY_MODE`: When set to 'true', restricts the server to only expose read-only operations. Useful for enhanced security or when write access is not needed. Also useful for using with Cursor and it's 40 tool limit.
42
39
 
43
40
  ## Tools 🛠️
44
41
 
@@ -272,6 +269,7 @@ Before running the server, you need to set the following environment variables:
272
269
  ```
273
270
  GITLAB_PERSONAL_ACCESS_TOKEN=your_gitlab_token
274
271
  GITLAB_API_URL=your_gitlab_api_url # Default: https://gitlab.com/api/v4
272
+ GITLAB_READ_ONLY_MODE=true # Optional: Enable read-only mode
275
273
  ```
276
274
 
277
275
  ## License
package/build/index.js CHANGED
@@ -39,6 +39,200 @@ const server = new Server({
39
39
  },
40
40
  });
41
41
  const GITLAB_PERSONAL_ACCESS_TOKEN = process.env.GITLAB_PERSONAL_ACCESS_TOKEN;
42
+ const GITLAB_READ_ONLY_MODE = process.env.GITLAB_READ_ONLY_MODE === 'true';
43
+ // Define all available tools
44
+ const allTools = [
45
+ {
46
+ name: "create_or_update_file",
47
+ description: "Create or update a single file in a GitLab project",
48
+ inputSchema: zodToJsonSchema(CreateOrUpdateFileSchema),
49
+ },
50
+ {
51
+ name: "search_repositories",
52
+ description: "Search for GitLab projects",
53
+ inputSchema: zodToJsonSchema(SearchRepositoriesSchema),
54
+ },
55
+ {
56
+ name: "create_repository",
57
+ description: "Create a new GitLab project",
58
+ inputSchema: zodToJsonSchema(CreateRepositorySchema),
59
+ },
60
+ {
61
+ name: "get_file_contents",
62
+ description: "Get the contents of a file or directory from a GitLab project",
63
+ inputSchema: zodToJsonSchema(GetFileContentsSchema),
64
+ },
65
+ {
66
+ name: "push_files",
67
+ description: "Push multiple files to a GitLab project in a single commit",
68
+ inputSchema: zodToJsonSchema(PushFilesSchema),
69
+ },
70
+ {
71
+ name: "create_issue",
72
+ description: "Create a new issue in a GitLab project",
73
+ inputSchema: zodToJsonSchema(CreateIssueSchema),
74
+ },
75
+ {
76
+ name: "create_merge_request",
77
+ description: "Create a new merge request in a GitLab project",
78
+ inputSchema: zodToJsonSchema(CreateMergeRequestSchema),
79
+ },
80
+ {
81
+ name: "fork_repository",
82
+ description: "Fork a GitLab project to your account or specified namespace",
83
+ inputSchema: zodToJsonSchema(ForkRepositorySchema),
84
+ },
85
+ {
86
+ name: "create_branch",
87
+ description: "Create a new branch in a GitLab project",
88
+ inputSchema: zodToJsonSchema(CreateBranchSchema),
89
+ },
90
+ {
91
+ name: "get_merge_request",
92
+ description: "Get details of a merge request",
93
+ inputSchema: zodToJsonSchema(GetMergeRequestSchema),
94
+ },
95
+ {
96
+ name: "get_merge_request_diffs",
97
+ description: "Get the changes/diffs of a merge request",
98
+ inputSchema: zodToJsonSchema(GetMergeRequestDiffsSchema),
99
+ },
100
+ {
101
+ name: "update_merge_request",
102
+ description: "Update a merge request",
103
+ inputSchema: zodToJsonSchema(UpdateMergeRequestSchema),
104
+ },
105
+ {
106
+ name: "create_note",
107
+ description: "Create a new note (comment) to an issue or merge request",
108
+ inputSchema: zodToJsonSchema(CreateNoteSchema),
109
+ },
110
+ {
111
+ name: "list_merge_request_discussions",
112
+ description: "List discussion items for a merge request",
113
+ inputSchema: zodToJsonSchema(ListMergeRequestDiscussionsSchema),
114
+ },
115
+ {
116
+ name: "update_merge_request_note",
117
+ description: "Modify an existing merge request thread note",
118
+ inputSchema: zodToJsonSchema(UpdateMergeRequestNoteSchema),
119
+ },
120
+ {
121
+ name: "list_issues",
122
+ description: "List issues in a GitLab project with filtering options",
123
+ inputSchema: zodToJsonSchema(ListIssuesSchema),
124
+ },
125
+ {
126
+ name: "get_issue",
127
+ description: "Get details of a specific issue in a GitLab project",
128
+ inputSchema: zodToJsonSchema(GetIssueSchema),
129
+ },
130
+ {
131
+ name: "update_issue",
132
+ description: "Update an issue in a GitLab project",
133
+ inputSchema: zodToJsonSchema(UpdateIssueSchema),
134
+ },
135
+ {
136
+ name: "delete_issue",
137
+ description: "Delete an issue from a GitLab project",
138
+ inputSchema: zodToJsonSchema(DeleteIssueSchema),
139
+ },
140
+ {
141
+ name: "list_issue_links",
142
+ description: "List all issue links for a specific issue",
143
+ inputSchema: zodToJsonSchema(ListIssueLinksSchema),
144
+ },
145
+ {
146
+ name: "get_issue_link",
147
+ description: "Get a specific issue link",
148
+ inputSchema: zodToJsonSchema(GetIssueLinkSchema),
149
+ },
150
+ {
151
+ name: "create_issue_link",
152
+ description: "Create an issue link between two issues",
153
+ inputSchema: zodToJsonSchema(CreateIssueLinkSchema),
154
+ },
155
+ {
156
+ name: "delete_issue_link",
157
+ description: "Delete an issue link",
158
+ inputSchema: zodToJsonSchema(DeleteIssueLinkSchema),
159
+ },
160
+ {
161
+ name: "list_namespaces",
162
+ description: "List all namespaces available to the current user",
163
+ inputSchema: zodToJsonSchema(ListNamespacesSchema),
164
+ },
165
+ {
166
+ name: "get_namespace",
167
+ description: "Get details of a namespace by ID or path",
168
+ inputSchema: zodToJsonSchema(GetNamespaceSchema),
169
+ },
170
+ {
171
+ name: "verify_namespace",
172
+ description: "Verify if a namespace path exists",
173
+ inputSchema: zodToJsonSchema(VerifyNamespaceSchema),
174
+ },
175
+ {
176
+ name: "get_project",
177
+ description: "Get details of a specific project",
178
+ inputSchema: zodToJsonSchema(GetProjectSchema),
179
+ },
180
+ {
181
+ name: "list_projects",
182
+ description: "List projects accessible by the current user",
183
+ inputSchema: zodToJsonSchema(ListProjectsSchema),
184
+ },
185
+ {
186
+ name: "list_labels",
187
+ description: "List labels for a project",
188
+ inputSchema: zodToJsonSchema(ListLabelsSchema),
189
+ },
190
+ {
191
+ name: "get_label",
192
+ description: "Get a single label from a project",
193
+ inputSchema: zodToJsonSchema(GetLabelSchema),
194
+ },
195
+ {
196
+ name: "create_label",
197
+ description: "Create a new label in a project",
198
+ inputSchema: zodToJsonSchema(CreateLabelSchema),
199
+ },
200
+ {
201
+ name: "update_label",
202
+ description: "Update an existing label in a project",
203
+ inputSchema: zodToJsonSchema(UpdateLabelSchema),
204
+ },
205
+ {
206
+ name: "delete_label",
207
+ description: "Delete a label from a project",
208
+ inputSchema: zodToJsonSchema(DeleteLabelSchema),
209
+ },
210
+ {
211
+ name: "list_group_projects",
212
+ description: "List projects in a GitLab group with filtering options",
213
+ inputSchema: zodToJsonSchema(ListGroupProjectsSchema),
214
+ },
215
+ ];
216
+ // Define which tools are read-only
217
+ const readOnlyTools = [
218
+ "search_repositories",
219
+ "get_file_contents",
220
+ "get_merge_request",
221
+ "get_merge_request_diffs",
222
+ "list_merge_request_discussions",
223
+ "list_issues",
224
+ "get_issue",
225
+ "list_issue_links",
226
+ "get_issue_link",
227
+ "list_namespaces",
228
+ "get_namespace",
229
+ "verify_namespace",
230
+ "get_project",
231
+ "list_projects",
232
+ "list_labels",
233
+ "get_label",
234
+ "list_group_projects"
235
+ ];
42
236
  /**
43
237
  * Smart URL handling for GitLab API
44
238
  *
@@ -1053,179 +1247,12 @@ async function listGroupProjects(options) {
1053
1247
  return GitLabProjectSchema.array().parse(projects);
1054
1248
  }
1055
1249
  server.setRequestHandler(ListToolsRequestSchema, async () => {
1250
+ // If read-only mode is enabled, filter out write operations
1251
+ const tools = GITLAB_READ_ONLY_MODE
1252
+ ? allTools.filter(tool => readOnlyTools.includes(tool.name))
1253
+ : allTools;
1056
1254
  return {
1057
- tools: [
1058
- {
1059
- name: "create_or_update_file",
1060
- description: "Create or update a single file in a GitLab project",
1061
- inputSchema: zodToJsonSchema(CreateOrUpdateFileSchema),
1062
- },
1063
- {
1064
- name: "search_repositories",
1065
- description: "Search for GitLab projects",
1066
- inputSchema: zodToJsonSchema(SearchRepositoriesSchema),
1067
- },
1068
- {
1069
- name: "create_repository",
1070
- description: "Create a new GitLab project",
1071
- inputSchema: zodToJsonSchema(CreateRepositorySchema),
1072
- },
1073
- {
1074
- name: "get_file_contents",
1075
- description: "Get the contents of a file or directory from a GitLab project",
1076
- inputSchema: zodToJsonSchema(GetFileContentsSchema),
1077
- },
1078
- {
1079
- name: "push_files",
1080
- description: "Push multiple files to a GitLab project in a single commit",
1081
- inputSchema: zodToJsonSchema(PushFilesSchema),
1082
- },
1083
- {
1084
- name: "create_issue",
1085
- description: "Create a new issue in a GitLab project",
1086
- inputSchema: zodToJsonSchema(CreateIssueSchema),
1087
- },
1088
- {
1089
- name: "create_merge_request",
1090
- description: "Create a new merge request in a GitLab project",
1091
- inputSchema: zodToJsonSchema(CreateMergeRequestSchema),
1092
- },
1093
- {
1094
- name: "fork_repository",
1095
- description: "Fork a GitLab project to your account or specified namespace",
1096
- inputSchema: zodToJsonSchema(ForkRepositorySchema),
1097
- },
1098
- {
1099
- name: "create_branch",
1100
- description: "Create a new branch in a GitLab project",
1101
- inputSchema: zodToJsonSchema(CreateBranchSchema),
1102
- },
1103
- {
1104
- name: "get_merge_request",
1105
- description: "Get details of a merge request",
1106
- inputSchema: zodToJsonSchema(GetMergeRequestSchema),
1107
- },
1108
- {
1109
- name: "get_merge_request_diffs",
1110
- description: "Get the changes/diffs of a merge request",
1111
- inputSchema: zodToJsonSchema(GetMergeRequestDiffsSchema),
1112
- },
1113
- {
1114
- name: "update_merge_request",
1115
- description: "Update a merge request",
1116
- inputSchema: zodToJsonSchema(UpdateMergeRequestSchema),
1117
- },
1118
- {
1119
- name: "create_note",
1120
- description: "Create a new note (comment) to an issue or merge request",
1121
- inputSchema: zodToJsonSchema(CreateNoteSchema),
1122
- },
1123
- {
1124
- name: "list_merge_request_discussions",
1125
- description: "List discussion items for a merge request",
1126
- inputSchema: zodToJsonSchema(ListMergeRequestDiscussionsSchema),
1127
- },
1128
- {
1129
- name: "update_merge_request_note",
1130
- description: "Modify an existing merge request thread note",
1131
- inputSchema: zodToJsonSchema(UpdateMergeRequestNoteSchema),
1132
- },
1133
- {
1134
- name: "list_issues",
1135
- description: "List issues in a GitLab project with filtering options",
1136
- inputSchema: zodToJsonSchema(ListIssuesSchema),
1137
- },
1138
- {
1139
- name: "get_issue",
1140
- description: "Get details of a specific issue in a GitLab project",
1141
- inputSchema: zodToJsonSchema(GetIssueSchema),
1142
- },
1143
- {
1144
- name: "update_issue",
1145
- description: "Update an issue in a GitLab project",
1146
- inputSchema: zodToJsonSchema(UpdateIssueSchema),
1147
- },
1148
- {
1149
- name: "delete_issue",
1150
- description: "Delete an issue from a GitLab project",
1151
- inputSchema: zodToJsonSchema(DeleteIssueSchema),
1152
- },
1153
- {
1154
- name: "list_issue_links",
1155
- description: "List all issue links for a specific issue",
1156
- inputSchema: zodToJsonSchema(ListIssueLinksSchema),
1157
- },
1158
- {
1159
- name: "get_issue_link",
1160
- description: "Get a specific issue link",
1161
- inputSchema: zodToJsonSchema(GetIssueLinkSchema),
1162
- },
1163
- {
1164
- name: "create_issue_link",
1165
- description: "Create an issue link between two issues",
1166
- inputSchema: zodToJsonSchema(CreateIssueLinkSchema),
1167
- },
1168
- {
1169
- name: "delete_issue_link",
1170
- description: "Delete an issue link",
1171
- inputSchema: zodToJsonSchema(DeleteIssueLinkSchema),
1172
- },
1173
- {
1174
- name: "list_namespaces",
1175
- description: "List all namespaces available to the current user",
1176
- inputSchema: zodToJsonSchema(ListNamespacesSchema),
1177
- },
1178
- {
1179
- name: "get_namespace",
1180
- description: "Get details of a namespace by ID or path",
1181
- inputSchema: zodToJsonSchema(GetNamespaceSchema),
1182
- },
1183
- {
1184
- name: "verify_namespace",
1185
- description: "Verify if a namespace path exists",
1186
- inputSchema: zodToJsonSchema(VerifyNamespaceSchema),
1187
- },
1188
- {
1189
- name: "get_project",
1190
- description: "Get details of a specific project",
1191
- inputSchema: zodToJsonSchema(GetProjectSchema),
1192
- },
1193
- {
1194
- name: "list_projects",
1195
- description: "List projects accessible by the current user",
1196
- inputSchema: zodToJsonSchema(ListProjectsSchema),
1197
- },
1198
- {
1199
- name: "list_labels",
1200
- description: "List labels for a project",
1201
- inputSchema: zodToJsonSchema(ListLabelsSchema),
1202
- },
1203
- {
1204
- name: "get_label",
1205
- description: "Get a single label from a project",
1206
- inputSchema: zodToJsonSchema(GetLabelSchema),
1207
- },
1208
- {
1209
- name: "create_label",
1210
- description: "Create a new label in a project",
1211
- inputSchema: zodToJsonSchema(CreateLabelSchema),
1212
- },
1213
- {
1214
- name: "update_label",
1215
- description: "Update an existing label in a project",
1216
- inputSchema: zodToJsonSchema(UpdateLabelSchema),
1217
- },
1218
- {
1219
- name: "delete_label",
1220
- description: "Delete a label from a project",
1221
- inputSchema: zodToJsonSchema(DeleteLabelSchema),
1222
- },
1223
- {
1224
- name: "list_group_projects",
1225
- description: "List projects in a GitLab group with filtering options",
1226
- inputSchema: zodToJsonSchema(ListGroupProjectsSchema),
1227
- },
1228
- ],
1255
+ tools,
1229
1256
  };
1230
1257
  });
1231
1258
  server.setRequestHandler(CallToolRequestSchema, async (request) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zereight/mcp-gitlab",
3
- "version": "1.0.24",
3
+ "version": "1.0.25",
4
4
  "description": "MCP server for using the GitLab API",
5
5
  "license": "MIT",
6
6
  "author": "zereight",