Skip to content

Commit def7549

Browse files
authored
Merge pull request #43 from Taylor4484/gitlab-server
Initial GitLab server version
2 parents b4a9a3d + cfdf46f commit def7549

File tree

6 files changed

+1584
-0
lines changed

6 files changed

+1584
-0
lines changed

src/gitlab/README.md

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
# GitLab MCP Server
2+
3+
MCP Server for the GitLab API, enabling project management, file operations, and more.
4+
5+
### Features
6+
7+
- **Automatic Branch Creation**: When creating/updating files or pushing changes, branches are automatically created if they don't exist
8+
- **Comprehensive Error Handling**: Clear error messages for common issues
9+
- **Git History Preservation**: Operations maintain proper Git history without force pushing
10+
- **Batch Operations**: Support for both single-file and multi-file operations
11+
12+
13+
## Tools
14+
15+
1. `create_or_update_file`
16+
- Create or update a single file in a project
17+
- Inputs:
18+
- `project_id` (string): Project ID or URL-encoded path
19+
- `file_path` (string): Path where to create/update the file
20+
- `content` (string): Content of the file
21+
- `commit_message` (string): Commit message
22+
- `branch` (string): Branch to create/update the file in
23+
- `previous_path` (optional string): Path of the file to move/rename
24+
- Returns: File content and commit details
25+
26+
2. `push_files`
27+
- Push multiple files in a single commit
28+
- Inputs:
29+
- `project_id` (string): Project ID or URL-encoded path
30+
- `branch` (string): Branch to push to
31+
- `files` (array): Files to push, each with `file_path` and `content`
32+
- `commit_message` (string): Commit message
33+
- Returns: Updated branch reference
34+
35+
3. `search_repositories`
36+
- Search for GitLab projects
37+
- Inputs:
38+
- `search` (string): Search query
39+
- `page` (optional number): Page number for pagination
40+
- `per_page` (optional number): Results per page (default 20)
41+
- Returns: Project search results
42+
43+
4. `create_repository`
44+
- Create a new GitLab project
45+
- Inputs:
46+
- `name` (string): Project name
47+
- `description` (optional string): Project description
48+
- `visibility` (optional string): 'private', 'internal', or 'public'
49+
- `initialize_with_readme` (optional boolean): Initialize with README
50+
- Returns: Created project details
51+
52+
5. `get_file_contents`
53+
- Get contents of a file or directory
54+
- Inputs:
55+
- `project_id` (string): Project ID or URL-encoded path
56+
- `file_path` (string): Path to file/directory
57+
- `ref` (optional string): Branch/tag/commit to get contents from
58+
- Returns: File/directory contents
59+
60+
6. `create_issue`
61+
- Create a new issue
62+
- Inputs:
63+
- `project_id` (string): Project ID or URL-encoded path
64+
- `title` (string): Issue title
65+
- `description` (optional string): Issue description
66+
- `assignee_ids` (optional number[]): User IDs to assign
67+
- `labels` (optional string[]): Labels to add
68+
- `milestone_id` (optional number): Milestone ID
69+
- Returns: Created issue details
70+
71+
7. `create_merge_request`
72+
- Create a new merge request
73+
- Inputs:
74+
- `project_id` (string): Project ID or URL-encoded path
75+
- `title` (string): MR title
76+
- `description` (optional string): MR description
77+
- `source_branch` (string): Branch containing changes
78+
- `target_branch` (string): Branch to merge into
79+
- `draft` (optional boolean): Create as draft MR
80+
- `allow_collaboration` (optional boolean): Allow commits from upstream members
81+
- Returns: Created merge request details
82+
83+
8. `fork_repository`
84+
- Fork a project
85+
- Inputs:
86+
- `project_id` (string): Project ID or URL-encoded path
87+
- `namespace` (optional string): Namespace to fork to
88+
- Returns: Forked project details
89+
90+
9. `create_branch`
91+
- Create a new branch
92+
- Inputs:
93+
- `project_id` (string): Project ID or URL-encoded path
94+
- `branch` (string): Name for new branch
95+
- `ref` (optional string): Source branch/commit for new branch
96+
- Returns: Created branch reference
97+
98+
## Setup
99+
100+
### Personal Access Token
101+
[Create a GitLab Personal Access Token](https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html) with appropriate permissions:
102+
- Go to User Settings > Access Tokens in GitLab
103+
- Select the required scopes:
104+
- `api` for full API access
105+
- `read_api` for read-only access
106+
- `read_repository` and `write_repository` for repository operations
107+
- Create the token and save it securely
108+
109+
### Usage with Claude Desktop
110+
Add the following to your `claude_desktop_config.json`:
111+
112+
```json
113+
{
114+
"gitlab": {
115+
"command": "npx",
116+
"args": ["-y", "@modelcontextprotocol/server-gitlab"],
117+
"env": {
118+
"GITLAB_PERSONAL_ACCESS_TOKEN": "<YOUR_TOKEN>",
119+
"GITLAB_API_URL": "https://gitlab.com/api/v4" // Optional, for self-hosted instances
120+
}
121+
}
122+
}
123+
```
124+
125+
## Environment Variables
126+
127+
- `GITLAB_PERSONAL_ACCESS_TOKEN`: Your GitLab personal access token (required)
128+
- `GITLAB_API_URL`: Base URL for GitLab API (optional, defaults to `https://gitlab.com/api/v4`)
129+
130+
## License
131+
132+
This MCP server is licensed under the MIT License. This means you are free to use, modify, and distribute the software, subject to the terms and conditions of the MIT License. For more details, please see the LICENSE file in the project repository.

0 commit comments

Comments
 (0)