efficient-gitlab-mcp-server 0.1.1

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 (4) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +306 -0
  3. package/dist/index.js +46881 -0
  4. package/package.json +60 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Ismar
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,306 @@
1
+ # Efficient GitLab MCP
2
+
3
+ [![CI](https://github.com/detailobsessed/efficient-gitlab-mcp/actions/workflows/ci.yml/badge.svg)](https://github.com/detailobsessed/efficient-gitlab-mcp/actions/workflows/ci.yml)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
+ [![Bun](https://img.shields.io/badge/Bun-1.0+-f9f1e1?logo=bun&logoColor=f9f1e1)](https://bun.sh/)
6
+ [![MCP](https://img.shields.io/badge/MCP-Compatible-8B5CF6?logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCI+PHBhdGggZmlsbD0id2hpdGUiIGQ9Ik0xMiAyQzYuNDggMiAyIDYuNDggMiAxMnM0LjQ4IDEwIDEwIDEwIDEwLTQuNDggMTAtMTBTMTcuNTIgMiAxMiAyem0wIDE4Yy00LjQxIDAtOC0zLjU5LTgtOHMzLjU5LTggOC04IDggMy41OSA4IDgtMy41OSA4LTggOHoiLz48L3N2Zz4=)](https://modelcontextprotocol.io/)
7
+ [![GitLab](https://img.shields.io/badge/GitLab-API-FC6D26?logo=gitlab&logoColor=white)](https://docs.gitlab.com/ee/api/)
8
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.0-3178C6?logo=typescript&logoColor=white)](https://www.typescriptlang.org/)
9
+ [![Biome](https://img.shields.io/badge/Biome-Strict-60A5FA?logo=biome&logoColor=white)](https://biomejs.dev/)
10
+
11
+ **Token-Efficient GitLab Server Management** — An enhanced fork of [zereight/gitlab-mcp](https://github.com/zereight/gitlab-mcp) with progressive disclosure pattern for dramatic token savings.
12
+
13
+ ## What's Different From Upstream?
14
+
15
+ This fork builds on the original GitLab MCP with substantial engineering improvements:
16
+
17
+ | Area | Upstream | This Fork |
18
+ |------|----------|-----------|
19
+ | **Runtime** | Node.js + npm | Bun (faster builds, native TypeScript) |
20
+ | **Tool Exposure** | 100+ tools directly | 5 meta-tools (progressive disclosure) |
21
+ | **Testing** | Basic | Comprehensive test suite |
22
+ | **Linting** | ESLint + Prettier | Strict Biome rules (`noExplicitAny`, `noNonNullAssertion`, cognitive complexity) |
23
+ | **CI/CD** | Basic | GitHub Actions (lint, build, test, semantic-release) |
24
+ | **Pre-commit** | None | prek hooks (typos, formatting, build verification) |
25
+
26
+ ### Key Improvements
27
+
28
+ - **Progressive Disclosure** — 5 meta-tools instead of 100+ individual tools (~90% token reduction)
29
+ - **MCP Protocol Logging** — Structured logs sent to LLM clients for agent observability
30
+ - **HTTP Transport Security** — DNS rebinding protection, configurable allowed hosts/origins
31
+ - **Comprehensive Test Suite** — 120+ tests covering registry, config, logger, MCP integration, and meta-tools
32
+ - **Strict Code Quality** — Zero `any` types, no non-null assertions, enforced cognitive complexity limits
33
+ - **Modern Tooling** — Bun for fast builds, Biome for linting, prek for pre-commit hooks
34
+ - **Automated Releases** — Semantic versioning with conventional commits
35
+
36
+ ---
37
+
38
+ ## How It Works
39
+
40
+ Instead of exposing 100+ individual tools, this server exposes **5 meta-tools**:
41
+
42
+ | Meta-Tool | Purpose |
43
+ |-----------|---------|
44
+ | `list_categories` | Discover available tool categories |
45
+ | `list_tools` | List tools in a specific category |
46
+ | `search_tools` | Search for tools by keyword |
47
+ | `get_tool_schema` | Get full parameter schema for a tool |
48
+ | `execute_tool` | Execute any GitLab tool by name |
49
+
50
+ ### Token Savings
51
+
52
+ | Approach | Tools Exposed | Approximate Token Cost |
53
+ |----------|---------------|------------------------|
54
+ | Traditional | 100+ tools | ~20,000+ tokens |
55
+ | Progressive Disclosure | 5 meta-tools | ~1,500 tokens |
56
+
57
+ **~90% reduction in tool definition tokens!**
58
+
59
+ ### Example Workflow
60
+
61
+ ```
62
+ 1. LLM calls list_categories() → sees "merge-requests" category
63
+ 2. LLM calls list_tools("merge-requests") → sees "create_merge_request", "merge_merge_request", etc.
64
+ 3. LLM calls get_tool_schema("create_merge_request") → sees required params
65
+ 4. LLM calls execute_tool("create_merge_request", {projectId: "123", title: "Fix bug", sourceBranch: "fix", targetBranch: "main"})
66
+ ```
67
+
68
+ ---
69
+
70
+ ## Available Operations
71
+
72
+ All GitLab operations organized by category:
73
+
74
+ | Category | Description |
75
+ |----------|-------------|
76
+ | repositories | Search, create, fork repos. Get files, push files, manage branches |
77
+ | merge-requests | Create, update, merge MRs. Discussions, threads, diffs |
78
+ | issues | Create, update, delete issues. Links, discussions |
79
+ | pipelines | List, create, retry, cancel pipelines. Job output |
80
+ | projects | Project details, members, labels |
81
+ | commits | List commits, get diffs |
82
+ | namespaces | List, get, verify namespaces |
83
+ | search | Global, project, and group search across code, issues, MRs, commits |
84
+ | milestones | Create, edit, delete milestones |
85
+ | wiki | Wiki page management |
86
+ | releases | Release management |
87
+ | users | User details |
88
+ | notes | Comments on issues and MRs |
89
+ | events | User and project activity |
90
+ | groups | Group projects and iterations |
91
+
92
+ ---
93
+
94
+ ## Quick Start
95
+
96
+ ### Prerequisites
97
+
98
+ - [Bun](https://bun.sh/) 1.0.0+
99
+ - A GitLab personal access token with the following scopes:
100
+ - `api` — Full API access (required for most operations)
101
+ - `read_api` — Read-only API access (if you only need read operations)
102
+ - `read_repository` — Read repository files
103
+ - `write_repository` — Push to repositories
104
+
105
+ ### Install
106
+
107
+ **Option 1: NPM (Recommended)**
108
+ ```bash
109
+ npx efficient-gitlab-mcp-server
110
+ # or with bun
111
+ bunx efficient-gitlab-mcp-server
112
+ ```
113
+
114
+ **Option 2: From Source**
115
+ ```bash
116
+ git clone https://github.com/detailobsessed/efficient-gitlab-mcp.git
117
+ cd efficient-gitlab-mcp
118
+ bun install
119
+ ```
120
+
121
+ ### Configure
122
+
123
+ ```bash
124
+ cp .env.example .env
125
+ # Edit .env and add your GITLAB_PERSONAL_ACCESS_TOKEN
126
+ ```
127
+
128
+ ### Run
129
+
130
+ ```bash
131
+ bun run build
132
+ bun start
133
+ ```
134
+
135
+ ### MCP Client Configuration
136
+
137
+ Add this to your MCP client configuration (e.g., `~/.config/claude/claude_desktop_config.json` for Claude Desktop, or your IDE's MCP settings):
138
+
139
+ ```json
140
+ {
141
+ "mcpServers": {
142
+ "gitlab": {
143
+ "command": "bun",
144
+ "args": ["run", "/path/to/efficient-gitlab-mcp/dist/index.js"],
145
+ "env": {
146
+ "GITLAB_PERSONAL_ACCESS_TOKEN": "glpat-xxxxxxxxxxxxxxxxxxxx",
147
+ "GITLAB_API_URL": "https://gitlab.com"
148
+ }
149
+ }
150
+ }
151
+ }
152
+ ```
153
+
154
+ For **self-hosted GitLab**, update `GITLAB_API_URL` to your instance URL.
155
+
156
+ ### Connect via CLI
157
+
158
+ ```bash
159
+ # stdio transport (default)
160
+ claude mcp add gitlab-agent -- bun /path/to/efficient-gitlab-mcp/dist/index.js
161
+
162
+ # HTTP transport
163
+ STREAMABLE_HTTP=true bun start
164
+ claude mcp add --transport http gitlab-agent http://localhost:3002/mcp
165
+ ```
166
+
167
+ ---
168
+
169
+ ## Features
170
+
171
+ ### MCP Protocol Logging
172
+
173
+ The server supports MCP protocol logging for agent observability. When connected, LLM clients can receive structured log messages showing what the server is doing:
174
+
175
+ - Tool execution logs
176
+ - GitLab API call details
177
+ - Error information with context
178
+
179
+ This helps agents understand server behavior and debug issues.
180
+
181
+ ### HTTP Transport Security
182
+
183
+ When using HTTP transport (`STREAMABLE_HTTP=true`), the server includes security features:
184
+
185
+ | Environment Variable | Default | Description |
186
+ |---------------------|---------|-------------|
187
+ | `HTTP_ALLOWED_HOSTS` | `localhost,127.0.0.1` | Comma-separated list of allowed Host headers |
188
+ | `HTTP_ALLOWED_ORIGINS` | (any) | Comma-separated list of allowed Origin headers |
189
+ | `HTTP_ENABLE_DNS_REBINDING_PROTECTION` | `true` | Enable DNS rebinding attack protection |
190
+
191
+ Example for production:
192
+
193
+ ```bash
194
+ HTTP_ALLOWED_HOSTS=api.example.com,localhost \
195
+ HTTP_ALLOWED_ORIGINS=https://app.example.com \
196
+ STREAMABLE_HTTP=true \
197
+ bun start
198
+ ```
199
+
200
+ ---
201
+
202
+ ## Development
203
+
204
+ ```bash
205
+ # Run tests
206
+ bun test
207
+
208
+ # Run tests with coverage
209
+ bun test --coverage
210
+
211
+ # Lint and format
212
+ bun run check
213
+
214
+ # Build
215
+ bun run build
216
+ ```
217
+
218
+ ---
219
+
220
+ ## Configuration
221
+
222
+ ### Core Settings
223
+
224
+ | Variable | Required | Default | Description |
225
+ |----------|----------|---------|-------------|
226
+ | `GITLAB_PERSONAL_ACCESS_TOKEN` | Yes* | - | GitLab personal access token |
227
+ | `GITLAB_API_URL` | No | `https://gitlab.com` | GitLab instance URL |
228
+ | `GITLAB_PROJECT_ID` | No | - | Default project ID |
229
+ | `GITLAB_ALLOWED_PROJECT_IDS` | No | - | Comma-separated allowed project IDs |
230
+ | `GITLAB_READ_ONLY_MODE` | No | `false` | Disable write operations |
231
+ | `GITLAB_IS_OLD` | No | `false` | For older GitLab instances |
232
+
233
+ ### Transport Settings
234
+
235
+ | Variable | Required | Default | Description |
236
+ |----------|----------|---------|-------------|
237
+ | `STREAMABLE_HTTP` | No | `false` | Enable HTTP transport |
238
+ | `SSE` | No | `false` | Enable SSE transport |
239
+ | `PORT` | No | `3002` | HTTP server port |
240
+ | `HOST` | No | `127.0.0.1` | HTTP server host |
241
+
242
+ ### Feature Flags
243
+
244
+ | Variable | Required | Default | Description |
245
+ |----------|----------|---------|-------------|
246
+ | `USE_GITLAB_WIKI` | No | `false` | Enable wiki tools |
247
+ | `USE_MILESTONE` | No | `false` | Enable milestone tools |
248
+ | `USE_PIPELINE` | No | `false` | Enable pipeline tools |
249
+
250
+ ### Logging & Security
251
+
252
+ | Variable | Required | Default | Description |
253
+ |----------|----------|---------|-------------|
254
+ | `LOG_LEVEL` | No | `info` | `debug`, `info`, `warn`, `error` |
255
+ | `LOG_FORMAT` | No | `pretty` | `json`, `pretty` |
256
+ | `HTTP_ALLOWED_HOSTS` | No | `localhost,127.0.0.1` | Allowed Host headers |
257
+ | `HTTP_ALLOWED_ORIGINS` | No | (any) | Allowed Origin headers |
258
+
259
+ ### Remote Authorization (Multi-tenant)
260
+
261
+ | Variable | Required | Default | Description |
262
+ |----------|----------|---------|-------------|
263
+ | `REMOTE_AUTHORIZATION` | No | `false` | Enable remote auth |
264
+ | `ENABLE_DYNAMIC_API_URL` | No | `false` | Allow dynamic GitLab URLs |
265
+ | `SESSION_TIMEOUT_SECONDS` | No | `3600` | Session timeout |
266
+ | `MAX_SESSIONS` | No | `1000` | Maximum concurrent sessions |
267
+ | `MAX_REQUESTS_PER_MINUTE` | No | `60` | Rate limit per session |
268
+
269
+ *Or use OAuth authentication - see [OAuth Setup Guide](./docs/oauth-setup.md)
270
+
271
+ ---
272
+
273
+ ## Security
274
+
275
+ - **Never commit tokens** — Use `.env` files (gitignored)
276
+ - **Rotate tokens** — Regenerate periodically
277
+ - **Least privilege** — Only grant necessary API scopes
278
+ - **Audit logs** — Monitor API access
279
+
280
+ ---
281
+
282
+ ## Acknowledgments
283
+
284
+ This project is a fork of [zereight/gitlab-mcp](https://github.com/zereight/gitlab-mcp). Thanks to the original author for the comprehensive GitLab API implementation.
285
+
286
+ ---
287
+
288
+ ## Resources
289
+
290
+ - **MCP Protocol**: [modelcontextprotocol.io](https://modelcontextprotocol.io/)
291
+ - **GitLab API**: [docs.gitlab.com/ee/api](https://docs.gitlab.com/ee/api/)
292
+ - **Bun**: [bun.sh](https://bun.sh/)
293
+
294
+ ---
295
+
296
+ ## License
297
+
298
+ MIT License — See [LICENSE](LICENSE) for details.
299
+
300
+ ---
301
+
302
+ <p align="center">
303
+ <strong>Efficient GitLab MCP</strong><br>
304
+ AI-Powered GitLab Management with Token Efficiency<br>
305
+ <sub>Built with Bun and the Model Context Protocol</sub>
306
+ </p>