@zereight/mcp-gitlab 2.0.33 → 2.0.35
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 +233 -90
- package/build/gitlab-client-pool.js +114 -6
- package/build/index.js +2244 -98
- package/build/oauth-proxy.js +257 -0
- package/build/oauth.js +11 -6
- package/build/schemas.js +458 -199
- package/build/test/mcp-oauth-tests.js +443 -0
- package/build/test/multi-server-test.js +16 -8
- package/build/test/no-proxy-integration-test.js +183 -0
- package/build/test/no-proxy-test.js +138 -0
- package/build/test/remote-auth-simple-test.js +12 -1
- package/build/test/test-geteffectiveprojectid.js +245 -0
- package/build/test/test-mr-file-diffs.js +251 -0
- package/build/test/test-search-code.js +272 -0
- package/build/test/test-toolset-filtering.js +22 -17
- package/build/test/test-upload-markdown.js +148 -0
- package/build/test/utils/mock-gitlab-server.js +267 -163
- package/build/test/utils/server-launcher.js +45 -41
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -34,7 +34,7 @@ For detailed OAuth2 setup instructions, see [OAuth Setup Guide](./docs/oauth-set
|
|
|
34
34
|
|
|
35
35
|
Quick setup - first create a GitLab OAuth application:
|
|
36
36
|
|
|
37
|
-
1. Go to your GitLab instance: `
|
|
37
|
+
1. Go to your GitLab instance: `Admin area` → `Applications`
|
|
38
38
|
2. Create a new application with:
|
|
39
39
|
- **Name**: `GitLab MCP Server` (or any name you prefer)
|
|
40
40
|
- **Redirect URI**: `http://127.0.0.1:8888/callback`
|
|
@@ -336,7 +336,7 @@ docker run -i --rm \
|
|
|
336
336
|
- `GITLAB_OAUTH_REDIRECT_URI`: The OAuth callback URL. Default: `http://127.0.0.1:8888/callback`
|
|
337
337
|
- `GITLAB_OAUTH_TOKEN_PATH`: Custom path to store the OAuth token. Default: `~/.gitlab-mcp-token.json`
|
|
338
338
|
- `REMOTE_AUTHORIZATION`: When set to 'true', enables remote per-session authorization via HTTP headers. In this mode:
|
|
339
|
-
- The server accepts GitLab PAT tokens from HTTP headers (`Authorization: Bearer <token>` or `
|
|
339
|
+
- The server accepts GitLab PAT tokens from HTTP headers (`Authorization: Bearer <token>`, `Private-Token: <token>` or `Job-Token: <token>`) on a per-session basis
|
|
340
340
|
- `GITLAB_PERSONAL_ACCESS_TOKEN` environment variable is **not required** and ignored
|
|
341
341
|
- Only works with **Streamable HTTP transport** (`STREAMABLE_HTTP=true`) because session management was already handled by the transport layer
|
|
342
342
|
- **SSE transport is disabled** - attempting to use SSE with remote authorization will cause the server to exit with an error
|
|
@@ -357,17 +357,20 @@ docker run -i --rm \
|
|
|
357
357
|
- `USE_MILESTONE`: Legacy flag. Milestone features are now enabled by default. When set to 'true', ensures milestone-related tools are included even if the `milestones` toolset is not explicitly listed in `GITLAB_TOOLSETS`.
|
|
358
358
|
- `USE_PIPELINE`: Legacy flag. Pipeline features are now enabled by default. When set to 'true', ensures pipeline-related tools are included even if the `pipelines` toolset is not explicitly listed in `GITLAB_TOOLSETS`.
|
|
359
359
|
- `GITLAB_TOOLSETS`: Comma-separated list of toolset IDs to enable. When empty or unset, default toolsets are used. Set to `"all"` to enable every toolset. Available toolsets (default toolsets marked with `*`):
|
|
360
|
-
- `merge_requests`\* — MR operations, notes, discussions, draft notes, threads (
|
|
360
|
+
- `merge_requests`\* — MR operations, notes, discussions, draft notes, threads, versions, file diffs, conflicts (34 tools)
|
|
361
361
|
- `issues`\* — Issue CRUD, notes, links, discussions (14 tools)
|
|
362
362
|
- `repositories`\* — Search, create, file contents, push, fork, tree (7 tools)
|
|
363
363
|
- `branches`\* — Branch creation, commits, diffs (4 tools)
|
|
364
364
|
- `projects`\* — Project/namespace info, group projects, iterations (8 tools)
|
|
365
365
|
- `labels`\* — Label CRUD (5 tools)
|
|
366
|
-
- `pipelines`\* — Pipeline and
|
|
366
|
+
- `pipelines`\* — Pipeline, job, deployment, environment, and artifact operations (19 tools)
|
|
367
367
|
- `milestones`\* — Milestone CRUD, issues, MRs, burndown (9 tools)
|
|
368
|
-
- `wiki`\* — Wiki page CRUD (
|
|
368
|
+
- `wiki`\* — Wiki page CRUD for projects and groups (10 tools)
|
|
369
369
|
- `releases`\* — Release CRUD, evidence, asset download (7 tools)
|
|
370
370
|
- `users`\* — User info, events, markdown upload, attachments (5 tools)
|
|
371
|
+
- `workitems` — Work item CRUD via GraphQL, type conversion, statuses, custom fields, notes, timeline events (12 tools, opt-in)
|
|
372
|
+
- `webhooks` — Webhook listing and event inspection (3 tools, opt-in)
|
|
373
|
+
- `search` — Code search across projects, groups, or globally (3 tools, requires advanced search or exact code search enabled)
|
|
371
374
|
|
|
372
375
|
Note: `execute_graphql` is not in any toolset and must be added individually via `GITLAB_TOOLS` if needed.
|
|
373
376
|
Exposing arbitrary GraphQL would allow bypassing toolset boundaries (e.g. querying data that the user intentionally disabled via toolsets like wiki or pipelines), which is a security and permission-containment concern. Keeping `execute_graphql` out of all toolsets and requiring explicit opt-in via `GITLAB_TOOLS=execute_graphql` is intentional, to align with that principle rather than for backward compatibility.
|
|
@@ -400,6 +403,7 @@ docker run -i --rm \
|
|
|
400
403
|
- `SSE`: When set to 'true', enables the Server-Sent Events transport.
|
|
401
404
|
- `STREAMABLE_HTTP`: When set to 'true', enables the Streamable HTTP transport. If both **SSE** and **STREAMABLE_HTTP** are set to 'true', the server will prioritize Streamable HTTP over SSE transport.
|
|
402
405
|
- `GITLAB_COMMIT_FILES_PER_PAGE`: The number of files per page that GitLab returns for commit diffs. This value should match the server-side GitLab setting. Adjust this if your GitLab instance uses a custom per-page value for commit diffs.
|
|
406
|
+
- `GITLAB_REPO_FILE_ENCODING`: Encoding for repository file create/update and related commit payloads sent to the GitLab API. Use `text` (default) or `base64`. Equivalent CLI: `--repo-file-encoding=text|base64`.
|
|
403
407
|
|
|
404
408
|
#### Performance & Security Configuration
|
|
405
409
|
|
|
@@ -407,6 +411,16 @@ docker run -i --rm \
|
|
|
407
411
|
- `MAX_SESSIONS`: Maximum number of concurrent sessions allowed. Default: `1000`. Valid range: 1-10000. When limit is reached, new connections are rejected with HTTP 503.
|
|
408
412
|
- `MAX_REQUESTS_PER_MINUTE`: Rate limit per session in requests per minute. Default: `60`. Valid range: 1-1000. Exceeded requests return HTTP 429.
|
|
409
413
|
- `PORT`: Server port. Default: `3002`. Valid range: 1-65535.
|
|
414
|
+
- `HTTP_PROXY`: HTTP proxy server URL for outgoing requests. Example: `http://proxy.example.com:8080`. Supports HTTP/HTTPS and SOCKS proxies (URLs starting with `socks://` or `socks5://`). CLI arg: `--http-proxy`
|
|
415
|
+
- `HTTPS_PROXY`: HTTPS proxy server URL for outgoing requests. Example: `https://proxy.example.com:8080`. Supports HTTP/HTTPS and SOCKS proxies. CLI arg: `--https-proxy`
|
|
416
|
+
- `NO_PROXY`: Comma-separated list of hosts that should bypass the proxy. Supports:
|
|
417
|
+
- Exact hostname matches (e.g., `localhost`, `gitlab.internal.com`)
|
|
418
|
+
- Domain suffix matches (e.g., `.internal.com` matches any subdomain)
|
|
419
|
+
- IP addresses (e.g., `127.0.0.1`, `192.168.1.1`)
|
|
420
|
+
- Port-specific matches (e.g., `example.com:443`)
|
|
421
|
+
- Wildcard `*` to bypass proxy for all hosts
|
|
422
|
+
- Example: `NO_PROXY=localhost,127.0.0.1,.internal.com`
|
|
423
|
+
- CLI arg: `--no-proxy`
|
|
410
424
|
|
|
411
425
|
#### Monitoring Endpoints
|
|
412
426
|
|
|
@@ -483,6 +497,92 @@ The token is stored per session (identified by `mcp-session-id` header) and reus
|
|
|
483
497
|
- **Rate limiting:** Each session is limited to `MAX_REQUESTS_PER_MINUTE` requests per minute (default 60)
|
|
484
498
|
- **Capacity limit:** Server accepts up to `MAX_SESSIONS` concurrent sessions (default 1000)
|
|
485
499
|
|
|
500
|
+
### MCP OAuth Setup (Claude.ai Native OAuth)
|
|
501
|
+
|
|
502
|
+
When using `GITLAB_MCP_OAUTH=true`, the server acts as an OAuth proxy to your GitLab
|
|
503
|
+
instance. Claude.ai (and any MCP-spec-compliant client) handles the entire browser
|
|
504
|
+
authentication flow automatically — no manual Personal Access Token management needed.
|
|
505
|
+
|
|
506
|
+
**Prerequisites:**
|
|
507
|
+
|
|
508
|
+
A **pre-registered GitLab OAuth application** is required. GitLab restricts dynamically
|
|
509
|
+
registered (unverified) applications to the `mcp` scope, which is insufficient for API
|
|
510
|
+
calls (need `api` or `read_api`).
|
|
511
|
+
|
|
512
|
+
1. Go to your GitLab instance → **Admin Area > Applications** (instance-wide) or **User Settings > Applications** (personal)
|
|
513
|
+
2. Create a new application with:
|
|
514
|
+
- **Confidential**: unchecked
|
|
515
|
+
- **Scopes**: `api`, `read_api`, `read_user`
|
|
516
|
+
3. Save and copy the **Application ID** — this is your `GITLAB_OAUTH_APP_ID`
|
|
517
|
+
|
|
518
|
+
**How it works:**
|
|
519
|
+
|
|
520
|
+
1. User adds your MCP server URL in Claude.ai
|
|
521
|
+
2. Claude.ai discovers OAuth endpoints via `/.well-known/oauth-authorization-server`
|
|
522
|
+
3. Claude.ai registers itself via Dynamic Client Registration (`POST /register`) — handled locally by the MCP server (each client gets a virtual client ID)
|
|
523
|
+
4. Claude.ai redirects the user's browser to GitLab's login page using the pre-registered OAuth application
|
|
524
|
+
5. User authenticates; GitLab redirects back to `https://claude.ai/api/mcp/auth_callback`
|
|
525
|
+
6. Claude.ai sends `Authorization: Bearer <token>` on every MCP request
|
|
526
|
+
7. Server validates the token with GitLab and stores it per session
|
|
527
|
+
|
|
528
|
+
**Server setup:**
|
|
529
|
+
|
|
530
|
+
```bash
|
|
531
|
+
docker run -d \
|
|
532
|
+
-e STREAMABLE_HTTP=true \
|
|
533
|
+
-e GITLAB_MCP_OAUTH=true \
|
|
534
|
+
-e GITLAB_OAUTH_APP_ID="your-gitlab-oauth-app-client-id" \
|
|
535
|
+
-e GITLAB_API_URL="https://gitlab.example.com/api/v4" \
|
|
536
|
+
-e MCP_SERVER_URL="https://your-mcp-server.example.com" \
|
|
537
|
+
-p 3002:3002 \
|
|
538
|
+
zereight050/gitlab-mcp
|
|
539
|
+
```
|
|
540
|
+
|
|
541
|
+
For local development (HTTP allowed):
|
|
542
|
+
|
|
543
|
+
```bash
|
|
544
|
+
MCP_DANGEROUSLY_ALLOW_INSECURE_ISSUER_URL=true \
|
|
545
|
+
STREAMABLE_HTTP=true \
|
|
546
|
+
GITLAB_MCP_OAUTH=true \
|
|
547
|
+
GITLAB_OAUTH_APP_ID=your-gitlab-oauth-app-client-id \
|
|
548
|
+
MCP_SERVER_URL=http://localhost:3002 \
|
|
549
|
+
GITLAB_API_URL=https://gitlab.com/api/v4 \
|
|
550
|
+
node build/index.js
|
|
551
|
+
```
|
|
552
|
+
|
|
553
|
+
**Claude.ai configuration:**
|
|
554
|
+
|
|
555
|
+
```json
|
|
556
|
+
{
|
|
557
|
+
"mcpServers": {
|
|
558
|
+
"GitLab": {
|
|
559
|
+
"url": "https://your-mcp-server.example.com/mcp"
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
```
|
|
564
|
+
|
|
565
|
+
No `headers` field is needed — Claude.ai obtains the token via OAuth automatically.
|
|
566
|
+
|
|
567
|
+
**Environment variables:**
|
|
568
|
+
|
|
569
|
+
| Variable | Required | Description |
|
|
570
|
+
|---|---|---|
|
|
571
|
+
| `GITLAB_MCP_OAUTH` | Yes | Set to `true` to enable |
|
|
572
|
+
| `GITLAB_OAUTH_APP_ID` | Yes | Client ID of the pre-registered GitLab OAuth application |
|
|
573
|
+
| `MCP_SERVER_URL` | Yes | Public HTTPS URL of your MCP server |
|
|
574
|
+
| `GITLAB_API_URL` | Yes | Your GitLab instance API URL (e.g. `https://gitlab.com/api/v4`) |
|
|
575
|
+
| `STREAMABLE_HTTP` | Yes | Must be `true` (SSE is not supported) |
|
|
576
|
+
| `MCP_DANGEROUSLY_ALLOW_INSECURE_ISSUER_URL` | No | Set `true` for local HTTP dev only |
|
|
577
|
+
|
|
578
|
+
**Important Notes:**
|
|
579
|
+
|
|
580
|
+
- MCP OAuth **only works with Streamable HTTP transport** (`SSE=true` is incompatible)
|
|
581
|
+
- Each user session stores its own OAuth token — sessions are fully isolated
|
|
582
|
+
- Session timeout, rate limiting, and capacity limits apply identically to the
|
|
583
|
+
`REMOTE_AUTHORIZATION` mode (`SESSION_TIMEOUT_SECONDS`, `MAX_REQUESTS_PER_MINUTE`,
|
|
584
|
+
`MAX_SESSIONS`)
|
|
585
|
+
|
|
486
586
|
## Tools 🛠️
|
|
487
587
|
|
|
488
588
|
<details>
|
|
@@ -503,91 +603,134 @@ The token is stored per session (identified by `mcp-session-id` header) and reus
|
|
|
503
603
|
11. `get_merge_request` - Get details of a merge request with compact deployment summary, behind-count, commit addition summary, and approval summary (Either mergeRequestIid or branchName must be provided)
|
|
504
604
|
12. `get_merge_request_diffs` - Get the changes/diffs of a merge request (Either mergeRequestIid or branchName must be provided)
|
|
505
605
|
13. `list_merge_request_diffs` - List merge request diffs with pagination support (Either mergeRequestIid or branchName must be provided)
|
|
506
|
-
14. `
|
|
507
|
-
15. `
|
|
508
|
-
16. `
|
|
509
|
-
17. `
|
|
510
|
-
18. `
|
|
511
|
-
19. `
|
|
512
|
-
20. `
|
|
513
|
-
21. `
|
|
514
|
-
22. `
|
|
515
|
-
23. `
|
|
516
|
-
24. `
|
|
517
|
-
25. `
|
|
518
|
-
26. `
|
|
519
|
-
27. `
|
|
520
|
-
28. `
|
|
521
|
-
29. `
|
|
522
|
-
30. `
|
|
523
|
-
31. `
|
|
524
|
-
32. `
|
|
525
|
-
33. `
|
|
526
|
-
34. `
|
|
527
|
-
35. `
|
|
528
|
-
36. `
|
|
529
|
-
37. `
|
|
530
|
-
38. `
|
|
531
|
-
39. `
|
|
532
|
-
40. `
|
|
533
|
-
41. `
|
|
534
|
-
42. `
|
|
535
|
-
43. `
|
|
536
|
-
44. `
|
|
537
|
-
45. `
|
|
538
|
-
46. `
|
|
539
|
-
47. `
|
|
540
|
-
48. `
|
|
541
|
-
49. `
|
|
542
|
-
50. `
|
|
543
|
-
51. `
|
|
544
|
-
52. `
|
|
545
|
-
53. `
|
|
546
|
-
54. `
|
|
547
|
-
55. `
|
|
548
|
-
56. `
|
|
549
|
-
57. `
|
|
550
|
-
58. `
|
|
551
|
-
59. `
|
|
552
|
-
60. `
|
|
553
|
-
61. `
|
|
554
|
-
62. `
|
|
555
|
-
63. `
|
|
556
|
-
64. `
|
|
557
|
-
65. `
|
|
558
|
-
66. `
|
|
559
|
-
67. `
|
|
560
|
-
68. `
|
|
561
|
-
69. `
|
|
562
|
-
70. `
|
|
563
|
-
71. `
|
|
564
|
-
72. `
|
|
565
|
-
73. `
|
|
566
|
-
74. `
|
|
567
|
-
75. `
|
|
568
|
-
76. `
|
|
569
|
-
77. `
|
|
570
|
-
78. `
|
|
571
|
-
79. `
|
|
572
|
-
80. `
|
|
573
|
-
81. `
|
|
574
|
-
82. `
|
|
575
|
-
83. `
|
|
576
|
-
84. `
|
|
577
|
-
85. `
|
|
578
|
-
86. `
|
|
579
|
-
87. `
|
|
580
|
-
88. `
|
|
581
|
-
89. `
|
|
582
|
-
90. `
|
|
583
|
-
91. `
|
|
584
|
-
92. `
|
|
585
|
-
93. `
|
|
586
|
-
94. `
|
|
587
|
-
95. `
|
|
588
|
-
96. `
|
|
589
|
-
97. `
|
|
590
|
-
98. `
|
|
606
|
+
14. `get_merge_request_conflicts` - Get the conflicts of a merge request in a GitLab project
|
|
607
|
+
15. `list_merge_request_changed_files` - STEP 1 of code review workflow. Returns ONLY the list of changed file paths in a merge request — WITHOUT diff content. Call this first to get file paths, then call get_merge_request_file_diff with multiple files in a single batched call (recommended 3-5 files per call). Supports excluded_file_patterns filtering using regex. (Either mergeRequestIid or branchName must be provided)
|
|
608
|
+
16. `get_merge_request_file_diff` - STEP 2 of code review workflow. Get diffs for one or more files from a merge request. Call list_merge_request_changed_files first, then pass them as an array to fetch diffs efficiently. Batching multiple files (recommended 3-5) is supported. (Either mergeRequestIid or branchName must be provided)
|
|
609
|
+
17. `list_merge_request_versions` - List all versions of a merge request
|
|
610
|
+
18. `get_merge_request_version` - Get a specific version of a merge request
|
|
611
|
+
19. `get_branch_diffs` - Get the changes/diffs between two branches or commits in a GitLab project
|
|
612
|
+
20. `update_merge_request` - Update a merge request (Either mergeRequestIid or branchName must be provided)
|
|
613
|
+
21. `create_note` - Create a new note (comment) to an issue or merge request
|
|
614
|
+
22. `create_merge_request_thread` - Create a new thread on a merge request
|
|
615
|
+
23. `mr_discussions` - List discussion items for a merge request
|
|
616
|
+
24. `resolve_merge_request_thread` - Resolve a thread on a merge request
|
|
617
|
+
25. `update_merge_request_note` - Modify an existing merge request thread note
|
|
618
|
+
26. `create_merge_request_note` - Add a new note to an existing merge request thread
|
|
619
|
+
27. `delete_merge_request_discussion_note` - Delete a discussion note on a merge request
|
|
620
|
+
28. `update_merge_request_discussion_note` - Update a discussion note on a merge request
|
|
621
|
+
29. `create_merge_request_discussion_note` - Add a new discussion note to an existing merge request thread
|
|
622
|
+
30. `delete_merge_request_note` - Delete an existing merge request note
|
|
623
|
+
31. `get_merge_request_note` - Get a specific note for a merge request
|
|
624
|
+
32. `get_merge_request_notes` - List notes for a merge request
|
|
625
|
+
33. `get_draft_note` - Get a single draft note from a merge request
|
|
626
|
+
34. `list_draft_notes` - List draft notes for a merge request
|
|
627
|
+
35. `create_draft_note` - Create a draft note for a merge request
|
|
628
|
+
36. `update_draft_note` - Update an existing draft note
|
|
629
|
+
37. `delete_draft_note` - Delete a draft note
|
|
630
|
+
38. `publish_draft_note` - Publish a single draft note
|
|
631
|
+
39. `bulk_publish_draft_notes` - Publish all draft notes for a merge request
|
|
632
|
+
40. `list_merge_requests` - List merge requests globally or in a specific GitLab project with filtering options (project_id is now optional)
|
|
633
|
+
41. `approve_merge_request` - Approve a merge request (requires appropriate permissions)
|
|
634
|
+
42. `unapprove_merge_request` - Unapprove a previously approved merge request
|
|
635
|
+
43. `get_merge_request_approval_state` - Get merge request approval details including approvers (uses `approval_state` when available, otherwise falls back to `approvals`)
|
|
636
|
+
44. `update_issue_note` - Modify an existing issue thread note
|
|
637
|
+
45. `create_issue_note` - Add a new note to an existing issue thread
|
|
638
|
+
46. `list_issues` - List issues (default: created by current user only; use scope='all' for all accessible issues)
|
|
639
|
+
47. `my_issues` - List issues assigned to the authenticated user (defaults to open issues)
|
|
640
|
+
48. `get_issue` - Get details of a specific issue in a GitLab project
|
|
641
|
+
49. `update_issue` - Update an issue in a GitLab project
|
|
642
|
+
50. `delete_issue` - Delete an issue from a GitLab project
|
|
643
|
+
51. `list_issue_links` - List all issue links for a specific issue
|
|
644
|
+
52. `list_issue_discussions` - List discussions for an issue in a GitLab project
|
|
645
|
+
53. `get_issue_link` - Get a specific issue link
|
|
646
|
+
54. `create_issue_link` - Create an issue link between two issues
|
|
647
|
+
55. `delete_issue_link` - Delete an issue link
|
|
648
|
+
56. `list_namespaces` - List all namespaces available to the current user
|
|
649
|
+
57. `get_namespace` - Get details of a namespace by ID or path
|
|
650
|
+
58. `verify_namespace` - Verify if a namespace path exists
|
|
651
|
+
59. `get_project` - Get details of a specific project
|
|
652
|
+
60. `list_projects` - List projects accessible by the current user
|
|
653
|
+
61. `list_project_members` - List members of a GitLab project
|
|
654
|
+
62. `list_group_projects` - List projects in a GitLab group with filtering options
|
|
655
|
+
63. `list_group_iterations` - List group iterations with filtering options
|
|
656
|
+
64. `list_labels` - List labels for a project
|
|
657
|
+
65. `get_label` - Get a single label from a project
|
|
658
|
+
66. `create_label` - Create a new label in a project
|
|
659
|
+
67. `update_label` - Update an existing label in a project
|
|
660
|
+
68. `delete_label` - Delete a label from a project
|
|
661
|
+
69. `list_pipelines` - List pipelines in a GitLab project with filtering options
|
|
662
|
+
70. `get_pipeline` - Get details of a specific pipeline in a GitLab project
|
|
663
|
+
71. `list_pipeline_jobs` - List all jobs in a specific pipeline
|
|
664
|
+
72. `list_pipeline_trigger_jobs` - List all trigger jobs (bridges) in a specific pipeline that trigger downstream pipelines
|
|
665
|
+
73. `get_pipeline_job` - Get details of a GitLab pipeline job number
|
|
666
|
+
74. `get_pipeline_job_output` - Get the output/trace of a GitLab pipeline job with optional pagination to limit context window usage
|
|
667
|
+
75. `create_pipeline` - Create a new pipeline for a branch or tag
|
|
668
|
+
76. `retry_pipeline` - Retry a failed or canceled pipeline
|
|
669
|
+
77. `cancel_pipeline` - Cancel a running pipeline
|
|
670
|
+
78. `play_pipeline_job` - Run a manual pipeline job
|
|
671
|
+
79. `retry_pipeline_job` - Retry a failed or canceled pipeline job
|
|
672
|
+
80. `cancel_pipeline_job` - Cancel a running pipeline job
|
|
673
|
+
81. `list_deployments` - List deployments in a GitLab project with filtering options
|
|
674
|
+
82. `get_deployment` - Get details of a specific deployment in a GitLab project
|
|
675
|
+
83. `list_environments` - List environments in a GitLab project
|
|
676
|
+
84. `get_environment` - Get details of a specific environment in a GitLab project
|
|
677
|
+
85. `list_job_artifacts` - List artifact files in a job's artifacts archive. Returns file names, paths, types, and sizes
|
|
678
|
+
86. `download_job_artifacts` - Download the entire artifact archive (zip) for a job to a local path. Returns the saved file path
|
|
679
|
+
87. `get_job_artifact_file` - Get the content of a single file from a job's artifacts by its path within the archive
|
|
680
|
+
88. `list_milestones` - List milestones in a GitLab project with filtering options
|
|
681
|
+
89. `get_milestone` - Get details of a specific milestone
|
|
682
|
+
90. `create_milestone` - Create a new milestone in a GitLab project
|
|
683
|
+
91. `edit_milestone` - Edit an existing milestone in a GitLab project
|
|
684
|
+
92. `delete_milestone` - Delete a milestone from a GitLab project
|
|
685
|
+
93. `get_milestone_issue` - Get issues associated with a specific milestone
|
|
686
|
+
94. `get_milestone_merge_requests` - Get merge requests associated with a specific milestone
|
|
687
|
+
95. `promote_milestone` - Promote a milestone to the next stage
|
|
688
|
+
96. `get_milestone_burndown_events` - Get burndown events for a specific milestone
|
|
689
|
+
97. `list_wiki_pages` - List wiki pages in a GitLab project
|
|
690
|
+
98. `get_wiki_page` - Get details of a specific wiki page
|
|
691
|
+
99. `create_wiki_page` - Create a new wiki page in a GitLab project
|
|
692
|
+
100. `update_wiki_page` - Update an existing wiki page in a GitLab project
|
|
693
|
+
101. `delete_wiki_page` - Delete a wiki page from a GitLab project
|
|
694
|
+
102. `list_group_wiki_pages` - List wiki pages in a GitLab group
|
|
695
|
+
103. `get_group_wiki_page` - Get details of a specific group wiki page
|
|
696
|
+
104. `create_group_wiki_page` - Create a new wiki page in a GitLab group
|
|
697
|
+
105. `update_group_wiki_page` - Update an existing wiki page in a GitLab group
|
|
698
|
+
106. `delete_group_wiki_page` - Delete a wiki page from a GitLab group
|
|
699
|
+
107. `get_repository_tree` - Get the repository tree for a GitLab project (list files and directories)
|
|
700
|
+
108. `list_commits` - List repository commits with filtering options
|
|
701
|
+
109. `get_commit` - Get details of a specific commit
|
|
702
|
+
110. `get_commit_diff` - Get changes/diffs of a specific commit
|
|
703
|
+
111. `list_releases` - List all releases for a project
|
|
704
|
+
112. `get_release` - Get a release by tag name
|
|
705
|
+
113. `create_release` - Create a new release in a GitLab project
|
|
706
|
+
114. `update_release` - Update an existing release in a GitLab project
|
|
707
|
+
115. `delete_release` - Delete a release from a GitLab project (does not delete the associated tag)
|
|
708
|
+
116. `create_release_evidence` - Create release evidence for an existing release (GitLab Premium/Ultimate only)
|
|
709
|
+
117. `download_release_asset` - Download a release asset file by direct asset path
|
|
710
|
+
118. `get_users` - Get GitLab user details by usernames
|
|
711
|
+
119. `list_events` - List all events for the currently authenticated user
|
|
712
|
+
120. `get_project_events` - List all visible events for a specified project
|
|
713
|
+
121. `upload_markdown` - Upload a file to a GitLab project for use in markdown content
|
|
714
|
+
122. `download_attachment` - Download an uploaded file from a GitLab project by secret and filename
|
|
715
|
+
123. `get_work_item` - Get a single work item with full details including status, hierarchy (parent/children), type, labels, assignees, and all widgets
|
|
716
|
+
124. `list_work_items` - List work items in a project with filters (type, state, search, assignees, labels). Returns items with status and hierarchy info
|
|
717
|
+
125. `create_work_item` - Create a new work item (issue, task, incident, test_case, epic, key_result, objective, requirement, ticket). Supports setting title, description, labels, assignees, weight, parent, health status, start/due dates, milestone, and confidentiality
|
|
718
|
+
126. `update_work_item` - Update a work item. Can modify title, description, labels, assignees, weight, state, status, parent hierarchy, children, health status, start/due dates, milestone, confidentiality, linked items, and custom fields
|
|
719
|
+
127. `convert_work_item_type` - Convert a work item to a different type (e.g. issue to task, task to incident)
|
|
720
|
+
128. `list_work_item_statuses` - List available statuses for a work item type in a project. Requires GitLab Premium/Ultimate with configurable statuses
|
|
721
|
+
129. `list_custom_field_definitions` - List available custom field definitions for a work item type in a project. Returns field names, types, and IDs needed for setting custom fields via update_work_item
|
|
722
|
+
130. `move_work_item` - Move a work item (issue, task, etc.) to a different project. Uses GitLab GraphQL issueMove mutation
|
|
723
|
+
131. `list_work_item_notes` - List notes and discussions on a work item. Returns threaded discussions with author, body, timestamps, and system/internal flags
|
|
724
|
+
132. `create_work_item_note` - Add a note/comment to a work item. Supports Markdown, internal notes, and threaded replies
|
|
725
|
+
133. `get_timeline_events` - List timeline events for an incident. Returns chronological events with notes, timestamps, and tags
|
|
726
|
+
134. `create_timeline_event` - Create a timeline event on an incident. Supports tags: 'Start time', 'End time', 'Impact detected', 'Response initiated', 'Impact mitigated', 'Cause identified'
|
|
727
|
+
135. `list_webhooks` - List all configured webhooks for a GitLab project or group. Provide either project_id or group_id
|
|
728
|
+
136. `list_webhook_events` - List recent webhook events (past 7 days) for a project or group webhook. Use summary mode for overview, then get_webhook_event for full details
|
|
729
|
+
137. `get_webhook_event` - Get full details of a specific webhook event by ID, including request/response payloads
|
|
730
|
+
138. `search_code` - Search for code across all projects on the GitLab instance (requires advanced search or exact code search to be enabled)
|
|
731
|
+
139. `search_project_code` - Search for code within a specific GitLab project (requires advanced search or exact code search to be enabled)
|
|
732
|
+
140. `search_group_code` - Search for code within a specific GitLab group (requires advanced search or exact code search to be enabled)
|
|
733
|
+
141. `execute_graphql` - Execute a GitLab GraphQL query
|
|
591
734
|
<!-- TOOLS-END -->
|
|
592
735
|
|
|
593
736
|
</details>
|
|
@@ -4,6 +4,64 @@ import { HttpProxyAgent } from "http-proxy-agent";
|
|
|
4
4
|
import { HttpsProxyAgent } from "https-proxy-agent";
|
|
5
5
|
import { SocksProxyAgent } from "socks-proxy-agent";
|
|
6
6
|
import fs from "fs";
|
|
7
|
+
/**
|
|
8
|
+
* Checks if a URL should bypass the proxy based on NO_PROXY patterns.
|
|
9
|
+
* Supports:
|
|
10
|
+
* - Exact hostname matches (e.g., "localhost", "gitlab.example.com")
|
|
11
|
+
* - Domain suffix matches (e.g., ".example.com" matches "gitlab.example.com")
|
|
12
|
+
* - IP addresses (e.g., "127.0.0.1", "192.168.1.1")
|
|
13
|
+
* - Wildcard "*" to bypass all proxies
|
|
14
|
+
* - Port-specific matches (e.g., "example.com:8080")
|
|
15
|
+
*
|
|
16
|
+
* @param url The URL to check
|
|
17
|
+
* @param noProxy Comma-separated list of patterns from NO_PROXY
|
|
18
|
+
* @returns true if the URL should bypass the proxy, false otherwise
|
|
19
|
+
*/
|
|
20
|
+
function shouldBypassProxy(url, noProxy) {
|
|
21
|
+
if (!noProxy) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
// Parse URL to get hostname and port
|
|
25
|
+
let hostname;
|
|
26
|
+
let port;
|
|
27
|
+
let protocol;
|
|
28
|
+
try {
|
|
29
|
+
const parsedUrl = new URL(url);
|
|
30
|
+
hostname = parsedUrl.hostname.toLowerCase();
|
|
31
|
+
protocol = parsedUrl.protocol;
|
|
32
|
+
// Use explicit port if provided, otherwise use default port based on protocol
|
|
33
|
+
port = parsedUrl.port || (protocol === 'https:' ? '443' : '80');
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
// Split NO_PROXY into patterns and trim whitespace
|
|
39
|
+
const patterns = noProxy.split(',').map(p => p.trim().toLowerCase()).filter(p => p.length > 0);
|
|
40
|
+
for (const pattern of patterns) {
|
|
41
|
+
// Wildcard matches everything
|
|
42
|
+
if (pattern === '*') {
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
// Handle port-specific patterns (e.g., "example.com:8080")
|
|
46
|
+
const [patternHost, patternPort] = pattern.split(':');
|
|
47
|
+
// If pattern specifies a port, check if it matches
|
|
48
|
+
if (patternPort && port !== patternPort) {
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
// Check for domain suffix match (e.g., ".example.com")
|
|
52
|
+
if (patternHost.startsWith('.')) {
|
|
53
|
+
const suffix = patternHost.substring(1);
|
|
54
|
+
if (hostname === suffix || hostname.endsWith('.' + suffix)) {
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
// Check for exact hostname match
|
|
59
|
+
else if (hostname === patternHost) {
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
7
65
|
/**
|
|
8
66
|
* Manages a pool of HTTP/HTTPS agents for different GitLab API URLs.
|
|
9
67
|
* This allows the server to efficiently handle requests to multiple GitLab instances
|
|
@@ -23,7 +81,7 @@ export class GitLabClientPool {
|
|
|
23
81
|
* @returns A `ClientAgents` object containing the configured agents.
|
|
24
82
|
*/
|
|
25
83
|
createAgentsForUrl(apiUrl) {
|
|
26
|
-
const { httpProxy, httpsProxy, rejectUnauthorized, caCertPath } = this.options;
|
|
84
|
+
const { httpProxy, httpsProxy, noProxy, rejectUnauthorized, caCertPath } = this.options;
|
|
27
85
|
const url = new URL(apiUrl);
|
|
28
86
|
let sslOptions = {};
|
|
29
87
|
if (rejectUnauthorized === false) {
|
|
@@ -38,10 +96,12 @@ export class GitLabClientPool {
|
|
|
38
96
|
throw new Error(`Failed to read CA certificate: ${caCertPath}`);
|
|
39
97
|
}
|
|
40
98
|
}
|
|
99
|
+
// Check if this URL should bypass the proxy
|
|
100
|
+
const bypassProxy = shouldBypassProxy(apiUrl, noProxy);
|
|
41
101
|
let httpAgent;
|
|
42
102
|
let httpsAgent;
|
|
43
|
-
// Configure HTTP agent with proxy if specified
|
|
44
|
-
if (httpProxy) {
|
|
103
|
+
// Configure HTTP agent with proxy if specified and not bypassed
|
|
104
|
+
if (httpProxy && !bypassProxy) {
|
|
45
105
|
httpAgent = httpProxy.startsWith("socks")
|
|
46
106
|
? new SocksProxyAgent(httpProxy)
|
|
47
107
|
: new HttpProxyAgent(httpProxy);
|
|
@@ -49,8 +109,8 @@ export class GitLabClientPool {
|
|
|
49
109
|
else {
|
|
50
110
|
httpAgent = new Agent({ keepAlive: true });
|
|
51
111
|
}
|
|
52
|
-
// Configure HTTPS agent with proxy and SSL options if specified
|
|
53
|
-
if (httpsProxy) {
|
|
112
|
+
// Configure HTTPS agent with proxy and SSL options if specified and not bypassed
|
|
113
|
+
if (httpsProxy && !bypassProxy) {
|
|
54
114
|
httpsAgent = httpsProxy.startsWith("socks")
|
|
55
115
|
// The `as any` cast is used here to bypass a TypeScript type mismatch error.
|
|
56
116
|
// The `socks-proxy-agent` documentation indicates that TLS options like
|
|
@@ -72,6 +132,31 @@ export class GitLabClientPool {
|
|
|
72
132
|
* @returns The corresponding `Agent` for the URL's protocol.
|
|
73
133
|
*/
|
|
74
134
|
getOrCreateAgentForUrl(apiUrl) {
|
|
135
|
+
const agents = this.getOrCreateAgentsForUrl(apiUrl);
|
|
136
|
+
const url = new URL(apiUrl);
|
|
137
|
+
return url.protocol === "https:" ? agents.httpsAgent : agents.httpAgent;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Returns an agent-selection function for use with node-fetch's `agent` option.
|
|
141
|
+
* The returned function picks the correct HTTP or HTTPS agent based on the
|
|
142
|
+
* request URL's protocol. This is critical for self-hosted GitLab instances
|
|
143
|
+
* where the server may redirect between HTTP and HTTPS (e.g., when
|
|
144
|
+
* `external_url` differs from the actual internal protocol).
|
|
145
|
+
* @param apiUrl The base API URL used to look up or create the agent pair.
|
|
146
|
+
* @returns A function `(parsedURL: URL) => Agent` suitable for node-fetch.
|
|
147
|
+
*/
|
|
148
|
+
getAgentFunctionForUrl(apiUrl) {
|
|
149
|
+
const agents = this.getOrCreateAgentsForUrl(apiUrl);
|
|
150
|
+
return (parsedURL) => {
|
|
151
|
+
return parsedURL.protocol === "https:" ? agents.httpsAgent : agents.httpAgent;
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Ensures agents exist for the given API URL and returns the pair.
|
|
156
|
+
* @param apiUrl The full URL of the request.
|
|
157
|
+
* @returns The `ClientAgents` (both HTTP and HTTPS agents) for the URL.
|
|
158
|
+
*/
|
|
159
|
+
getOrCreateAgentsForUrl(apiUrl) {
|
|
75
160
|
const url = new URL(apiUrl);
|
|
76
161
|
const baseUrl = `${url.protocol}//${url.host}${url.pathname.substring(0, url.pathname.lastIndexOf('/api/v4') + '/api/v4'.length)}`;
|
|
77
162
|
if (!this.clients.has(baseUrl)) {
|
|
@@ -86,7 +171,7 @@ export class GitLabClientPool {
|
|
|
86
171
|
// This should not happen given the logic above, but it satisfies TypeScript
|
|
87
172
|
throw new Error(`Failed to create or get client for URL: ${baseUrl}`);
|
|
88
173
|
}
|
|
89
|
-
return
|
|
174
|
+
return agents;
|
|
90
175
|
}
|
|
91
176
|
/**
|
|
92
177
|
* Retrieves the client agents for a specific base API URL.
|
|
@@ -110,4 +195,27 @@ export class GitLabClientPool {
|
|
|
110
195
|
}
|
|
111
196
|
return this.clients.get(defaultUrl);
|
|
112
197
|
}
|
|
198
|
+
/**
|
|
199
|
+
* Destroy all pooled agents and clear pool state.
|
|
200
|
+
* This should be called on graceful shutdown so sockets are closed
|
|
201
|
+
* and the process can exit cleanly.
|
|
202
|
+
*/
|
|
203
|
+
closeAll() {
|
|
204
|
+
for (const [, agents] of this.clients) {
|
|
205
|
+
const destroyIfSupported = (agent) => {
|
|
206
|
+
if (agent && typeof agent.destroy === "function") {
|
|
207
|
+
agent.destroy();
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
destroyIfSupported(agents.httpAgent);
|
|
211
|
+
destroyIfSupported(agents.httpsAgent);
|
|
212
|
+
}
|
|
213
|
+
this.clients.clear();
|
|
214
|
+
}
|
|
215
|
+
getStats() {
|
|
216
|
+
return {
|
|
217
|
+
size: this.clients.size,
|
|
218
|
+
maxSize: this.options.poolMaxSize ?? 0,
|
|
219
|
+
};
|
|
220
|
+
}
|
|
113
221
|
}
|