1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
# GitLab CLI MCP Server
This MCP server provides integration with GitLab through the GitLab CLI (`glab`) tool. It allows LLM agents to interact with GitLab repositories and resources using the GitLab API.
## Features
- Check if the GitLab CLI is available and accessible
- Find GitLab projects by name and retrieve their IDs
- More features to be added in the future
## Prerequisites
- Python 3.11 or higher
- GitLab CLI (`glab`) installed and accessible in the system PATH
- GitLab account with proper authentication set up via `glab auth login`
## Installation
```bash
# Clone the repository
git clone https://github.com/yourusername/dawids-mcp-servers.git
cd dawids-mcp-servers
# Install the server
cd servers/gitlab_glab
uv pip install -e .
```
## Usage
### Running the server with stdio transport (for local development)
```bash
mcp-gitlab-glab --transport stdio
```
### Running the server with remote transport
```bash
mcp-gitlab-glab --transport remote --host 0.0.0.0 --port 8080
```
## Available Tools
### check_glab_availability
Checks if the GitLab CLI tool is installed and accessible.
```python
result = use_mcp_tool(
server_name="gitlab_glab",
tool_name="check_glab_availability",
arguments={
"working_directory": "/path/to/current/directory"
}
)
```
### find_project
Finds GitLab projects by name and returns their details.
```python
result = use_mcp_tool(
server_name="gitlab_glab",
tool_name="find_project",
arguments={
"project_name": "my-project",
"working_directory": "/path/to/current/directory"
}
)
```
The function returns a list of matching projects, each containing the following fields:
- `id`: The project ID
- `name`: The project name
- `path_with_namespace`: The project path with namespace
- `web_url`: The project web URL
- `description`: The project description
### create_issue
Creates a new GitLab issue and returns its URL.
```python
result = use_mcp_tool(
server_name="gitlab_glab",
tool_name="create_issue",
arguments={
"title": "Issue title",
"description": "Issue description",
"working_directory": "/path/to/current/directory",
# Optional parameters
"labels": ["bug", "critical"], # List of labels
"assignee": ["username1", "username2"], # List of usernames
"milestone": "v1.0", # Milestone title or ID
"epic_id": 123, # Epic ID
"project": "group/project" # Project path with namespace
}
)
```
The function returns a dictionary containing:
- `url`: The URL of the created issue
- `error`: Error message if the operation failed
## Working Directory Context
All tools require a `working_directory` parameter that specifies the directory context in which the GitLab CLI commands should be executed. This ensures that commands are run in the same directory as the agent, maintaining proper context for repository operations.
The working directory should be the absolute path to the directory where you want the GitLab CLI commands to be executed. For example, if you're working with a GitLab repository cloned to `/home/user/projects/my-repo`, you would pass that path as the `working_directory` parameter.
## Development
### Running tests
```bash
cd servers/gitlab_glab
uv run pytest
```
### Running tests with coverage
```bash
cd servers/gitlab_glab
uv run pytest --cov=mcp_server_gitlab_glab
```
## License
This project is licensed under the MIT License - see the LICENSE file for details.
|