Compare commits
26 Commits
doc/readme
...
main
Author | SHA1 | Date | |
---|---|---|---|
672953ff40 | |||
cced1c16f9 | |||
402f068470 | |||
83a8aa8fc2 | |||
8d706275e6 | |||
62f0ffff69 | |||
aed6046022 | |||
2905f30af7 | |||
3c23675eec | |||
8df87c67d2 | |||
d318f9ea5e | |||
ed032bad48 | |||
5200cc526c | |||
1ba54342bc | |||
29659db0b7 | |||
44d8d11b4a | |||
622c112f7f | |||
0930ce3636 | |||
061e19d861 | |||
511d2d9c06 | |||
8cb7703aa1 | |||
5e254836e8 | |||
93710f2846 | |||
c07356bd46 | |||
c82be8c94f | |||
cd8f0e5525 |
46
CHANGELOG.md
46
CHANGELOG.md
@ -1,8 +1,54 @@
|
|||||||
|
## [1.0.63] - 2025-06-12
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- 📊 **CI Job Log Pagination**: Added pagination support for CI job logs to prevent context window flooding
|
||||||
|
- `get_pipeline_job_output` now supports optional `limit` and `offset` parameters
|
||||||
|
- Default limit is 1000 lines when pagination is used
|
||||||
|
- Returns lines from the end of the log, with configurable offset
|
||||||
|
- Includes truncation metadata showing what was skipped
|
||||||
|
- Maintains backward compatibility (no parameters = full log)
|
||||||
|
- See: [PR #97](https://github.com/zereight/gitlab-mcp/pull/97)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## [1.0.62] - 2025-06-10
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- 🔐 **Private Token Authentication Fix**: Fixed Private-Token header authentication for GitLab API
|
||||||
|
- Removed incorrect `Bearer ` prefix from Private-Token header in legacy authentication mode
|
||||||
|
- Fixed authentication issues when using older GitLab instances with private tokens
|
||||||
|
- Ensures proper API authentication for both new and legacy GitLab configurations
|
||||||
|
- See: [PR #91](https://github.com/zereight/gitlab-mcp/pull/91), [Issue #88](https://github.com/zereight/gitlab-mcp/issues/88)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## [1.0.60] - 2025-06-07
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- 📄 **Merge Request Enhancement**: Added support for `remove_source_branch` and `squash` options for merge requests
|
||||||
|
- Enhanced merge request functionality with additional configuration options
|
||||||
|
- Allows automatic source branch removal after merge
|
||||||
|
- Supports squash commits for cleaner Git history
|
||||||
|
- See: [PR #86](https://github.com/zereight/gitlab-mcp/pull/86)
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- 🔧 **Issue Assignment Fix**: Fixed list issues assignee username handling
|
||||||
|
- Corrected assignee username field in issue listing functionality
|
||||||
|
- Improved user assignment data processing for GitLab issues
|
||||||
|
- See: [PR #87](https://github.com/zereight/gitlab-mcp/pull/87), [Issue #74](https://github.com/zereight/gitlab-mcp/issues/74)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## [1.0.54] - 2025-05-31
|
## [1.0.54] - 2025-05-31
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
- 🌐 **Multi-Platform Support**: Added support for multiple platforms to improve compatibility across different environments
|
- 🌐 **Multi-Platform Support**: Added support for multiple platforms to improve compatibility across different environments
|
||||||
|
|
||||||
- Enhanced platform detection and configuration handling
|
- Enhanced platform detection and configuration handling
|
||||||
- Improved cross-platform functionality for GitLab MCP server
|
- Improved cross-platform functionality for GitLab MCP server
|
||||||
- See: [PR #71](https://github.com/zereight/gitlab-mcp/pull/71), [Issue #69](https://github.com/zereight/gitlab-mcp/issues/69)
|
- See: [PR #71](https://github.com/zereight/gitlab-mcp/pull/71), [Issue #69](https://github.com/zereight/gitlab-mcp/issues/69)
|
||||||
|
116
README.md
116
README.md
@ -36,7 +36,9 @@ When using with the Claude App, you need to set up your API key and URLs directl
|
|||||||
```
|
```
|
||||||
|
|
||||||
#### Docker
|
#### Docker
|
||||||
|
|
||||||
- stdio
|
- stdio
|
||||||
|
|
||||||
```mcp.json
|
```mcp.json
|
||||||
{
|
{
|
||||||
"mcpServers": {
|
"mcpServers": {
|
||||||
@ -74,6 +76,7 @@ When using with the Claude App, you need to set up your API key and URLs directl
|
|||||||
```
|
```
|
||||||
|
|
||||||
- sse
|
- sse
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
docker run -i --rm \
|
docker run -i --rm \
|
||||||
-e GITLAB_PERSONAL_ACCESS_TOKEN=your_gitlab_token \
|
-e GITLAB_PERSONAL_ACCESS_TOKEN=your_gitlab_token \
|
||||||
@ -111,10 +114,14 @@ $ sh scripts/image_push.sh docker_user_name
|
|||||||
- `USE_GITLAB_WIKI`: When set to 'true', enables the wiki-related tools (list_wiki_pages, get_wiki_page, create_wiki_page, update_wiki_page, delete_wiki_page). By default, wiki features are disabled.
|
- `USE_GITLAB_WIKI`: When set to 'true', enables the wiki-related tools (list_wiki_pages, get_wiki_page, create_wiki_page, update_wiki_page, delete_wiki_page). By default, wiki features are disabled.
|
||||||
- `USE_MILESTONE`: When set to 'true', enables the milestone-related tools (list_milestones, get_milestone, create_milestone, edit_milestone, delete_milestone, get_milestone_issue, get_milestone_merge_requests, promote_milestone, get_milestone_burndown_events). By default, milestone features are disabled.
|
- `USE_MILESTONE`: When set to 'true', enables the milestone-related tools (list_milestones, get_milestone, create_milestone, edit_milestone, delete_milestone, get_milestone_issue, get_milestone_merge_requests, promote_milestone, get_milestone_burndown_events). By default, milestone features are disabled.
|
||||||
- `USE_PIPELINE`: When set to 'true', enables the pipeline-related tools (list_pipelines, get_pipeline, list_pipeline_jobs, get_pipeline_job, get_pipeline_job_output, create_pipeline, retry_pipeline, cancel_pipeline). By default, pipeline features are disabled.
|
- `USE_PIPELINE`: When set to 'true', enables the pipeline-related tools (list_pipelines, get_pipeline, list_pipeline_jobs, get_pipeline_job, get_pipeline_job_output, create_pipeline, retry_pipeline, cancel_pipeline). By default, pipeline features are disabled.
|
||||||
|
- `GITLAB_AUTH_COOKIE_PATH`: Path to an authentication cookie file for GitLab instances that require cookie-based authentication. When provided, the cookie will be included in all GitLab API requests.
|
||||||
|
|
||||||
|
[](https://www.star-history.com/#zereight/gitlab-mcp&Date)
|
||||||
|
|
||||||
## Tools 🛠️
|
## Tools 🛠️
|
||||||
|
|
||||||
+<!-- TOOLS-START -->
|
+<!-- TOOLS-START -->
|
||||||
|
|
||||||
1. `create_or_update_file` - Create or update a single file in a GitLab project
|
1. `create_or_update_file` - Create or update a single file in a GitLab project
|
||||||
2. `search_repositories` - Search for GitLab projects
|
2. `search_repositories` - Search for GitLab projects
|
||||||
3. `create_repository` - Create a new GitLab project
|
3. `create_repository` - Create a new GitLab project
|
||||||
@ -126,58 +133,59 @@ $ sh scripts/image_push.sh docker_user_name
|
|||||||
9. `create_branch` - Create a new branch in a GitLab project
|
9. `create_branch` - Create a new branch in a GitLab project
|
||||||
10. `get_merge_request` - Get details of a merge request (Either mergeRequestIid or branchName must be provided)
|
10. `get_merge_request` - Get details of a merge request (Either mergeRequestIid or branchName must be provided)
|
||||||
11. `get_merge_request_diffs` - Get the changes/diffs of a merge request (Either mergeRequestIid or branchName must be provided)
|
11. `get_merge_request_diffs` - Get the changes/diffs of a merge request (Either mergeRequestIid or branchName must be provided)
|
||||||
12. `get_branch_diffs` - Get the changes/diffs between two branches or commits in a GitLab project
|
12. `list_merge_request_diffs` - List merge request diffs with pagination support (Either mergeRequestIid or branchName must be provided)
|
||||||
13. `update_merge_request` - Update a merge request (Either mergeRequestIid or branchName must be provided)
|
13. `get_branch_diffs` - Get the changes/diffs between two branches or commits in a GitLab project
|
||||||
14. `create_note` - Create a new note (comment) to an issue or merge request
|
14. `update_merge_request` - Update a merge request (Either mergeRequestIid or branchName must be provided)
|
||||||
15. `create_merge_request_thread` - Create a new thread on a merge request
|
15. `create_note` - Create a new note (comment) to an issue or merge request
|
||||||
16. `mr_discussions` - List discussion items for a merge request
|
16. `create_merge_request_thread` - Create a new thread on a merge request
|
||||||
17. `update_merge_request_note` - Modify an existing merge request thread note
|
17. `mr_discussions` - List discussion items for a merge request
|
||||||
18. `create_merge_request_note` - Add a new note to an existing merge request thread
|
18. `update_merge_request_note` - Modify an existing merge request thread note
|
||||||
19. `update_issue_note` - Modify an existing issue thread note
|
19. `create_merge_request_note` - Add a new note to an existing merge request thread
|
||||||
20. `create_issue_note` - Add a new note to an existing issue thread
|
20. `update_issue_note` - Modify an existing issue thread note
|
||||||
21. `list_issues` - List issues in a GitLab project with filtering options
|
21. `create_issue_note` - Add a new note to an existing issue thread
|
||||||
22. `get_issue` - Get details of a specific issue in a GitLab project
|
22. `list_issues` - List issues in a GitLab project with filtering options
|
||||||
23. `update_issue` - Update an issue in a GitLab project
|
23. `get_issue` - Get details of a specific issue in a GitLab project
|
||||||
24. `delete_issue` - Delete an issue from a GitLab project
|
24. `update_issue` - Update an issue in a GitLab project
|
||||||
25. `list_issue_links` - List all issue links for a specific issue
|
25. `delete_issue` - Delete an issue from a GitLab project
|
||||||
26. `list_issue_discussions` - List discussions for an issue in a GitLab project
|
26. `list_issue_links` - List all issue links for a specific issue
|
||||||
27. `get_issue_link` - Get a specific issue link
|
27. `list_issue_discussions` - List discussions for an issue in a GitLab project
|
||||||
28. `create_issue_link` - Create an issue link between two issues
|
28. `get_issue_link` - Get a specific issue link
|
||||||
29. `delete_issue_link` - Delete an issue link
|
29. `create_issue_link` - Create an issue link between two issues
|
||||||
30. `list_namespaces` - List all namespaces available to the current user
|
30. `delete_issue_link` - Delete an issue link
|
||||||
31. `get_namespace` - Get details of a namespace by ID or path
|
31. `list_namespaces` - List all namespaces available to the current user
|
||||||
32. `verify_namespace` - Verify if a namespace path exists
|
32. `get_namespace` - Get details of a namespace by ID or path
|
||||||
33. `get_project` - Get details of a specific project
|
33. `verify_namespace` - Verify if a namespace path exists
|
||||||
34. `list_projects` - List projects accessible by the current user
|
34. `get_project` - Get details of a specific project
|
||||||
35. `list_labels` - List labels for a project
|
35. `list_projects` - List projects accessible by the current user
|
||||||
36. `get_label` - Get a single label from a project
|
36. `list_labels` - List labels for a project
|
||||||
37. `create_label` - Create a new label in a project
|
37. `get_label` - Get a single label from a project
|
||||||
38. `update_label` - Update an existing label in a project
|
38. `create_label` - Create a new label in a project
|
||||||
39. `delete_label` - Delete a label from a project
|
39. `update_label` - Update an existing label in a project
|
||||||
40. `list_group_projects` - List projects in a GitLab group with filtering options
|
40. `delete_label` - Delete a label from a project
|
||||||
41. `list_wiki_pages` - List wiki pages in a GitLab project
|
41. `list_group_projects` - List projects in a GitLab group with filtering options
|
||||||
42. `get_wiki_page` - Get details of a specific wiki page
|
42. `list_wiki_pages` - List wiki pages in a GitLab project
|
||||||
43. `create_wiki_page` - Create a new wiki page in a GitLab project
|
43. `get_wiki_page` - Get details of a specific wiki page
|
||||||
44. `update_wiki_page` - Update an existing wiki page in a GitLab project
|
44. `create_wiki_page` - Create a new wiki page in a GitLab project
|
||||||
45. `delete_wiki_page` - Delete a wiki page from a GitLab project
|
45. `update_wiki_page` - Update an existing wiki page in a GitLab project
|
||||||
46. `get_repository_tree` - Get the repository tree for a GitLab project (list files and directories)
|
46. `delete_wiki_page` - Delete a wiki page from a GitLab project
|
||||||
47. `list_pipelines` - List pipelines in a GitLab project with filtering options
|
47. `get_repository_tree` - Get the repository tree for a GitLab project (list files and directories)
|
||||||
48. `get_pipeline` - Get details of a specific pipeline in a GitLab project
|
48. `list_pipelines` - List pipelines in a GitLab project with filtering options
|
||||||
49. `list_pipeline_jobs` - List all jobs in a specific pipeline
|
49. `get_pipeline` - Get details of a specific pipeline in a GitLab project
|
||||||
50. `get_pipeline_job` - Get details of a GitLab pipeline job number
|
50. `list_pipeline_jobs` - List all jobs in a specific pipeline
|
||||||
51. `get_pipeline_job_output` - Get the output/trace of a GitLab pipeline job number
|
51. `get_pipeline_job` - Get details of a GitLab pipeline job number
|
||||||
52. `create_pipeline` - Create a new pipeline for a branch or tag
|
52. `get_pipeline_job_output` - Get the output/trace of a GitLab pipeline job number
|
||||||
53. `retry_pipeline` - Retry a failed or canceled pipeline
|
53. `create_pipeline` - Create a new pipeline for a branch or tag
|
||||||
54. `cancel_pipeline` - Cancel a running pipeline
|
54. `retry_pipeline` - Retry a failed or canceled pipeline
|
||||||
55. `list_merge_requests` - List merge requests in a GitLab project with filtering options
|
55. `cancel_pipeline` - Cancel a running pipeline
|
||||||
56. `list_milestones` - List milestones in a GitLab project with filtering options
|
56. `list_merge_requests` - List merge requests in a GitLab project with filtering options
|
||||||
57. `get_milestone` - Get details of a specific milestone
|
57. `list_milestones` - List milestones in a GitLab project with filtering options
|
||||||
58. `create_milestone` - Create a new milestone in a GitLab project
|
58. `get_milestone` - Get details of a specific milestone
|
||||||
59. `edit_milestone` - Edit an existing milestone in a GitLab project
|
59. `create_milestone` - Create a new milestone in a GitLab project
|
||||||
60. `delete_milestone` - Delete a milestone from a GitLab project
|
60. `edit_milestone` - Edit an existing milestone in a GitLab project
|
||||||
61. `get_milestone_issue` - Get issues associated with a specific milestone
|
61. `delete_milestone` - Delete a milestone from a GitLab project
|
||||||
62. `get_milestone_merge_requests` - Get merge requests associated with a specific milestone
|
62. `get_milestone_issue` - Get issues associated with a specific milestone
|
||||||
63. `promote_milestone` - Promote a milestone to the next stage
|
63. `get_milestone_merge_requests` - Get merge requests associated with a specific milestone
|
||||||
64. `get_milestone_burndown_events` - Get burndown events for a specific milestone
|
64. `promote_milestone` - Promote a milestone to the next stage
|
||||||
65. `get_users` - Get GitLab user details by usernames
|
65. `get_milestone_burndown_events` - Get burndown events for a specific milestone
|
||||||
|
66. `get_users` - Get GitLab user details by usernames
|
||||||
<!-- TOOLS-END -->
|
<!-- TOOLS-END -->
|
||||||
|
11
RELEASE_NOTES.md
Normal file
11
RELEASE_NOTES.md
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
## [1.0.62] - 2025-06-10
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- 🔐 **Private Token Authentication Fix**: Fixed Private-Token header authentication for GitLab API
|
||||||
|
- Removed incorrect `Bearer ` prefix from Private-Token header in legacy authentication mode
|
||||||
|
- Fixed authentication issues when using older GitLab instances with private tokens
|
||||||
|
- Ensures proper API authentication for both new and legacy GitLab configurations
|
||||||
|
- See: [PR #91](https://github.com/zereight/gitlab-mcp/pull/91), [Issue #88](https://github.com/zereight/gitlab-mcp/issues/88)
|
||||||
|
|
||||||
|
---
|
625
index.ts
625
index.ts
@ -4,7 +4,9 @@ import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|||||||
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
||||||
import { SSEServerTransport } from "@modelcontextprotocol/sdk/server/sse.js";
|
import { SSEServerTransport } from "@modelcontextprotocol/sdk/server/sse.js";
|
||||||
import { CallToolRequestSchema, ListToolsRequestSchema } from "@modelcontextprotocol/sdk/types.js";
|
import { CallToolRequestSchema, ListToolsRequestSchema } from "@modelcontextprotocol/sdk/types.js";
|
||||||
import fetch from "node-fetch";
|
import nodeFetch from "node-fetch";
|
||||||
|
import fetchCookie from "fetch-cookie";
|
||||||
|
import { CookieJar, parse as parseCookie } from "tough-cookie";
|
||||||
import { SocksProxyAgent } from "socks-proxy-agent";
|
import { SocksProxyAgent } from "socks-proxy-agent";
|
||||||
import { HttpsProxyAgent } from "https-proxy-agent";
|
import { HttpsProxyAgent } from "https-proxy-agent";
|
||||||
import { HttpProxyAgent } from "http-proxy-agent";
|
import { HttpProxyAgent } from "http-proxy-agent";
|
||||||
@ -17,7 +19,7 @@ import path from "path";
|
|||||||
import express, { Request, Response } from "express";
|
import express, { Request, Response } from "express";
|
||||||
// Add type imports for proxy agents
|
// Add type imports for proxy agents
|
||||||
import { Agent } from "http";
|
import { Agent } from "http";
|
||||||
import { Agent as HttpsAgent } from 'https';
|
import { Agent as HttpsAgent } from "https";
|
||||||
import { URL } from "url";
|
import { URL } from "url";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@ -100,6 +102,7 @@ import {
|
|||||||
// Discussion Schemas
|
// Discussion Schemas
|
||||||
GitLabDiscussionNoteSchema, // Added
|
GitLabDiscussionNoteSchema, // Added
|
||||||
GitLabDiscussionSchema,
|
GitLabDiscussionSchema,
|
||||||
|
PaginatedDiscussionsResponseSchema,
|
||||||
UpdateMergeRequestNoteSchema, // Added
|
UpdateMergeRequestNoteSchema, // Added
|
||||||
CreateMergeRequestNoteSchema, // Added
|
CreateMergeRequestNoteSchema, // Added
|
||||||
ListMergeRequestDiscussionsSchema,
|
ListMergeRequestDiscussionsSchema,
|
||||||
@ -142,8 +145,10 @@ import {
|
|||||||
type PromoteProjectMilestoneOptions,
|
type PromoteProjectMilestoneOptions,
|
||||||
type GetMilestoneBurndownEventsOptions,
|
type GetMilestoneBurndownEventsOptions,
|
||||||
// Discussion Types
|
// Discussion Types
|
||||||
type GitLabDiscussionNote, // Added
|
type GitLabDiscussionNote,
|
||||||
type GitLabDiscussion,
|
type GitLabDiscussion,
|
||||||
|
type PaginatedDiscussionsResponse,
|
||||||
|
type PaginationOptions,
|
||||||
type MergeRequestThreadPosition,
|
type MergeRequestThreadPosition,
|
||||||
type GetWikiPageOptions,
|
type GetWikiPageOptions,
|
||||||
type CreateWikiPageOptions,
|
type CreateWikiPageOptions,
|
||||||
@ -168,6 +173,14 @@ import {
|
|||||||
GitLabCompareResult,
|
GitLabCompareResult,
|
||||||
GitLabCompareResultSchema,
|
GitLabCompareResultSchema,
|
||||||
GetBranchDiffsSchema,
|
GetBranchDiffsSchema,
|
||||||
|
ListWikiPagesOptions,
|
||||||
|
ListCommitsSchema,
|
||||||
|
GetCommitSchema,
|
||||||
|
GetCommitDiffSchema,
|
||||||
|
type ListCommitsOptions,
|
||||||
|
type GetCommitOptions,
|
||||||
|
type GetCommitDiffOptions,
|
||||||
|
ListMergeRequestDiffsSchema,
|
||||||
} from "./schemas.js";
|
} from "./schemas.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -183,7 +196,7 @@ try {
|
|||||||
SERVER_VERSION = packageJson.version || SERVER_VERSION;
|
SERVER_VERSION = packageJson.version || SERVER_VERSION;
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Warning: Could not read version from package.json:", error);
|
// Warning: Could not read version from package.json - silently continue
|
||||||
}
|
}
|
||||||
|
|
||||||
const server = new Server(
|
const server = new Server(
|
||||||
@ -199,6 +212,8 @@ const server = new Server(
|
|||||||
);
|
);
|
||||||
|
|
||||||
const GITLAB_PERSONAL_ACCESS_TOKEN = process.env.GITLAB_PERSONAL_ACCESS_TOKEN;
|
const GITLAB_PERSONAL_ACCESS_TOKEN = process.env.GITLAB_PERSONAL_ACCESS_TOKEN;
|
||||||
|
const GITLAB_AUTH_COOKIE_PATH = process.env.GITLAB_AUTH_COOKIE_PATH;
|
||||||
|
const IS_OLD = process.env.GITLAB_IS_OLD === "true";
|
||||||
const GITLAB_READ_ONLY_MODE = process.env.GITLAB_READ_ONLY_MODE === "true";
|
const GITLAB_READ_ONLY_MODE = process.env.GITLAB_READ_ONLY_MODE === "true";
|
||||||
const USE_GITLAB_WIKI = process.env.USE_GITLAB_WIKI === "true";
|
const USE_GITLAB_WIKI = process.env.USE_GITLAB_WIKI === "true";
|
||||||
const USE_MILESTONE = process.env.USE_MILESTONE === "true";
|
const USE_MILESTONE = process.env.USE_MILESTONE === "true";
|
||||||
@ -211,12 +226,12 @@ const HTTPS_PROXY = process.env.HTTPS_PROXY;
|
|||||||
const NODE_TLS_REJECT_UNAUTHORIZED = process.env.NODE_TLS_REJECT_UNAUTHORIZED;
|
const NODE_TLS_REJECT_UNAUTHORIZED = process.env.NODE_TLS_REJECT_UNAUTHORIZED;
|
||||||
const GITLAB_CA_CERT_PATH = process.env.GITLAB_CA_CERT_PATH;
|
const GITLAB_CA_CERT_PATH = process.env.GITLAB_CA_CERT_PATH;
|
||||||
|
|
||||||
let sslOptions= undefined;
|
let sslOptions = undefined;
|
||||||
if (NODE_TLS_REJECT_UNAUTHORIZED === '0') {
|
if (NODE_TLS_REJECT_UNAUTHORIZED === "0") {
|
||||||
sslOptions = { rejectUnauthorized: false };
|
sslOptions = { rejectUnauthorized: false };
|
||||||
} else if (GITLAB_CA_CERT_PATH) {
|
} else if (GITLAB_CA_CERT_PATH) {
|
||||||
const ca = fs.readFileSync(GITLAB_CA_CERT_PATH);
|
const ca = fs.readFileSync(GITLAB_CA_CERT_PATH);
|
||||||
sslOptions = { ca };
|
sslOptions = { ca };
|
||||||
}
|
}
|
||||||
|
|
||||||
// Configure proxy agents if proxies are set
|
// Configure proxy agents if proxies are set
|
||||||
@ -240,12 +255,98 @@ if (HTTPS_PROXY) {
|
|||||||
httpsAgent = httpsAgent || new HttpsAgent(sslOptions);
|
httpsAgent = httpsAgent || new HttpsAgent(sslOptions);
|
||||||
httpAgent = httpAgent || new Agent();
|
httpAgent = httpAgent || new Agent();
|
||||||
|
|
||||||
|
// Create cookie jar with clean Netscape file parsing
|
||||||
|
const createCookieJar = (): CookieJar | null => {
|
||||||
|
if (!GITLAB_AUTH_COOKIE_PATH) return null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const cookiePath = GITLAB_AUTH_COOKIE_PATH.startsWith("~/")
|
||||||
|
? path.join(process.env.HOME || "", GITLAB_AUTH_COOKIE_PATH.slice(2))
|
||||||
|
: GITLAB_AUTH_COOKIE_PATH;
|
||||||
|
|
||||||
|
const jar = new CookieJar();
|
||||||
|
const cookieContent = fs.readFileSync(cookiePath, "utf8");
|
||||||
|
|
||||||
|
cookieContent.split("\n").forEach(line => {
|
||||||
|
// Handle #HttpOnly_ prefix
|
||||||
|
if (line.startsWith("#HttpOnly_")) {
|
||||||
|
line = line.slice(10);
|
||||||
|
}
|
||||||
|
// Skip comments and empty lines
|
||||||
|
if (line.startsWith("#") || !line.trim()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Parse Netscape format: domain, flag, path, secure, expires, name, value
|
||||||
|
const parts = line.split("\t");
|
||||||
|
if (parts.length >= 7) {
|
||||||
|
const [domain, , path, secure, expires, name, value] = parts;
|
||||||
|
|
||||||
|
// Build cookie string in standard format
|
||||||
|
const cookieStr = `${name}=${value}; Domain=${domain}; Path=${path}${secure === "TRUE" ? "; Secure" : ""}${expires !== "0" ? `; Expires=${new Date(parseInt(expires) * 1000).toUTCString()}` : ""}`;
|
||||||
|
|
||||||
|
// Use tough-cookie's parse function for robust parsing
|
||||||
|
const cookie = parseCookie(cookieStr);
|
||||||
|
if (cookie) {
|
||||||
|
const url = `${secure === "TRUE" ? "https" : "http"}://${domain.startsWith(".") ? domain.slice(1) : domain}`;
|
||||||
|
jar.setCookieSync(cookie, url);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return jar;
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error loading cookie file:", error);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Initialize cookie jar and fetch
|
||||||
|
const cookieJar = createCookieJar();
|
||||||
|
const fetch = cookieJar ? fetchCookie(nodeFetch, cookieJar) : nodeFetch;
|
||||||
|
|
||||||
|
// Ensure session is established for the current request
|
||||||
|
async function ensureSessionForRequest(): Promise<void> {
|
||||||
|
if (!cookieJar || !GITLAB_AUTH_COOKIE_PATH) return;
|
||||||
|
|
||||||
|
// Extract the base URL from GITLAB_API_URL
|
||||||
|
const apiUrl = new URL(GITLAB_API_URL);
|
||||||
|
const baseUrl = `${apiUrl.protocol}//${apiUrl.hostname}`;
|
||||||
|
|
||||||
|
// Check if we already have GitLab session cookies
|
||||||
|
const gitlabCookies = cookieJar.getCookiesSync(baseUrl);
|
||||||
|
const hasSessionCookie = gitlabCookies.some(cookie =>
|
||||||
|
cookie.key === '_gitlab_session' || cookie.key === 'remember_user_token'
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!hasSessionCookie) {
|
||||||
|
try {
|
||||||
|
// Establish session with a lightweight request
|
||||||
|
await fetch(`${GITLAB_API_URL}/user`, {
|
||||||
|
...DEFAULT_FETCH_CONFIG,
|
||||||
|
redirect: 'follow'
|
||||||
|
}).catch(() => {
|
||||||
|
// Ignore errors - the important thing is that cookies get set during redirects
|
||||||
|
});
|
||||||
|
|
||||||
|
// Small delay to ensure cookies are fully processed
|
||||||
|
await new Promise(resolve => setTimeout(resolve, 100));
|
||||||
|
} catch (error) {
|
||||||
|
// Ignore session establishment errors
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Modify DEFAULT_HEADERS to include agent configuration
|
// Modify DEFAULT_HEADERS to include agent configuration
|
||||||
const DEFAULT_HEADERS = {
|
const DEFAULT_HEADERS: Record<string, string> = {
|
||||||
Accept: "application/json",
|
Accept: "application/json",
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
Authorization: `Bearer ${GITLAB_PERSONAL_ACCESS_TOKEN}`,
|
|
||||||
};
|
};
|
||||||
|
if (IS_OLD) {
|
||||||
|
DEFAULT_HEADERS["Private-Token"] = `${GITLAB_PERSONAL_ACCESS_TOKEN}`;
|
||||||
|
} else {
|
||||||
|
DEFAULT_HEADERS["Authorization"] = `Bearer ${GITLAB_PERSONAL_ACCESS_TOKEN}`;
|
||||||
|
}
|
||||||
|
|
||||||
// Create a default fetch configuration object that includes proxy agents if set
|
// Create a default fetch configuration object that includes proxy agents if set
|
||||||
const DEFAULT_FETCH_CONFIG = {
|
const DEFAULT_FETCH_CONFIG = {
|
||||||
@ -318,9 +419,14 @@ const allTools = [
|
|||||||
inputSchema: zodToJsonSchema(GetMergeRequestDiffsSchema),
|
inputSchema: zodToJsonSchema(GetMergeRequestDiffsSchema),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "get_branch_diffs",
|
name: "list_merge_request_diffs",
|
||||||
description:
|
description:
|
||||||
"Get the changes/diffs between two branches or commits in a GitLab project",
|
"List merge request diffs with pagination support (Either mergeRequestIid or branchName must be provided)",
|
||||||
|
inputSchema: zodToJsonSchema(ListMergeRequestDiffsSchema),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "get_branch_diffs",
|
||||||
|
description: "Get the changes/diffs between two branches or commits in a GitLab project",
|
||||||
inputSchema: zodToJsonSchema(GetBranchDiffsSchema),
|
inputSchema: zodToJsonSchema(GetBranchDiffsSchema),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -515,7 +621,7 @@ const allTools = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "get_pipeline_job_output",
|
name: "get_pipeline_job_output",
|
||||||
description: "Get the output/trace of a GitLab pipeline job number",
|
description: "Get the output/trace of a GitLab pipeline job with optional pagination to limit context window usage",
|
||||||
inputSchema: zodToJsonSchema(GetPipelineJobOutputSchema),
|
inputSchema: zodToJsonSchema(GetPipelineJobOutputSchema),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -588,6 +694,21 @@ const allTools = [
|
|||||||
description: "Get GitLab user details by usernames",
|
description: "Get GitLab user details by usernames",
|
||||||
inputSchema: zodToJsonSchema(GetUsersSchema),
|
inputSchema: zodToJsonSchema(GetUsersSchema),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "list_commits",
|
||||||
|
description: "List repository commits with filtering options",
|
||||||
|
inputSchema: zodToJsonSchema(ListCommitsSchema),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "get_commit",
|
||||||
|
description: "Get details of a specific commit",
|
||||||
|
inputSchema: zodToJsonSchema(GetCommitSchema),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "get_commit_diff",
|
||||||
|
description: "Get changes/diffs of a specific commit",
|
||||||
|
inputSchema: zodToJsonSchema(GetCommitDiffSchema),
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
// Define which tools are read-only
|
// Define which tools are read-only
|
||||||
@ -626,6 +747,9 @@ const readOnlyTools = [
|
|||||||
"list_wiki_pages",
|
"list_wiki_pages",
|
||||||
"get_wiki_page",
|
"get_wiki_page",
|
||||||
"get_users",
|
"get_users",
|
||||||
|
"list_commits",
|
||||||
|
"get_commit",
|
||||||
|
"get_commit_diff",
|
||||||
];
|
];
|
||||||
|
|
||||||
// Define which tools are related to wiki and can be toggled by USE_GITLAB_WIKI
|
// Define which tools are related to wiki and can be toggled by USE_GITLAB_WIKI
|
||||||
@ -903,13 +1027,18 @@ async function listIssues(
|
|||||||
// Add all query parameters
|
// Add all query parameters
|
||||||
Object.entries(options).forEach(([key, value]) => {
|
Object.entries(options).forEach(([key, value]) => {
|
||||||
if (value !== undefined) {
|
if (value !== undefined) {
|
||||||
if (key === "labels" && Array.isArray(value)) {
|
const keys = ["labels", "assignee_username"];
|
||||||
// Handle array of labels
|
if (keys.includes(key)) {
|
||||||
value.forEach(label => {
|
if (Array.isArray(value)) {
|
||||||
url.searchParams.append("labels[]", label.toString());
|
// Handle array of labels
|
||||||
});
|
value.forEach(label => {
|
||||||
|
url.searchParams.append(`${key}[]`, label.toString());
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
url.searchParams.append(`${key}[]`, value.toString());
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
url.searchParams.append("labels[]", value.toString());
|
url.searchParams.append(key, value.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -1191,6 +1320,8 @@ async function createMergeRequest(
|
|||||||
labels: options.labels?.join(","),
|
labels: options.labels?.join(","),
|
||||||
allow_collaboration: options.allow_collaboration,
|
allow_collaboration: options.allow_collaboration,
|
||||||
draft: options.draft,
|
draft: options.draft,
|
||||||
|
remove_source_branch: options.remove_source_branch,
|
||||||
|
squash: options.squash,
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1209,55 +1340,26 @@ async function createMergeRequest(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List merge request discussion items
|
* Shared helper function for listing discussions
|
||||||
* 병합 요청 토론 목록 조회
|
* 토론 목록 조회를 위한 공유 헬퍼 함수
|
||||||
*
|
*
|
||||||
* @param {string} projectId - The ID or URL-encoded path of the project
|
* @param {string} projectId - The ID or URL-encoded path of the project
|
||||||
* @param {number} mergeRequestIid - The IID of a merge request
|
* @param {"issues" | "merge_requests"} resourceType - The type of resource (issues or merge_requests)
|
||||||
* @returns {Promise<GitLabDiscussion[]>} List of discussions
|
* @param {number} resourceIid - The IID of the issue or merge request
|
||||||
|
* @param {PaginationOptions} options - Pagination and sorting options
|
||||||
|
* @returns {Promise<PaginatedDiscussionsResponse>} Paginated list of discussions
|
||||||
*/
|
*/
|
||||||
async function listMergeRequestDiscussions(
|
async function listDiscussions(
|
||||||
projectId: string,
|
projectId: string,
|
||||||
mergeRequestIid: number
|
resourceType: "issues" | "merge_requests",
|
||||||
): Promise<GitLabDiscussion[]> {
|
resourceIid: number,
|
||||||
|
options: PaginationOptions = {}
|
||||||
|
): Promise<PaginatedDiscussionsResponse> {
|
||||||
projectId = decodeURIComponent(projectId); // Decode project ID
|
projectId = decodeURIComponent(projectId); // Decode project ID
|
||||||
const url = new URL(
|
const url = new URL(
|
||||||
`${GITLAB_API_URL}/projects/${encodeURIComponent(
|
`${GITLAB_API_URL}/projects/${encodeURIComponent(
|
||||||
projectId
|
projectId
|
||||||
)}/merge_requests/${mergeRequestIid}/discussions`
|
)}/${resourceType}/${resourceIid}/discussions`
|
||||||
);
|
|
||||||
|
|
||||||
const response = await fetch(url.toString(), {
|
|
||||||
...DEFAULT_FETCH_CONFIG,
|
|
||||||
});
|
|
||||||
|
|
||||||
await handleGitLabError(response);
|
|
||||||
const data = await response.json();
|
|
||||||
// Ensure the response is parsed as an array of discussions
|
|
||||||
return z.array(GitLabDiscussionSchema).parse(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* List discussions for an issue
|
|
||||||
*
|
|
||||||
* @param {string} projectId - The ID or URL-encoded path of the project
|
|
||||||
* @param {number} issueIid - The internal ID of the project issue
|
|
||||||
* @param {Object} options - Pagination and sorting options
|
|
||||||
* @returns {Promise<GitLabDiscussion[]>} List of issue discussions
|
|
||||||
*/
|
|
||||||
async function listIssueDiscussions(
|
|
||||||
projectId: string,
|
|
||||||
issueIid: number,
|
|
||||||
options: {
|
|
||||||
page?: number;
|
|
||||||
per_page?: number;
|
|
||||||
sort?: "asc" | "desc";
|
|
||||||
order_by?: "created_at" | "updated_at";
|
|
||||||
} = {}
|
|
||||||
): Promise<GitLabDiscussion[]> {
|
|
||||||
projectId = decodeURIComponent(projectId); // Decode project ID
|
|
||||||
const url = new URL(
|
|
||||||
`${GITLAB_API_URL}/projects/${encodeURIComponent(projectId)}/issues/${issueIid}/discussions`
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// Add query parameters for pagination and sorting
|
// Add query parameters for pagination and sorting
|
||||||
@ -1267,22 +1369,69 @@ async function listIssueDiscussions(
|
|||||||
if (options.per_page) {
|
if (options.per_page) {
|
||||||
url.searchParams.append("per_page", options.per_page.toString());
|
url.searchParams.append("per_page", options.per_page.toString());
|
||||||
}
|
}
|
||||||
if (options.sort) {
|
|
||||||
url.searchParams.append("sort", options.sort);
|
|
||||||
}
|
|
||||||
if (options.order_by) {
|
|
||||||
url.searchParams.append("order_by", options.order_by);
|
|
||||||
}
|
|
||||||
|
|
||||||
const response = await fetch(url.toString(), {
|
const response = await fetch(url.toString(), {
|
||||||
...DEFAULT_FETCH_CONFIG,
|
...DEFAULT_FETCH_CONFIG,
|
||||||
});
|
});
|
||||||
|
|
||||||
await handleGitLabError(response);
|
await handleGitLabError(response);
|
||||||
const data = await response.json();
|
const discussions = await response.json();
|
||||||
|
|
||||||
// Parse the response as an array of discussions
|
// Extract pagination headers
|
||||||
return z.array(GitLabDiscussionSchema).parse(data);
|
const pagination = {
|
||||||
|
x_next_page: response.headers.get("x-next-page")
|
||||||
|
? parseInt(response.headers.get("x-next-page")!)
|
||||||
|
: null,
|
||||||
|
x_page: response.headers.get("x-page") ? parseInt(response.headers.get("x-page")!) : undefined,
|
||||||
|
x_per_page: response.headers.get("x-per-page")
|
||||||
|
? parseInt(response.headers.get("x-per-page")!)
|
||||||
|
: undefined,
|
||||||
|
x_prev_page: response.headers.get("x-prev-page")
|
||||||
|
? parseInt(response.headers.get("x-prev-page")!)
|
||||||
|
: null,
|
||||||
|
x_total: response.headers.get("x-total") ? parseInt(response.headers.get("x-total")!) : null,
|
||||||
|
x_total_pages: response.headers.get("x-total-pages")
|
||||||
|
? parseInt(response.headers.get("x-total-pages")!)
|
||||||
|
: null,
|
||||||
|
};
|
||||||
|
|
||||||
|
return PaginatedDiscussionsResponseSchema.parse({
|
||||||
|
items: discussions,
|
||||||
|
pagination: pagination,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List merge request discussion items
|
||||||
|
* 병합 요청 토론 목록 조회
|
||||||
|
*
|
||||||
|
* @param {string} projectId - The ID or URL-encoded path of the project
|
||||||
|
* @param {number} mergeRequestIid - The IID of a merge request
|
||||||
|
* @param {DiscussionPaginationOptions} options - Pagination and sorting options
|
||||||
|
* @returns {Promise<GitLabDiscussion[]>} List of discussions
|
||||||
|
*/
|
||||||
|
async function listMergeRequestDiscussions(
|
||||||
|
projectId: string,
|
||||||
|
mergeRequestIid: number,
|
||||||
|
options: PaginationOptions = {}
|
||||||
|
): Promise<PaginatedDiscussionsResponse> {
|
||||||
|
return listDiscussions(projectId, "merge_requests", mergeRequestIid, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List discussions for an issue
|
||||||
|
*
|
||||||
|
* @param {string} projectId - The ID or URL-encoded path of the project
|
||||||
|
* @param {number} issueIid - The internal ID of the project issue
|
||||||
|
* @param {DiscussionPaginationOptions} options - Pagination and sorting options
|
||||||
|
* @returns {Promise<GitLabDiscussion[]>} List of issue discussions
|
||||||
|
*/
|
||||||
|
async function listIssueDiscussions(
|
||||||
|
projectId: string,
|
||||||
|
issueIid: number,
|
||||||
|
options: PaginationOptions = {}
|
||||||
|
): Promise<PaginatedDiscussionsResponse> {
|
||||||
|
return listDiscussions(projectId, "issues", issueIid, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1804,6 +1953,60 @@ async function getMergeRequestDiffs(
|
|||||||
return z.array(GitLabDiffSchema).parse(data.changes);
|
return z.array(GitLabDiffSchema).parse(data.changes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get merge request changes with detailed information including commits, diff_refs, and more
|
||||||
|
* 마지막으로 추가된 상세한 MR 변경사항 조회 함수 (Detailed merge request changes retrieval function)
|
||||||
|
*
|
||||||
|
* @param {string} projectId - The ID or URL-encoded path of the project
|
||||||
|
* @param {number} mergeRequestIid - The internal ID of the merge request (Either mergeRequestIid or branchName must be provided)
|
||||||
|
* @param {string} [branchName] - The name of the branch to search for merge request by branch name (Either mergeRequestIid or branchName must be provided)
|
||||||
|
* @param {boolean} [unidiff] - Return diff in unidiff format
|
||||||
|
* @returns {Promise<any>} The complete merge request changes response
|
||||||
|
*/
|
||||||
|
async function listMergeRequestDiffs(
|
||||||
|
projectId: string,
|
||||||
|
mergeRequestIid?: number,
|
||||||
|
branchName?: string,
|
||||||
|
page?: number,
|
||||||
|
perPage?: number,
|
||||||
|
unidiff?: boolean
|
||||||
|
): Promise<any> {
|
||||||
|
projectId = decodeURIComponent(projectId); // Decode project ID
|
||||||
|
if (!mergeRequestIid && !branchName) {
|
||||||
|
throw new Error("Either mergeRequestIid or branchName must be provided");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (branchName && !mergeRequestIid) {
|
||||||
|
const mergeRequest = await getMergeRequest(projectId, undefined, branchName);
|
||||||
|
mergeRequestIid = mergeRequest.iid;
|
||||||
|
}
|
||||||
|
|
||||||
|
const url = new URL(
|
||||||
|
`${GITLAB_API_URL}/projects/${encodeURIComponent(
|
||||||
|
projectId
|
||||||
|
)}/merge_requests/${mergeRequestIid}/diffs`
|
||||||
|
);
|
||||||
|
|
||||||
|
if (page) {
|
||||||
|
url.searchParams.append("page", page.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (perPage) {
|
||||||
|
url.searchParams.append("per_page", perPage.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (unidiff) {
|
||||||
|
url.searchParams.append("unidiff", "true");
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await fetch(url.toString(), {
|
||||||
|
...DEFAULT_FETCH_CONFIG,
|
||||||
|
});
|
||||||
|
|
||||||
|
await handleGitLabError(response);
|
||||||
|
return await response.json(); // Return full response including commits, diff_refs, changes, etc.
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get branch comparison diffs
|
* Get branch comparison diffs
|
||||||
*
|
*
|
||||||
@ -1820,14 +2023,14 @@ async function getBranchDiffs(
|
|||||||
straight?: boolean
|
straight?: boolean
|
||||||
): Promise<GitLabCompareResult> {
|
): Promise<GitLabCompareResult> {
|
||||||
projectId = decodeURIComponent(projectId); // Decode project ID
|
projectId = decodeURIComponent(projectId); // Decode project ID
|
||||||
|
|
||||||
const url = new URL(
|
const url = new URL(
|
||||||
`${GITLAB_API_URL}/projects/${encodeURIComponent(projectId)}/repository/compare`
|
`${GITLAB_API_URL}/projects/${encodeURIComponent(projectId)}/repository/compare`
|
||||||
);
|
);
|
||||||
|
|
||||||
url.searchParams.append("from", from);
|
url.searchParams.append("from", from);
|
||||||
url.searchParams.append("to", to);
|
url.searchParams.append("to", to);
|
||||||
|
|
||||||
if (straight !== undefined) {
|
if (straight !== undefined) {
|
||||||
url.searchParams.append("straight", straight.toString());
|
url.searchParams.append("straight", straight.toString());
|
||||||
}
|
}
|
||||||
@ -1838,9 +2041,7 @@ async function getBranchDiffs(
|
|||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
const errorBody = await response.text();
|
const errorBody = await response.text();
|
||||||
throw new Error(
|
throw new Error(`GitLab API error: ${response.status} ${response.statusText}\n${errorBody}`);
|
||||||
`GitLab API error: ${response.status} ${response.statusText}\n${errorBody}`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
@ -2363,12 +2564,14 @@ async function listGroupProjects(
|
|||||||
*/
|
*/
|
||||||
async function listWikiPages(
|
async function listWikiPages(
|
||||||
projectId: string,
|
projectId: string,
|
||||||
options: Omit<z.infer<typeof ListWikiPagesSchema>, "project_id"> = {}
|
options: Omit<ListWikiPagesOptions, "project_id"> = {}
|
||||||
): Promise<GitLabWikiPage[]> {
|
): Promise<GitLabWikiPage[]> {
|
||||||
projectId = decodeURIComponent(projectId); // Decode project ID
|
projectId = decodeURIComponent(projectId); // Decode project ID
|
||||||
const url = new URL(`${GITLAB_API_URL}/projects/${encodeURIComponent(projectId)}/wikis`);
|
const url = new URL(`${GITLAB_API_URL}/projects/${encodeURIComponent(projectId)}/wikis`);
|
||||||
if (options.page) url.searchParams.append("page", options.page.toString());
|
if (options.page) url.searchParams.append("page", options.page.toString());
|
||||||
if (options.per_page) url.searchParams.append("per_page", options.per_page.toString());
|
if (options.per_page) url.searchParams.append("per_page", options.per_page.toString());
|
||||||
|
if (options.with_content)
|
||||||
|
url.searchParams.append("with_content", options.with_content.toString());
|
||||||
const response = await fetch(url.toString(), {
|
const response = await fetch(url.toString(), {
|
||||||
...DEFAULT_FETCH_CONFIG,
|
...DEFAULT_FETCH_CONFIG,
|
||||||
});
|
});
|
||||||
@ -2578,9 +2781,11 @@ async function getPipelineJob(projectId: string, jobId: number): Promise<GitLabP
|
|||||||
*
|
*
|
||||||
* @param {string} projectId - The ID or URL-encoded path of the project
|
* @param {string} projectId - The ID or URL-encoded path of the project
|
||||||
* @param {number} jobId - The ID of the job
|
* @param {number} jobId - The ID of the job
|
||||||
|
* @param {number} limit - Maximum number of lines to return from the end (default: 1000)
|
||||||
|
* @param {number} offset - Number of lines to skip from the end (default: 0)
|
||||||
* @returns {Promise<string>} The job output/trace
|
* @returns {Promise<string>} The job output/trace
|
||||||
*/
|
*/
|
||||||
async function getPipelineJobOutput(projectId: string, jobId: number): Promise<string> {
|
async function getPipelineJobOutput(projectId: string, jobId: number, limit?: number, offset?: number): Promise<string> {
|
||||||
projectId = decodeURIComponent(projectId); // Decode project ID
|
projectId = decodeURIComponent(projectId); // Decode project ID
|
||||||
const url = new URL(
|
const url = new URL(
|
||||||
`${GITLAB_API_URL}/projects/${encodeURIComponent(projectId)}/jobs/${jobId}/trace`
|
`${GITLAB_API_URL}/projects/${encodeURIComponent(projectId)}/jobs/${jobId}/trace`
|
||||||
@ -2599,7 +2804,35 @@ async function getPipelineJobOutput(projectId: string, jobId: number): Promise<s
|
|||||||
}
|
}
|
||||||
|
|
||||||
await handleGitLabError(response);
|
await handleGitLabError(response);
|
||||||
return await response.text();
|
const fullTrace = await response.text();
|
||||||
|
|
||||||
|
// Apply client-side pagination to limit context window usage
|
||||||
|
if (limit !== undefined || offset !== undefined) {
|
||||||
|
const lines = fullTrace.split('\n');
|
||||||
|
const startOffset = offset || 0;
|
||||||
|
const maxLines = limit || 1000;
|
||||||
|
|
||||||
|
// Return lines from the end, skipping offset lines and limiting to maxLines
|
||||||
|
const startIndex = Math.max(0, lines.length - startOffset - maxLines);
|
||||||
|
const endIndex = lines.length - startOffset;
|
||||||
|
|
||||||
|
const selectedLines = lines.slice(startIndex, endIndex);
|
||||||
|
const result = selectedLines.join('\n');
|
||||||
|
|
||||||
|
// Add metadata about truncation
|
||||||
|
if (startIndex > 0 || endIndex < lines.length) {
|
||||||
|
const totalLines = lines.length;
|
||||||
|
const shownLines = selectedLines.length;
|
||||||
|
const skippedFromStart = startIndex;
|
||||||
|
const skippedFromEnd = startOffset;
|
||||||
|
|
||||||
|
return `[Log truncated: showing ${shownLines} of ${totalLines} lines, skipped ${skippedFromStart} from start, ${skippedFromEnd} from end]\n\n${result}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
return fullTrace;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2620,10 +2853,13 @@ async function createPipeline(
|
|||||||
|
|
||||||
const body: any = { ref };
|
const body: any = { ref };
|
||||||
if (variables && variables.length > 0) {
|
if (variables && variables.length > 0) {
|
||||||
body.variables = variables.reduce((acc, { key, value }) => {
|
body.variables = variables.reduce(
|
||||||
acc[key] = value;
|
(acc, { key, value }) => {
|
||||||
return acc;
|
acc[key] = value;
|
||||||
}, {} as Record<string, string>);
|
return acc;
|
||||||
|
},
|
||||||
|
{} as Record<string, string>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const response = await fetch(url.toString(), {
|
const response = await fetch(url.toString(), {
|
||||||
@ -2699,15 +2935,20 @@ async function getRepositoryTree(options: GetRepositoryTreeOptions): Promise<Git
|
|||||||
if (options.page_token) queryParams.append("page_token", options.page_token);
|
if (options.page_token) queryParams.append("page_token", options.page_token);
|
||||||
if (options.pagination) queryParams.append("pagination", options.pagination);
|
if (options.pagination) queryParams.append("pagination", options.pagination);
|
||||||
|
|
||||||
|
const headers: Record<string, string> = {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
};
|
||||||
|
if (IS_OLD) {
|
||||||
|
headers["Private-Token"] = `${GITLAB_PERSONAL_ACCESS_TOKEN}`;
|
||||||
|
} else {
|
||||||
|
headers["Authorization"] = `Bearer ${GITLAB_PERSONAL_ACCESS_TOKEN}`;
|
||||||
|
}
|
||||||
const response = await fetch(
|
const response = await fetch(
|
||||||
`${GITLAB_API_URL}/projects/${encodeURIComponent(
|
`${GITLAB_API_URL}/projects/${encodeURIComponent(
|
||||||
options.project_id
|
options.project_id
|
||||||
)}/repository/tree?${queryParams.toString()}`,
|
)}/repository/tree?${queryParams.toString()}`,
|
||||||
{
|
{
|
||||||
headers: {
|
headers,
|
||||||
Authorization: `Bearer ${GITLAB_PERSONAL_ACCESS_TOKEN}`,
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -2955,9 +3196,9 @@ async function getUser(username: string): Promise<GitLabUser | null> {
|
|||||||
});
|
});
|
||||||
|
|
||||||
await handleGitLabError(response);
|
await handleGitLabError(response);
|
||||||
|
|
||||||
const users = await response.json();
|
const users = await response.json();
|
||||||
|
|
||||||
// GitLab returns an array of users that match the username
|
// GitLab returns an array of users that match the username
|
||||||
if (Array.isArray(users) && users.length > 0) {
|
if (Array.isArray(users) && users.length > 0) {
|
||||||
// Find exact match for username (case-sensitive)
|
// Find exact match for username (case-sensitive)
|
||||||
@ -2966,7 +3207,7 @@ async function getUser(username: string): Promise<GitLabUser | null> {
|
|||||||
return GitLabUserSchema.parse(exactMatch);
|
return GitLabUserSchema.parse(exactMatch);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// No matching user found
|
// No matching user found
|
||||||
return null;
|
return null;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -2977,13 +3218,13 @@ async function getUser(username: string): Promise<GitLabUser | null> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get multiple users from GitLab
|
* Get multiple users from GitLab
|
||||||
*
|
*
|
||||||
* @param {string[]} usernames - Array of usernames to look up
|
* @param {string[]} usernames - Array of usernames to look up
|
||||||
* @returns {Promise<GitLabUsersResponse>} Object with usernames as keys and user objects or null as values
|
* @returns {Promise<GitLabUsersResponse>} Object with usernames as keys and user objects or null as values
|
||||||
*/
|
*/
|
||||||
async function getUsers(usernames: string[]): Promise<GitLabUsersResponse> {
|
async function getUsers(usernames: string[]): Promise<GitLabUsersResponse> {
|
||||||
const users: Record<string, GitLabUser | null> = {};
|
const users: Record<string, GitLabUser | null> = {};
|
||||||
|
|
||||||
// Process usernames sequentially to avoid rate limiting
|
// Process usernames sequentially to avoid rate limiting
|
||||||
for (const username of usernames) {
|
for (const username of usernames) {
|
||||||
try {
|
try {
|
||||||
@ -2998,6 +3239,107 @@ async function getUsers(usernames: string[]): Promise<GitLabUsersResponse> {
|
|||||||
return GitLabUsersResponseSchema.parse(users);
|
return GitLabUsersResponseSchema.parse(users);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List repository commits
|
||||||
|
* 저장소 커밋 목록 조회
|
||||||
|
*
|
||||||
|
* @param {string} projectId - Project ID or URL-encoded path
|
||||||
|
* @param {ListCommitsOptions} options - List commits options
|
||||||
|
* @returns {Promise<GitLabCommit[]>} List of commits
|
||||||
|
*/
|
||||||
|
async function listCommits(
|
||||||
|
projectId: string,
|
||||||
|
options: Omit<ListCommitsOptions, "project_id"> = {}
|
||||||
|
): Promise<GitLabCommit[]> {
|
||||||
|
projectId = decodeURIComponent(projectId);
|
||||||
|
const url = new URL(
|
||||||
|
`${GITLAB_API_URL}/projects/${encodeURIComponent(projectId)}/repository/commits`
|
||||||
|
);
|
||||||
|
|
||||||
|
// Add query parameters
|
||||||
|
if (options.ref_name) url.searchParams.append("ref_name", options.ref_name);
|
||||||
|
if (options.since) url.searchParams.append("since", options.since);
|
||||||
|
if (options.until) url.searchParams.append("until", options.until);
|
||||||
|
if (options.path) url.searchParams.append("path", options.path);
|
||||||
|
if (options.author) url.searchParams.append("author", options.author);
|
||||||
|
if (options.all) url.searchParams.append("all", options.all.toString());
|
||||||
|
if (options.with_stats) url.searchParams.append("with_stats", options.with_stats.toString());
|
||||||
|
if (options.first_parent) url.searchParams.append("first_parent", options.first_parent.toString());
|
||||||
|
if (options.order) url.searchParams.append("order", options.order);
|
||||||
|
if (options.trailers) url.searchParams.append("trailers", options.trailers.toString());
|
||||||
|
if (options.page) url.searchParams.append("page", options.page.toString());
|
||||||
|
if (options.per_page) url.searchParams.append("per_page", options.per_page.toString());
|
||||||
|
|
||||||
|
const response = await fetch(url.toString(), {
|
||||||
|
...DEFAULT_FETCH_CONFIG,
|
||||||
|
});
|
||||||
|
|
||||||
|
await handleGitLabError(response);
|
||||||
|
|
||||||
|
const data = await response.json();
|
||||||
|
return z.array(GitLabCommitSchema).parse(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a single commit
|
||||||
|
* 단일 커밋 정보 조회
|
||||||
|
*
|
||||||
|
* @param {string} projectId - Project ID or URL-encoded path
|
||||||
|
* @param {string} sha - The commit hash or name of a repository branch or tag
|
||||||
|
* @param {boolean} [stats] - Include commit stats
|
||||||
|
* @returns {Promise<GitLabCommit>} The commit details
|
||||||
|
*/
|
||||||
|
async function getCommit(
|
||||||
|
projectId: string,
|
||||||
|
sha: string,
|
||||||
|
stats?: boolean
|
||||||
|
): Promise<GitLabCommit> {
|
||||||
|
projectId = decodeURIComponent(projectId);
|
||||||
|
const url = new URL(
|
||||||
|
`${GITLAB_API_URL}/projects/${encodeURIComponent(projectId)}/repository/commits/${encodeURIComponent(sha)}`
|
||||||
|
);
|
||||||
|
|
||||||
|
if (stats) {
|
||||||
|
url.searchParams.append("stats", "true");
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await fetch(url.toString(), {
|
||||||
|
...DEFAULT_FETCH_CONFIG,
|
||||||
|
});
|
||||||
|
|
||||||
|
await handleGitLabError(response);
|
||||||
|
|
||||||
|
const data = await response.json();
|
||||||
|
return GitLabCommitSchema.parse(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get commit diff
|
||||||
|
* 커밋 변경사항 조회
|
||||||
|
*
|
||||||
|
* @param {string} projectId - Project ID or URL-encoded path
|
||||||
|
* @param {string} sha - The commit hash or name of a repository branch or tag
|
||||||
|
* @returns {Promise<GitLabMergeRequestDiff[]>} The commit diffs
|
||||||
|
*/
|
||||||
|
async function getCommitDiff(
|
||||||
|
projectId: string,
|
||||||
|
sha: string
|
||||||
|
): Promise<GitLabMergeRequestDiff[]> {
|
||||||
|
projectId = decodeURIComponent(projectId);
|
||||||
|
const url = new URL(
|
||||||
|
`${GITLAB_API_URL}/projects/${encodeURIComponent(projectId)}/repository/commits/${encodeURIComponent(sha)}/diff`
|
||||||
|
);
|
||||||
|
|
||||||
|
const response = await fetch(url.toString(), {
|
||||||
|
...DEFAULT_FETCH_CONFIG,
|
||||||
|
});
|
||||||
|
|
||||||
|
await handleGitLabError(response);
|
||||||
|
|
||||||
|
const data = await response.json();
|
||||||
|
return z.array(GitLabDiffSchema).parse(data);
|
||||||
|
}
|
||||||
|
|
||||||
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
||||||
// Apply read-only filter first
|
// Apply read-only filter first
|
||||||
const tools0 = GITLAB_READ_ONLY_MODE
|
const tools0 = GITLAB_READ_ONLY_MODE
|
||||||
@ -3012,9 +3354,7 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|||||||
? tools1
|
? tools1
|
||||||
: tools1.filter(tool => !milestoneToolNames.includes(tool.name));
|
: tools1.filter(tool => !milestoneToolNames.includes(tool.name));
|
||||||
// Toggle pipeline tools by USE_PIPELINE flag
|
// Toggle pipeline tools by USE_PIPELINE flag
|
||||||
let tools = USE_PIPELINE
|
let tools = USE_PIPELINE ? tools2 : tools2.filter(tool => !pipelineToolNames.includes(tool.name));
|
||||||
? tools2
|
|
||||||
: tools2.filter(tool => !pipelineToolNames.includes(tool.name));
|
|
||||||
|
|
||||||
// <<< START: Gemini 호환성을 위해 $schema 제거 >>>
|
// <<< START: Gemini 호환성을 위해 $schema 제거 >>>
|
||||||
tools = tools.map(tool => {
|
tools = tools.map(tool => {
|
||||||
@ -3043,6 +3383,11 @@ server.setRequestHandler(CallToolRequestSchema, async request => {
|
|||||||
if (!request.params.arguments) {
|
if (!request.params.arguments) {
|
||||||
throw new Error("Arguments are required");
|
throw new Error("Arguments are required");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ensure session is established for every request if cookie authentication is enabled
|
||||||
|
if (GITLAB_AUTH_COOKIE_PATH) {
|
||||||
|
await ensureSessionForRequest();
|
||||||
|
}
|
||||||
|
|
||||||
switch (request.params.name) {
|
switch (request.params.name) {
|
||||||
case "fork_repository": {
|
case "fork_repository": {
|
||||||
@ -3088,26 +3433,19 @@ server.setRequestHandler(CallToolRequestSchema, async request => {
|
|||||||
|
|
||||||
case "get_branch_diffs": {
|
case "get_branch_diffs": {
|
||||||
const args = GetBranchDiffsSchema.parse(request.params.arguments);
|
const args = GetBranchDiffsSchema.parse(request.params.arguments);
|
||||||
const diffResp = await getBranchDiffs(
|
const diffResp = await getBranchDiffs(args.project_id, args.from, args.to, args.straight);
|
||||||
args.project_id,
|
|
||||||
args.from,
|
|
||||||
args.to,
|
|
||||||
args.straight
|
|
||||||
);
|
|
||||||
|
|
||||||
if (args.excluded_file_patterns?.length) {
|
if (args.excluded_file_patterns?.length) {
|
||||||
const regexPatterns = args.excluded_file_patterns.map(pattern => new RegExp(pattern));
|
const regexPatterns = args.excluded_file_patterns.map(pattern => new RegExp(pattern));
|
||||||
|
|
||||||
// Helper function to check if a path matches any regex pattern
|
// Helper function to check if a path matches any regex pattern
|
||||||
const matchesAnyPattern = (path: string): boolean => {
|
const matchesAnyPattern = (path: string): boolean => {
|
||||||
if (!path) return false;
|
if (!path) return false;
|
||||||
return regexPatterns.some(regex => regex.test(path));
|
return regexPatterns.some(regex => regex.test(path));
|
||||||
};
|
};
|
||||||
|
|
||||||
// Filter out files that match any of the regex patterns on new files
|
// Filter out files that match any of the regex patterns on new files
|
||||||
diffResp.diffs = diffResp.diffs.filter(diff =>
|
diffResp.diffs = diffResp.diffs.filter(diff => !matchesAnyPattern(diff.new_path));
|
||||||
!matchesAnyPattern(diff.new_path)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
content: [{ type: "text", text: JSON.stringify(diffResp, null, 2) }],
|
content: [{ type: "text", text: JSON.stringify(diffResp, null, 2) }],
|
||||||
@ -3268,6 +3606,21 @@ server.setRequestHandler(CallToolRequestSchema, async request => {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case "list_merge_request_diffs": {
|
||||||
|
const args = ListMergeRequestDiffsSchema.parse(request.params.arguments);
|
||||||
|
const changes = await listMergeRequestDiffs(
|
||||||
|
args.project_id,
|
||||||
|
args.merge_request_iid,
|
||||||
|
args.source_branch,
|
||||||
|
args.page,
|
||||||
|
args.per_page,
|
||||||
|
args.unidiff
|
||||||
|
);
|
||||||
|
return {
|
||||||
|
content: [{ type: "text", text: JSON.stringify(changes, null, 2) }],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
case "update_merge_request": {
|
case "update_merge_request": {
|
||||||
const args = UpdateMergeRequestSchema.parse(request.params.arguments);
|
const args = UpdateMergeRequestSchema.parse(request.params.arguments);
|
||||||
const { project_id, merge_request_iid, source_branch, ...options } = args;
|
const { project_id, merge_request_iid, source_branch, ...options } = args;
|
||||||
@ -3284,9 +3637,11 @@ server.setRequestHandler(CallToolRequestSchema, async request => {
|
|||||||
|
|
||||||
case "mr_discussions": {
|
case "mr_discussions": {
|
||||||
const args = ListMergeRequestDiscussionsSchema.parse(request.params.arguments);
|
const args = ListMergeRequestDiscussionsSchema.parse(request.params.arguments);
|
||||||
|
const { project_id, merge_request_iid, ...options } = args;
|
||||||
const discussions = await listMergeRequestDiscussions(
|
const discussions = await listMergeRequestDiscussions(
|
||||||
args.project_id,
|
project_id,
|
||||||
args.merge_request_iid
|
merge_request_iid,
|
||||||
|
options
|
||||||
);
|
);
|
||||||
return {
|
return {
|
||||||
content: [{ type: "text", text: JSON.stringify(discussions, null, 2) }],
|
content: [{ type: "text", text: JSON.stringify(discussions, null, 2) }],
|
||||||
@ -3384,11 +3739,11 @@ server.setRequestHandler(CallToolRequestSchema, async request => {
|
|||||||
content: [{ type: "text", text: JSON.stringify(projects, null, 2) }],
|
content: [{ type: "text", text: JSON.stringify(projects, null, 2) }],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
case "get_users": {
|
case "get_users": {
|
||||||
const args = GetUsersSchema.parse(request.params.arguments);
|
const args = GetUsersSchema.parse(request.params.arguments);
|
||||||
const usersMap = await getUsers(args.usernames);
|
const usersMap = await getUsers(args.usernames);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
content: [{ type: "text", text: JSON.stringify(usersMap, null, 2) }],
|
content: [{ type: "text", text: JSON.stringify(usersMap, null, 2) }],
|
||||||
};
|
};
|
||||||
@ -3582,8 +3937,10 @@ server.setRequestHandler(CallToolRequestSchema, async request => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case "list_wiki_pages": {
|
case "list_wiki_pages": {
|
||||||
const { project_id, page, per_page } = ListWikiPagesSchema.parse(request.params.arguments);
|
const { project_id, page, per_page, with_content } = ListWikiPagesSchema.parse(
|
||||||
const wikiPages = await listWikiPages(project_id, { page, per_page });
|
request.params.arguments
|
||||||
|
);
|
||||||
|
const wikiPages = await listWikiPages(project_id, { page, per_page, with_content });
|
||||||
return {
|
return {
|
||||||
content: [{ type: "text", text: JSON.stringify(wikiPages, null, 2) }],
|
content: [{ type: "text", text: JSON.stringify(wikiPages, null, 2) }],
|
||||||
};
|
};
|
||||||
@ -3696,8 +4053,8 @@ server.setRequestHandler(CallToolRequestSchema, async request => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case "get_pipeline_job_output": {
|
case "get_pipeline_job_output": {
|
||||||
const { project_id, job_id } = GetPipelineJobOutputSchema.parse(request.params.arguments);
|
const { project_id, job_id, limit, offset } = GetPipelineJobOutputSchema.parse(request.params.arguments);
|
||||||
const jobOutput = await getPipelineJobOutput(project_id, job_id);
|
const jobOutput = await getPipelineJobOutput(project_id, job_id, limit, offset);
|
||||||
return {
|
return {
|
||||||
content: [
|
content: [
|
||||||
{
|
{
|
||||||
@ -3897,6 +4254,30 @@ server.setRequestHandler(CallToolRequestSchema, async request => {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case "list_commits": {
|
||||||
|
const args = ListCommitsSchema.parse(request.params.arguments);
|
||||||
|
const commits = await listCommits(args.project_id, args);
|
||||||
|
return {
|
||||||
|
content: [{ type: "text", text: JSON.stringify(commits, null, 2) }],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
case "get_commit": {
|
||||||
|
const args = GetCommitSchema.parse(request.params.arguments);
|
||||||
|
const commit = await getCommit(args.project_id, args.sha, args.stats);
|
||||||
|
return {
|
||||||
|
content: [{ type: "text", text: JSON.stringify(commit, null, 2) }],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
case "get_commit_diff": {
|
||||||
|
const args = GetCommitDiffSchema.parse(request.params.arguments);
|
||||||
|
const diff = await getCommitDiff(args.project_id, args.sha);
|
||||||
|
return {
|
||||||
|
content: [{ type: "text", text: JSON.stringify(diff, null, 2) }],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new Error(`Unknown tool: ${request.params.name}`);
|
throw new Error(`Unknown tool: ${request.params.name}`);
|
||||||
}
|
}
|
||||||
@ -3918,14 +4299,13 @@ server.setRequestHandler(CallToolRequestSchema, async request => {
|
|||||||
*/
|
*/
|
||||||
async function runServer() {
|
async function runServer() {
|
||||||
try {
|
try {
|
||||||
console.error("========================");
|
// Server startup banner removed - inappropriate use of console.error for logging
|
||||||
console.error(`GitLab MCP Server v${SERVER_VERSION}`);
|
// Server version banner removed - inappropriate use of console.error for logging
|
||||||
console.error(`API URL: ${GITLAB_API_URL}`);
|
// API URL banner removed - inappropriate use of console.error for logging
|
||||||
console.error("========================");
|
// Server startup banner removed - inappropriate use of console.error for logging
|
||||||
if ( !SSE )
|
if (!SSE) {
|
||||||
{
|
|
||||||
const transport = new StdioServerTransport();
|
const transport = new StdioServerTransport();
|
||||||
await server.connect(transport);
|
await server.connect(transport);
|
||||||
} else {
|
} else {
|
||||||
const app = express();
|
const app = express();
|
||||||
const transports: { [sessionId: string]: SSEServerTransport } = {};
|
const transports: { [sessionId: string]: SSEServerTransport } = {};
|
||||||
@ -3937,7 +4317,7 @@ async function runServer() {
|
|||||||
});
|
});
|
||||||
await server.connect(transport);
|
await server.connect(transport);
|
||||||
});
|
});
|
||||||
|
|
||||||
app.post("/messages", async (req: Request, res: Response) => {
|
app.post("/messages", async (req: Request, res: Response) => {
|
||||||
const sessionId = req.query.sessionId as string;
|
const sessionId = req.query.sessionId as string;
|
||||||
const transport = transports[sessionId];
|
const transport = transports[sessionId];
|
||||||
@ -3947,13 +4327,12 @@ async function runServer() {
|
|||||||
res.status(400).send("No transport found for sessionId");
|
res.status(400).send("No transport found for sessionId");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const PORT = process.env.PORT || 3002;
|
const PORT = process.env.PORT || 3002;
|
||||||
app.listen(PORT, () => {
|
app.listen(PORT, () => {
|
||||||
console.log(`Server is running on port ${PORT}`);
|
console.log(`Server is running on port ${PORT}`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
console.error("GitLab MCP Server running on stdio");
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error initializing server:", error);
|
console.error("Error initializing server:", error);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
|
249
package-lock.json
generated
249
package-lock.json
generated
@ -1,22 +1,24 @@
|
|||||||
{
|
{
|
||||||
"name": "@zereight/mcp-gitlab",
|
"name": "@zereight/mcp-gitlab",
|
||||||
"version": "1.0.56",
|
"version": "1.0.64",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@zereight/mcp-gitlab",
|
"name": "@zereight/mcp-gitlab",
|
||||||
"version": "1.0.56",
|
"version": "1.0.64",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@modelcontextprotocol/sdk": "1.8.0",
|
"@modelcontextprotocol/sdk": "1.8.0",
|
||||||
"@types/node-fetch": "^2.6.12",
|
"@types/node-fetch": "^2.6.12",
|
||||||
"express": "^5.1.0",
|
"express": "^5.1.0",
|
||||||
|
"fetch-cookie": "^3.1.0",
|
||||||
"form-data": "^4.0.0",
|
"form-data": "^4.0.0",
|
||||||
"http-proxy-agent": "^7.0.2",
|
"http-proxy-agent": "^7.0.2",
|
||||||
"https-proxy-agent": "^7.0.6",
|
"https-proxy-agent": "^7.0.6",
|
||||||
"node-fetch": "^3.3.2",
|
"node-fetch": "^3.3.2",
|
||||||
"socks-proxy-agent": "^8.0.5",
|
"socks-proxy-agent": "^8.0.5",
|
||||||
|
"tough-cookie": "^5.1.2",
|
||||||
"zod-to-json-schema": "^3.23.5"
|
"zod-to-json-schema": "^3.23.5"
|
||||||
},
|
},
|
||||||
"bin": {
|
"bin": {
|
||||||
@ -27,6 +29,7 @@
|
|||||||
"@types/node": "^22.13.10",
|
"@types/node": "^22.13.10",
|
||||||
"@typescript-eslint/eslint-plugin": "^8.21.0",
|
"@typescript-eslint/eslint-plugin": "^8.21.0",
|
||||||
"@typescript-eslint/parser": "^8.21.0",
|
"@typescript-eslint/parser": "^8.21.0",
|
||||||
|
"auto-changelog": "^2.4.0",
|
||||||
"eslint": "^9.18.0",
|
"eslint": "^9.18.0",
|
||||||
"prettier": "^3.4.2",
|
"prettier": "^3.4.2",
|
||||||
"ts-node": "^10.9.2",
|
"ts-node": "^10.9.2",
|
||||||
@ -889,6 +892,48 @@
|
|||||||
"integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==",
|
"integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
|
"node_modules/auto-changelog": {
|
||||||
|
"version": "2.5.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/auto-changelog/-/auto-changelog-2.5.0.tgz",
|
||||||
|
"integrity": "sha512-UTnLjT7I9U2U/xkCUH5buDlp8C7g0SGChfib+iDrJkamcj5kaMqNKHNfbKJw1kthJUq8sUo3i3q2S6FzO/l/wA==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"commander": "^7.2.0",
|
||||||
|
"handlebars": "^4.7.7",
|
||||||
|
"import-cwd": "^3.0.0",
|
||||||
|
"node-fetch": "^2.6.1",
|
||||||
|
"parse-github-url": "^1.0.3",
|
||||||
|
"semver": "^7.3.5"
|
||||||
|
},
|
||||||
|
"bin": {
|
||||||
|
"auto-changelog": "src/index.js"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8.3"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/auto-changelog/node_modules/node-fetch": {
|
||||||
|
"version": "2.7.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz",
|
||||||
|
"integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"whatwg-url": "^5.0.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "4.x || >=6.0.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"encoding": "^0.1.0"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"encoding": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/balanced-match": {
|
"node_modules/balanced-match": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
|
||||||
@ -1036,6 +1081,16 @@
|
|||||||
"node": ">= 0.8"
|
"node": ">= 0.8"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/commander": {
|
||||||
|
"version": "7.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/commander/-/commander-7.2.0.tgz",
|
||||||
|
"integrity": "sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 10"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/concat-map": {
|
"node_modules/concat-map": {
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
|
||||||
@ -1656,6 +1711,16 @@
|
|||||||
"node": "^12.20 || >= 14.13"
|
"node": "^12.20 || >= 14.13"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/fetch-cookie": {
|
||||||
|
"version": "3.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/fetch-cookie/-/fetch-cookie-3.1.0.tgz",
|
||||||
|
"integrity": "sha512-s/XhhreJpqH0ftkGVcQt8JE9bqk+zRn4jF5mPJXWZeQMCI5odV9K+wEWYbnzFPHgQZlvPSMjS4n4yawWE8RINw==",
|
||||||
|
"license": "Unlicense",
|
||||||
|
"dependencies": {
|
||||||
|
"set-cookie-parser": "^2.4.8",
|
||||||
|
"tough-cookie": "^5.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/file-entry-cache": {
|
"node_modules/file-entry-cache": {
|
||||||
"version": "8.0.0",
|
"version": "8.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-8.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-8.0.0.tgz",
|
||||||
@ -1894,6 +1959,28 @@
|
|||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
|
"node_modules/handlebars": {
|
||||||
|
"version": "4.7.8",
|
||||||
|
"resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.7.8.tgz",
|
||||||
|
"integrity": "sha512-vafaFqs8MZkRrSX7sFVUdo3ap/eNiLnb4IakshzvP56X5Nr1iGKAIqdX6tMlm6HcNRIkr6AxO5jFEoJzzpT8aQ==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"minimist": "^1.2.5",
|
||||||
|
"neo-async": "^2.6.2",
|
||||||
|
"source-map": "^0.6.1",
|
||||||
|
"wordwrap": "^1.0.0"
|
||||||
|
},
|
||||||
|
"bin": {
|
||||||
|
"handlebars": "bin/handlebars"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.4.7"
|
||||||
|
},
|
||||||
|
"optionalDependencies": {
|
||||||
|
"uglify-js": "^3.1.4"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/has-flag": {
|
"node_modules/has-flag": {
|
||||||
"version": "4.0.0",
|
"version": "4.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
|
||||||
@ -2007,6 +2094,19 @@
|
|||||||
"node": ">= 4"
|
"node": ">= 4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/import-cwd": {
|
||||||
|
"version": "3.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/import-cwd/-/import-cwd-3.0.0.tgz",
|
||||||
|
"integrity": "sha512-4pnzH16plW+hgvRECbDWpQl3cqtvSofHWh44met7ESfZ8UZOWWddm8hEyDTqREJ9RbYHY8gi8DqmaelApoOGMg==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"import-from": "^3.0.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/import-fresh": {
|
"node_modules/import-fresh": {
|
||||||
"version": "3.3.1",
|
"version": "3.3.1",
|
||||||
"resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.1.tgz",
|
"resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.1.tgz",
|
||||||
@ -2024,6 +2124,29 @@
|
|||||||
"url": "https://github.com/sponsors/sindresorhus"
|
"url": "https://github.com/sponsors/sindresorhus"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/import-from": {
|
||||||
|
"version": "3.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/import-from/-/import-from-3.0.0.tgz",
|
||||||
|
"integrity": "sha512-CiuXOFFSzkU5x/CR0+z7T91Iht4CXgfCxVOFRhh2Zyhg5wOpWvvDLQUsWl+gcN+QscYBjez8hDCt85O7RLDttQ==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"resolve-from": "^5.0.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/import-from/node_modules/resolve-from": {
|
||||||
|
"version": "5.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz",
|
||||||
|
"integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/imurmurhash": {
|
"node_modules/imurmurhash": {
|
||||||
"version": "0.1.4",
|
"version": "0.1.4",
|
||||||
"resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz",
|
"resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz",
|
||||||
@ -2292,6 +2415,16 @@
|
|||||||
"url": "https://github.com/sponsors/isaacs"
|
"url": "https://github.com/sponsors/isaacs"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/minimist": {
|
||||||
|
"version": "1.2.8",
|
||||||
|
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz",
|
||||||
|
"integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/ljharb"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/ms": {
|
"node_modules/ms": {
|
||||||
"version": "2.1.3",
|
"version": "2.1.3",
|
||||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
|
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
|
||||||
@ -2314,6 +2447,13 @@
|
|||||||
"node": ">= 0.6"
|
"node": ">= 0.6"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/neo-async": {
|
||||||
|
"version": "2.6.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.2.tgz",
|
||||||
|
"integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/node-domexception": {
|
"node_modules/node-domexception": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz",
|
||||||
@ -2456,6 +2596,19 @@
|
|||||||
"node": ">=6"
|
"node": ">=6"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/parse-github-url": {
|
||||||
|
"version": "1.0.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/parse-github-url/-/parse-github-url-1.0.3.tgz",
|
||||||
|
"integrity": "sha512-tfalY5/4SqGaV/GIGzWyHnFjlpTPTNpENR9Ea2lLldSJ8EWXMsvacWucqY3m3I4YPtas15IxTLQVQ5NSYXPrww==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"bin": {
|
||||||
|
"parse-github-url": "cli.js"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 0.10"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/parseurl": {
|
"node_modules/parseurl": {
|
||||||
"version": "1.3.3",
|
"version": "1.3.3",
|
||||||
"resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz",
|
"resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz",
|
||||||
@ -2761,6 +2914,12 @@
|
|||||||
"node": ">= 18"
|
"node": ">= 18"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/set-cookie-parser": {
|
||||||
|
"version": "2.7.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/set-cookie-parser/-/set-cookie-parser-2.7.1.tgz",
|
||||||
|
"integrity": "sha512-IOc8uWeOZgnb3ptbCURJWNjWUPcO3ZnTTdzsurqERrP6nPyv+paC55vJM0LpOlT2ne+Ix+9+CRG1MNLlyZ4GjQ==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/setprototypeof": {
|
"node_modules/setprototypeof": {
|
||||||
"version": "1.2.0",
|
"version": "1.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz",
|
||||||
@ -2898,6 +3057,16 @@
|
|||||||
"node": ">= 14"
|
"node": ">= 14"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/source-map": {
|
||||||
|
"version": "0.6.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
|
||||||
|
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "BSD-3-Clause",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.10.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/sprintf-js": {
|
"node_modules/sprintf-js": {
|
||||||
"version": "1.1.3",
|
"version": "1.1.3",
|
||||||
"resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.1.3.tgz",
|
"resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.1.3.tgz",
|
||||||
@ -2939,6 +3108,24 @@
|
|||||||
"node": ">=8"
|
"node": ">=8"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/tldts": {
|
||||||
|
"version": "6.1.86",
|
||||||
|
"resolved": "https://registry.npmjs.org/tldts/-/tldts-6.1.86.tgz",
|
||||||
|
"integrity": "sha512-WMi/OQ2axVTf/ykqCQgXiIct+mSQDFdH2fkwhPwgEwvJ1kSzZRiinb0zF2Xb8u4+OqPChmyI6MEu4EezNJz+FQ==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"tldts-core": "^6.1.86"
|
||||||
|
},
|
||||||
|
"bin": {
|
||||||
|
"tldts": "bin/cli.js"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/tldts-core": {
|
||||||
|
"version": "6.1.86",
|
||||||
|
"resolved": "https://registry.npmjs.org/tldts-core/-/tldts-core-6.1.86.tgz",
|
||||||
|
"integrity": "sha512-Je6p7pkk+KMzMv2XXKmAE3McmolOQFdxkKw0R8EYNr7sELW46JqnNeTX8ybPiQgvg1ymCoF8LXs5fzFaZvJPTA==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/to-regex-range": {
|
"node_modules/to-regex-range": {
|
||||||
"version": "5.0.1",
|
"version": "5.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",
|
||||||
@ -2961,6 +3148,25 @@
|
|||||||
"node": ">=0.6"
|
"node": ">=0.6"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/tough-cookie": {
|
||||||
|
"version": "5.1.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-5.1.2.tgz",
|
||||||
|
"integrity": "sha512-FVDYdxtnj0G6Qm/DhNPSb8Ju59ULcup3tuJxkFb5K8Bv2pUXILbf0xZWU8PX8Ov19OXljbUyveOFwRMwkXzO+A==",
|
||||||
|
"license": "BSD-3-Clause",
|
||||||
|
"dependencies": {
|
||||||
|
"tldts": "^6.1.32"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=16"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/tr46": {
|
||||||
|
"version": "0.0.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",
|
||||||
|
"integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/ts-api-utils": {
|
"node_modules/ts-api-utils": {
|
||||||
"version": "2.1.0",
|
"version": "2.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-2.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-2.1.0.tgz",
|
||||||
@ -3059,6 +3265,20 @@
|
|||||||
"node": ">=14.17"
|
"node": ">=14.17"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/uglify-js": {
|
||||||
|
"version": "3.19.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.19.3.tgz",
|
||||||
|
"integrity": "sha512-v3Xu+yuwBXisp6QYTcH4UbH+xYJXqnq2m/LtQVWKWzYc1iehYnLixoQDN9FH6/j9/oybfd6W9Ghwkl8+UMKTKQ==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "BSD-2-Clause",
|
||||||
|
"optional": true,
|
||||||
|
"bin": {
|
||||||
|
"uglifyjs": "bin/uglifyjs"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.8.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/undici-types": {
|
"node_modules/undici-types": {
|
||||||
"version": "6.20.0",
|
"version": "6.20.0",
|
||||||
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.20.0.tgz",
|
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.20.0.tgz",
|
||||||
@ -3109,6 +3329,24 @@
|
|||||||
"node": ">= 8"
|
"node": ">= 8"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/webidl-conversions": {
|
||||||
|
"version": "3.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
|
||||||
|
"integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "BSD-2-Clause"
|
||||||
|
},
|
||||||
|
"node_modules/whatwg-url": {
|
||||||
|
"version": "5.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz",
|
||||||
|
"integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"tr46": "~0.0.3",
|
||||||
|
"webidl-conversions": "^3.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/which": {
|
"node_modules/which": {
|
||||||
"version": "2.0.2",
|
"version": "2.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
|
||||||
@ -3134,6 +3372,13 @@
|
|||||||
"node": ">=0.10.0"
|
"node": ">=0.10.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/wordwrap": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz",
|
||||||
|
"integrity": "sha512-gvVzJFlPycKc5dZN4yPkP8w7Dc37BtP1yczEneOb4uq34pXZcvrtRTmWV8W+Ume+XCxKgbjM+nevkyFPMybd4Q==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/wrappy": {
|
"node_modules/wrappy": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@zereight/mcp-gitlab",
|
"name": "@zereight/mcp-gitlab",
|
||||||
"version": "1.0.56",
|
"version": "1.0.64",
|
||||||
"description": "MCP server for using the GitLab API",
|
"description": "MCP server for using the GitLab API",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"author": "zereight",
|
"author": "zereight",
|
||||||
@ -21,6 +21,7 @@
|
|||||||
"watch": "tsc --watch",
|
"watch": "tsc --watch",
|
||||||
"deploy": "npm publish --access public",
|
"deploy": "npm publish --access public",
|
||||||
"generate-tools": "npx ts-node scripts/generate-tools-readme.ts",
|
"generate-tools": "npx ts-node scripts/generate-tools-readme.ts",
|
||||||
|
"changelog": "auto-changelog -p",
|
||||||
"test": "node test/validate-api.js",
|
"test": "node test/validate-api.js",
|
||||||
"test:integration": "node test/validate-api.js",
|
"test:integration": "node test/validate-api.js",
|
||||||
"lint": "eslint . --ext .ts",
|
"lint": "eslint . --ext .ts",
|
||||||
@ -32,11 +33,13 @@
|
|||||||
"@modelcontextprotocol/sdk": "1.8.0",
|
"@modelcontextprotocol/sdk": "1.8.0",
|
||||||
"@types/node-fetch": "^2.6.12",
|
"@types/node-fetch": "^2.6.12",
|
||||||
"express": "^5.1.0",
|
"express": "^5.1.0",
|
||||||
|
"fetch-cookie": "^3.1.0",
|
||||||
"form-data": "^4.0.0",
|
"form-data": "^4.0.0",
|
||||||
"http-proxy-agent": "^7.0.2",
|
"http-proxy-agent": "^7.0.2",
|
||||||
"https-proxy-agent": "^7.0.6",
|
"https-proxy-agent": "^7.0.6",
|
||||||
"node-fetch": "^3.3.2",
|
"node-fetch": "^3.3.2",
|
||||||
"socks-proxy-agent": "^8.0.5",
|
"socks-proxy-agent": "^8.0.5",
|
||||||
|
"tough-cookie": "^5.1.2",
|
||||||
"zod-to-json-schema": "^3.23.5"
|
"zod-to-json-schema": "^3.23.5"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@ -48,6 +51,7 @@
|
|||||||
"prettier": "^3.4.2",
|
"prettier": "^3.4.2",
|
||||||
"ts-node": "^10.9.2",
|
"ts-node": "^10.9.2",
|
||||||
"typescript": "^5.8.2",
|
"typescript": "^5.8.2",
|
||||||
"zod": "^3.24.2"
|
"zod": "^3.24.2",
|
||||||
|
"auto-changelog": "^2.4.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
235
schemas.ts
235
schemas.ts
@ -94,6 +94,13 @@ export const GitLabPipelineJobSchema = z.object({
|
|||||||
web_url: z.string().optional(),
|
web_url: z.string().optional(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Shared base schema for various pagination options
|
||||||
|
// See https://docs.gitlab.com/api/rest/#pagination
|
||||||
|
export const PaginationOptionsSchema = z.object({
|
||||||
|
page: z.number().optional().describe("Page number for pagination (default: 1)"),
|
||||||
|
per_page: z.number().optional().describe("Number of items per page (max: 100, default: 20)"),
|
||||||
|
});
|
||||||
|
|
||||||
// Schema for listing pipelines
|
// Schema for listing pipelines
|
||||||
export const ListPipelinesSchema = z.object({
|
export const ListPipelinesSchema = z.object({
|
||||||
project_id: z.string().describe("Project ID or URL-encoded path"),
|
project_id: z.string().describe("Project ID or URL-encoded path"),
|
||||||
@ -134,9 +141,7 @@ export const ListPipelinesSchema = z.object({
|
|||||||
.optional()
|
.optional()
|
||||||
.describe("Order pipelines by"),
|
.describe("Order pipelines by"),
|
||||||
sort: z.enum(["asc", "desc"]).optional().describe("Sort pipelines"),
|
sort: z.enum(["asc", "desc"]).optional().describe("Sort pipelines"),
|
||||||
page: z.number().optional().describe("Page number for pagination"),
|
}).merge(PaginationOptionsSchema);
|
||||||
per_page: z.number().optional().describe("Number of items per page (max 100)"),
|
|
||||||
});
|
|
||||||
|
|
||||||
// Schema for getting a specific pipeline
|
// Schema for getting a specific pipeline
|
||||||
export const GetPipelineSchema = z.object({
|
export const GetPipelineSchema = z.object({
|
||||||
@ -153,9 +158,7 @@ export const ListPipelineJobsSchema = z.object({
|
|||||||
.optional()
|
.optional()
|
||||||
.describe("The scope of jobs to show"),
|
.describe("The scope of jobs to show"),
|
||||||
include_retried: z.boolean().optional().describe("Whether to include retried jobs"),
|
include_retried: z.boolean().optional().describe("Whether to include retried jobs"),
|
||||||
page: z.number().optional().describe("Page number for pagination"),
|
}).merge(PaginationOptionsSchema);
|
||||||
per_page: z.number().optional().describe("Number of items per page (max 100)"),
|
|
||||||
});
|
|
||||||
|
|
||||||
// Schema for creating a new pipeline
|
// Schema for creating a new pipeline
|
||||||
export const CreatePipelineSchema = z.object({
|
export const CreatePipelineSchema = z.object({
|
||||||
@ -188,6 +191,8 @@ export const CancelPipelineSchema = z.object({
|
|||||||
export const GetPipelineJobOutputSchema = z.object({
|
export const GetPipelineJobOutputSchema = z.object({
|
||||||
project_id: z.string().describe("Project ID or URL-encoded path"),
|
project_id: z.string().describe("Project ID or URL-encoded path"),
|
||||||
job_id: z.number().describe("The ID of the job"),
|
job_id: z.number().describe("The ID of the job"),
|
||||||
|
limit: z.number().optional().describe("Maximum number of lines to return from the end of the log (default: 1000)"),
|
||||||
|
offset: z.number().optional().describe("Number of lines to skip from the end of the log (default: 0)"),
|
||||||
});
|
});
|
||||||
|
|
||||||
// User schemas
|
// User schemas
|
||||||
@ -209,7 +214,7 @@ export const GitLabUsersResponseSchema = z.record(
|
|||||||
id: z.number(),
|
id: z.number(),
|
||||||
username: z.string(),
|
username: z.string(),
|
||||||
name: z.string(),
|
name: z.string(),
|
||||||
avatar_url: z.string(),
|
avatar_url: z.string().nullable(),
|
||||||
web_url: z.string(),
|
web_url: z.string(),
|
||||||
}).nullable()
|
}).nullable()
|
||||||
);
|
);
|
||||||
@ -250,7 +255,7 @@ export const GitLabNamespaceExistsResponseSchema = z.object({
|
|||||||
export const GitLabOwnerSchema = z.object({
|
export const GitLabOwnerSchema = z.object({
|
||||||
username: z.string(), // Changed from login to match GitLab API
|
username: z.string(), // Changed from login to match GitLab API
|
||||||
id: z.number(),
|
id: z.number(),
|
||||||
avatar_url: z.string(),
|
avatar_url: z.string().nullable(),
|
||||||
web_url: z.string(), // Changed from html_url to match GitLab API
|
web_url: z.string(), // Changed from html_url to match GitLab API
|
||||||
name: z.string(), // Added as GitLab includes full name
|
name: z.string(), // Added as GitLab includes full name
|
||||||
state: z.string(), // Added as GitLab includes user state
|
state: z.string(), // Added as GitLab includes user state
|
||||||
@ -293,14 +298,14 @@ export const GitLabRepositorySchema = z.object({
|
|||||||
project_access: z
|
project_access: z
|
||||||
.object({
|
.object({
|
||||||
access_level: z.number(),
|
access_level: z.number(),
|
||||||
notification_level: z.number().optional(),
|
notification_level: z.number().nullable().optional(),
|
||||||
})
|
})
|
||||||
.optional()
|
.optional()
|
||||||
.nullable(),
|
.nullable(),
|
||||||
group_access: z
|
group_access: z
|
||||||
.object({
|
.object({
|
||||||
access_level: z.number(),
|
access_level: z.number(),
|
||||||
notification_level: z.number().optional(),
|
notification_level: z.number().nullable().optional(),
|
||||||
})
|
})
|
||||||
.optional()
|
.optional()
|
||||||
.nullable(),
|
.nullable(),
|
||||||
@ -310,7 +315,7 @@ export const GitLabRepositorySchema = z.object({
|
|||||||
container_registry_access_level: z.string().optional(),
|
container_registry_access_level: z.string().optional(),
|
||||||
issues_enabled: z.boolean().optional(),
|
issues_enabled: z.boolean().optional(),
|
||||||
merge_requests_enabled: z.boolean().optional(),
|
merge_requests_enabled: z.boolean().optional(),
|
||||||
merge_requests_template: z.string().optional(),
|
merge_requests_template: z.string().nullable().optional(),
|
||||||
wiki_enabled: z.boolean().optional(),
|
wiki_enabled: z.boolean().optional(),
|
||||||
jobs_enabled: z.boolean().optional(),
|
jobs_enabled: z.boolean().optional(),
|
||||||
snippets_enabled: z.boolean().optional(),
|
snippets_enabled: z.boolean().optional(),
|
||||||
@ -404,8 +409,17 @@ export const GitLabCommitSchema = z.object({
|
|||||||
committer_name: z.string(),
|
committer_name: z.string(),
|
||||||
committer_email: z.string(),
|
committer_email: z.string(),
|
||||||
committed_date: z.string(),
|
committed_date: z.string(),
|
||||||
|
created_at: z.string().optional(), // Add created_at field
|
||||||
|
message: z.string().optional(), // Add full message field
|
||||||
web_url: z.string(), // Changed from html_url to match GitLab API
|
web_url: z.string(), // Changed from html_url to match GitLab API
|
||||||
parent_ids: z.array(z.string()), // Changed from parents to match GitLab API
|
parent_ids: z.array(z.string()), // Changed from parents to match GitLab API
|
||||||
|
stats: z.object({
|
||||||
|
additions: z.number().optional().nullable(),
|
||||||
|
deletions: z.number().optional().nullable(),
|
||||||
|
total: z.number().optional().nullable(),
|
||||||
|
}).optional(), // Only present when with_stats=true
|
||||||
|
trailers: z.record(z.string()).optional().default({}), // Git trailers, may be empty object
|
||||||
|
extended_trailers: z.record(z.array(z.string())).optional().default({}), // Extended trailers, may be empty object
|
||||||
});
|
});
|
||||||
|
|
||||||
// Reference schema
|
// Reference schema
|
||||||
@ -464,6 +478,8 @@ export const CreateMergeRequestOptionsSchema = z.object({
|
|||||||
labels: z.array(z.string()).optional(),
|
labels: z.array(z.string()).optional(),
|
||||||
allow_collaboration: z.boolean().optional(), // Changed from maintainer_can_modify to match GitLab API
|
allow_collaboration: z.boolean().optional(), // Changed from maintainer_can_modify to match GitLab API
|
||||||
draft: z.boolean().optional(),
|
draft: z.boolean().optional(),
|
||||||
|
remove_source_branch: z.boolean().optional().describe("Flag indicating if a merge request should remove the source branch when merging."),
|
||||||
|
squash: z.boolean().optional().describe("If true, squash all commits into a single commit on merge.")
|
||||||
});
|
});
|
||||||
|
|
||||||
export const GitLabDiffSchema = z.object({
|
export const GitLabDiffSchema = z.object({
|
||||||
@ -590,7 +606,7 @@ export const GitLabForkParentSchema = z.object({
|
|||||||
.object({
|
.object({
|
||||||
username: z.string(), // Changed from login to match GitLab API
|
username: z.string(), // Changed from login to match GitLab API
|
||||||
id: z.number(),
|
id: z.number(),
|
||||||
avatar_url: z.string(),
|
avatar_url: z.string().nullable(),
|
||||||
})
|
})
|
||||||
.optional(), // Made optional to handle cases where GitLab API doesn't include it
|
.optional(), // Made optional to handle cases where GitLab API doesn't include it
|
||||||
web_url: z.string(), // Changed from html_url to match GitLab API
|
web_url: z.string(), // Changed from html_url to match GitLab API
|
||||||
@ -643,6 +659,21 @@ export const GitLabMergeRequestSchema = z.object({
|
|||||||
labels: z.array(z.string()).optional(),
|
labels: z.array(z.string()).optional(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const LineRangeSchema = z.object({
|
||||||
|
start: z.object({
|
||||||
|
line_code: z.string().nullable().optional().describe("CRITICAL: Line identifier in format '{file_path_sha1_hash}_{old_line_number}_{new_line_number}'. USUALLY REQUIRED for GitLab diff comments despite being optional in schema. Example: 'a1b2c3d4e5f6_10_15'. Get this from GitLab diff API response, never fabricate."),
|
||||||
|
type: z.enum(["new", "old"]).nullable().optional().describe("Line type: 'old' = deleted/original line, 'new' = added/modified line, null = unchanged context. MUST match the line_code format and old_line/new_line values."),
|
||||||
|
old_line: z.number().nullable().optional().describe("Line number in original file (before changes). REQUIRED when type='old', NULL when type='new' (for purely added lines), can be present for context lines."),
|
||||||
|
new_line: z.number().nullable().optional().describe("Line number in modified file (after changes). REQUIRED when type='new', NULL when type='old' (for purely deleted lines), can be present for context lines."),
|
||||||
|
}).describe("Start line position for multiline comment range. MUST specify either old_line OR new_line (or both for context), never neither."),
|
||||||
|
end: z.object({
|
||||||
|
line_code: z.string().nullable().optional().describe("CRITICAL: Line identifier in format '{file_path_sha1_hash}_{old_line_number}_{new_line_number}'. USUALLY REQUIRED for GitLab diff comments despite being optional in schema. Example: 'a1b2c3d4e5f6_12_17'. Must be from same file as start.line_code."),
|
||||||
|
type: z.enum(["new", "old"]).nullable().optional().describe("Line type: 'old' = deleted/original line, 'new' = added/modified line, null = unchanged context. SHOULD MATCH start.type for consistent ranges (don't mix old/new types)."),
|
||||||
|
old_line: z.number().nullable().optional().describe("Line number in original file (before changes). REQUIRED when type='old', NULL when type='new' (for purely added lines), can be present for context lines. MUST be >= start.old_line if both specified."),
|
||||||
|
new_line: z.number().nullable().optional().describe("Line number in modified file (after changes). REQUIRED when type='new', NULL when type='old' (for purely deleted lines), can be present for context lines. MUST be >= start.new_line if both specified."),
|
||||||
|
}).describe("End line position for multiline comment range. MUST specify either old_line OR new_line (or both for context), never neither. Range must be valid (end >= start)."),
|
||||||
|
}).describe("Line range for multiline comments on GitLab merge request diffs. VALIDATION RULES: 1) line_code is critical for GitLab API success, 2) start/end must have consistent types, 3) line numbers must form valid range, 4) get line_code from GitLab diff API, never generate manually.");
|
||||||
|
|
||||||
// Discussion related schemas
|
// Discussion related schemas
|
||||||
export const GitLabDiscussionNoteSchema = z.object({
|
export const GitLabDiscussionNoteSchema = z.object({
|
||||||
id: z.number(),
|
id: z.number(),
|
||||||
@ -667,24 +698,24 @@ export const GitLabDiscussionNoteSchema = z.object({
|
|||||||
base_sha: z.string(),
|
base_sha: z.string(),
|
||||||
start_sha: z.string(),
|
start_sha: z.string(),
|
||||||
head_sha: z.string(),
|
head_sha: z.string(),
|
||||||
old_path: z.string(),
|
old_path: z.string().optional().describe("File path before change"),
|
||||||
new_path: z.string(),
|
new_path: z.string().optional().describe("File path after change"),
|
||||||
position_type: z.enum(["text", "image", "file"]),
|
position_type: z.enum(["text", "image", "file"]),
|
||||||
old_line: z.number().nullish(), // This is missing for image diffs
|
new_line: z.number().nullable().optional().describe("Line number in the modified file (after changes). Used for added lines and context lines. Null for deleted lines."),
|
||||||
new_line: z.number().nullish(), // This is missing for image diffs
|
old_line: z.number().nullable().optional().describe("Line number in the original file (before changes). Used for deleted lines and context lines. Null for newly added lines."),
|
||||||
line_range: z
|
line_range: z
|
||||||
.object({
|
.object({
|
||||||
start: z.object({
|
start: z.object({
|
||||||
line_code: z.string(),
|
line_code: z.string().nullable().optional().describe("Line identifier in format: '{file_path_sha1_hash}_{old_line_number}_{new_line_number}'. Used to uniquely identify a specific line in the diff."),
|
||||||
type: z.enum(["new", "old", "expanded"]),
|
type: z.enum(["new", "old", "expanded"]),
|
||||||
old_line: z.number().nullish(), // This is missing for image diffs
|
old_line: z.number().nullable().optional().describe("Line number in the original file (before changes). Null for newly added lines or unchanged context lines."),
|
||||||
new_line: z.number().nullish(), // This is missing for image diffs
|
new_line: z.number().nullable().optional().describe("Line number in the modified file (after changes). Null for deleted lines or unchanged context lines."),
|
||||||
}),
|
}),
|
||||||
end: z.object({
|
end: z.object({
|
||||||
line_code: z.string(),
|
line_code: z.string().nullable().optional().describe("Line identifier in format: '{file_path_sha1_hash}_{old_line_number}_{new_line_number}'. Used to uniquely identify a specific line in the diff."),
|
||||||
type: z.enum(["new", "old", "expanded"]),
|
type: z.enum(["new", "old", "expanded"]),
|
||||||
old_line: z.number().nullish(), // This is missing for image diffs
|
old_line: z.number().nullable().optional().describe("Line number in the original file (before changes). Null for newly added lines or unchanged context lines."),
|
||||||
new_line: z.number().nullish(), // This is missing for image diffs
|
new_line: z.number().nullable().optional().describe("Line number in the modified file (after changes). Null for deleted lines or unchanged context lines."),
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.nullable()
|
.nullable()
|
||||||
@ -698,6 +729,24 @@ export const GitLabDiscussionNoteSchema = z.object({
|
|||||||
});
|
});
|
||||||
export type GitLabDiscussionNote = z.infer<typeof GitLabDiscussionNoteSchema>;
|
export type GitLabDiscussionNote = z.infer<typeof GitLabDiscussionNoteSchema>;
|
||||||
|
|
||||||
|
// Reusable pagination schema for GitLab API responses.
|
||||||
|
// See https://docs.gitlab.com/api/rest/#pagination
|
||||||
|
export const GitLabPaginationSchema = z.object({
|
||||||
|
x_next_page: z.number().nullable().optional(),
|
||||||
|
x_page: z.number().optional(),
|
||||||
|
x_per_page: z.number().optional(),
|
||||||
|
x_prev_page: z.number().nullable().optional(),
|
||||||
|
x_total: z.number().nullable().optional(),
|
||||||
|
x_total_pages: z.number().nullable().optional(),
|
||||||
|
});
|
||||||
|
export type GitLabPagination = z.infer<typeof GitLabPaginationSchema>;
|
||||||
|
|
||||||
|
// Base paginated response schema that can be extended.
|
||||||
|
// See https://docs.gitlab.com/api/rest/#pagination
|
||||||
|
export const PaginatedResponseSchema = z.object({
|
||||||
|
pagination: GitLabPaginationSchema.optional(),
|
||||||
|
});
|
||||||
|
|
||||||
export const GitLabDiscussionSchema = z.object({
|
export const GitLabDiscussionSchema = z.object({
|
||||||
id: z.string(),
|
id: z.string(),
|
||||||
individual_note: z.boolean(),
|
individual_note: z.boolean(),
|
||||||
@ -705,10 +754,24 @@ export const GitLabDiscussionSchema = z.object({
|
|||||||
});
|
});
|
||||||
export type GitLabDiscussion = z.infer<typeof GitLabDiscussionSchema>;
|
export type GitLabDiscussion = z.infer<typeof GitLabDiscussionSchema>;
|
||||||
|
|
||||||
|
// Create a schema for paginated discussions response
|
||||||
|
export const PaginatedDiscussionsResponseSchema = z.object({
|
||||||
|
items: z.array(GitLabDiscussionSchema),
|
||||||
|
pagination: GitLabPaginationSchema,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Export the paginated response type for discussions
|
||||||
|
export type PaginatedDiscussionsResponse = z.infer<typeof PaginatedDiscussionsResponseSchema>;
|
||||||
|
|
||||||
|
export const ListIssueDiscussionsSchema = z.object({
|
||||||
|
project_id: z.string().describe("Project ID or URL-encoded path"),
|
||||||
|
issue_iid: z.number().describe("The internal ID of the project issue"),
|
||||||
|
}).merge(PaginationOptionsSchema);
|
||||||
|
|
||||||
// Input schema for listing merge request discussions
|
// Input schema for listing merge request discussions
|
||||||
export const ListMergeRequestDiscussionsSchema = ProjectParamsSchema.extend({
|
export const ListMergeRequestDiscussionsSchema = ProjectParamsSchema.extend({
|
||||||
merge_request_iid: z.number().describe("The IID of a merge request"),
|
merge_request_iid: z.number().describe("The IID of a merge request"),
|
||||||
});
|
}).merge(PaginationOptionsSchema);
|
||||||
|
|
||||||
// Input schema for updating a merge request discussion note
|
// Input schema for updating a merge request discussion note
|
||||||
export const UpdateMergeRequestNoteSchema = ProjectParamsSchema.extend({
|
export const UpdateMergeRequestNoteSchema = ProjectParamsSchema.extend({
|
||||||
@ -763,9 +826,7 @@ export const CreateOrUpdateFileSchema = ProjectParamsSchema.extend({
|
|||||||
|
|
||||||
export const SearchRepositoriesSchema = z.object({
|
export const SearchRepositoriesSchema = z.object({
|
||||||
search: z.string().describe("Search query"), // Changed from query to match GitLab API
|
search: z.string().describe("Search query"), // Changed from query to match GitLab API
|
||||||
page: z.number().optional().describe("Page number for pagination (default: 1)"),
|
}).merge(PaginationOptionsSchema);
|
||||||
per_page: z.number().optional().describe("Number of results per page (default: 20)"),
|
|
||||||
});
|
|
||||||
|
|
||||||
export const CreateRepositorySchema = z.object({
|
export const CreateRepositorySchema = z.object({
|
||||||
name: z.string().describe("Repository name"),
|
name: z.string().describe("Repository name"),
|
||||||
@ -870,6 +931,12 @@ export const GetMergeRequestDiffsSchema = GetMergeRequestSchema.extend({
|
|||||||
view: z.enum(["inline", "parallel"]).optional().describe("Diff view type"),
|
view: z.enum(["inline", "parallel"]).optional().describe("Diff view type"),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const ListMergeRequestDiffsSchema = GetMergeRequestSchema.extend({
|
||||||
|
page: z.number().optional().describe("Page number for pagination (default: 1)"),
|
||||||
|
per_page: z.number().optional().describe("Number of items per page (max: 100, default: 20)"),
|
||||||
|
unidiff: z.boolean().optional().describe("Present diffs in the unified diff format. Default is false. Introduced in GitLab 16.5."),
|
||||||
|
});
|
||||||
|
|
||||||
export const CreateNoteSchema = z.object({
|
export const CreateNoteSchema = z.object({
|
||||||
project_id: z.string().describe("Project ID or namespace/project_path"),
|
project_id: z.string().describe("Project ID or namespace/project_path"),
|
||||||
noteable_type: z
|
noteable_type: z
|
||||||
@ -883,7 +950,7 @@ export const CreateNoteSchema = z.object({
|
|||||||
export const ListIssuesSchema = z.object({
|
export const ListIssuesSchema = z.object({
|
||||||
project_id: z.string().describe("Project ID or URL-encoded path"),
|
project_id: z.string().describe("Project ID or URL-encoded path"),
|
||||||
assignee_id: z.number().optional().describe("Return issues assigned to the given user ID"),
|
assignee_id: z.number().optional().describe("Return issues assigned to the given user ID"),
|
||||||
assignee_username: z.string().optional().describe("Return issues assigned to the given username"),
|
assignee_username: z.array(z.string()).optional().describe("Return issues assigned to the given username"),
|
||||||
author_id: z.number().optional().describe("Return issues created by the given user ID"),
|
author_id: z.number().optional().describe("Return issues created by the given user ID"),
|
||||||
author_username: z.string().optional().describe("Return issues created by the given username"),
|
author_username: z.string().optional().describe("Return issues created by the given username"),
|
||||||
confidential: z.boolean().optional().describe("Filter confidential or public issues"),
|
confidential: z.boolean().optional().describe("Filter confidential or public issues"),
|
||||||
@ -904,9 +971,7 @@ export const ListIssuesSchema = z.object({
|
|||||||
updated_after: z.string().optional().describe("Return issues updated after the given time"),
|
updated_after: z.string().optional().describe("Return issues updated after the given time"),
|
||||||
updated_before: z.string().optional().describe("Return issues updated before the given time"),
|
updated_before: z.string().optional().describe("Return issues updated before the given time"),
|
||||||
with_labels_details: z.boolean().optional().describe("Return more details for each label"),
|
with_labels_details: z.boolean().optional().describe("Return more details for each label"),
|
||||||
page: z.number().optional().describe("Page number for pagination"),
|
}).merge(PaginationOptionsSchema);
|
||||||
per_page: z.number().optional().describe("Number of items per page"),
|
|
||||||
});
|
|
||||||
|
|
||||||
// Merge Requests API operation schemas
|
// Merge Requests API operation schemas
|
||||||
export const ListMergeRequestsSchema = z.object({
|
export const ListMergeRequestsSchema = z.object({
|
||||||
@ -977,9 +1042,7 @@ export const ListMergeRequestsSchema = z.object({
|
|||||||
.describe("Return merge requests from a specific source branch"),
|
.describe("Return merge requests from a specific source branch"),
|
||||||
wip: z.enum(["yes", "no"]).optional().describe("Filter merge requests against their wip status"),
|
wip: z.enum(["yes", "no"]).optional().describe("Filter merge requests against their wip status"),
|
||||||
with_labels_details: z.boolean().optional().describe("Return more details for each label"),
|
with_labels_details: z.boolean().optional().describe("Return more details for each label"),
|
||||||
page: z.number().optional().describe("Page number for pagination"),
|
}).merge(PaginationOptionsSchema);
|
||||||
per_page: z.number().optional().describe("Number of items per page"),
|
|
||||||
});
|
|
||||||
|
|
||||||
export const GetIssueSchema = z.object({
|
export const GetIssueSchema = z.object({
|
||||||
project_id: z.string().describe("Project ID or URL-encoded path"),
|
project_id: z.string().describe("Project ID or URL-encoded path"),
|
||||||
@ -1018,21 +1081,6 @@ export const ListIssueLinksSchema = z.object({
|
|||||||
issue_iid: z.number().describe("The internal ID of a project's issue"),
|
issue_iid: z.number().describe("The internal ID of a project's issue"),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const ListIssueDiscussionsSchema = z.object({
|
|
||||||
project_id: z.string().describe("Project ID or URL-encoded path"),
|
|
||||||
issue_iid: z.number().describe("The internal ID of the project issue"),
|
|
||||||
page: z.number().optional().describe("Page number for pagination"),
|
|
||||||
per_page: z.number().optional().describe("Number of items per page"),
|
|
||||||
sort: z
|
|
||||||
.enum(["asc", "desc"])
|
|
||||||
.optional()
|
|
||||||
.describe("Return issue discussions sorted in ascending or descending order"),
|
|
||||||
order_by: z
|
|
||||||
.enum(["created_at", "updated_at"])
|
|
||||||
.optional()
|
|
||||||
.describe("Return issue discussions ordered by created_at or updated_at fields"),
|
|
||||||
});
|
|
||||||
|
|
||||||
export const GetIssueLinkSchema = z.object({
|
export const GetIssueLinkSchema = z.object({
|
||||||
project_id: z.string().describe("Project ID or URL-encoded path"),
|
project_id: z.string().describe("Project ID or URL-encoded path"),
|
||||||
issue_iid: z.number().describe("The internal ID of a project's issue"),
|
issue_iid: z.number().describe("The internal ID of a project's issue"),
|
||||||
@ -1059,10 +1107,8 @@ export const DeleteIssueLinkSchema = z.object({
|
|||||||
// Namespace API operation schemas
|
// Namespace API operation schemas
|
||||||
export const ListNamespacesSchema = z.object({
|
export const ListNamespacesSchema = z.object({
|
||||||
search: z.string().optional().describe("Search term for namespaces"),
|
search: z.string().optional().describe("Search term for namespaces"),
|
||||||
page: z.number().optional().describe("Page number for pagination"),
|
|
||||||
per_page: z.number().optional().describe("Number of items per page"),
|
|
||||||
owned: z.boolean().optional().describe("Filter for namespaces owned by current user"),
|
owned: z.boolean().optional().describe("Filter for namespaces owned by current user"),
|
||||||
});
|
}).merge(PaginationOptionsSchema);
|
||||||
|
|
||||||
export const GetNamespaceSchema = z.object({
|
export const GetNamespaceSchema = z.object({
|
||||||
namespace_id: z.string().describe("Namespace ID or full path"),
|
namespace_id: z.string().describe("Namespace ID or full path"),
|
||||||
@ -1079,8 +1125,6 @@ export const GetProjectSchema = z.object({
|
|||||||
|
|
||||||
export const ListProjectsSchema = z.object({
|
export const ListProjectsSchema = z.object({
|
||||||
search: z.string().optional().describe("Search term for projects"),
|
search: z.string().optional().describe("Search term for projects"),
|
||||||
page: z.number().optional().describe("Page number for pagination"),
|
|
||||||
per_page: z.number().optional().describe("Number of items per page"),
|
|
||||||
search_namespaces: z.boolean().optional().describe("Needs to be true if search is full path"),
|
search_namespaces: z.boolean().optional().describe("Needs to be true if search is full path"),
|
||||||
owned: z.boolean().optional().describe("Filter for projects owned by current user"),
|
owned: z.boolean().optional().describe("Filter for projects owned by current user"),
|
||||||
membership: z.boolean().optional().describe("Filter for projects where current user is a member"),
|
membership: z.boolean().optional().describe("Filter for projects where current user is a member"),
|
||||||
@ -1107,7 +1151,7 @@ export const ListProjectsSchema = z.object({
|
|||||||
.optional()
|
.optional()
|
||||||
.describe("Filter projects with merge requests feature enabled"),
|
.describe("Filter projects with merge requests feature enabled"),
|
||||||
min_access_level: z.number().optional().describe("Filter by minimum access level"),
|
min_access_level: z.number().optional().describe("Filter by minimum access level"),
|
||||||
});
|
}).merge(PaginationOptionsSchema);
|
||||||
|
|
||||||
// Label operation schemas
|
// Label operation schemas
|
||||||
export const ListLabelsSchema = z.object({
|
export const ListLabelsSchema = z.object({
|
||||||
@ -1163,8 +1207,6 @@ export const ListGroupProjectsSchema = z.object({
|
|||||||
.optional()
|
.optional()
|
||||||
.describe("Field to sort by"),
|
.describe("Field to sort by"),
|
||||||
sort: z.enum(["asc", "desc"]).optional().describe("Sort direction"),
|
sort: z.enum(["asc", "desc"]).optional().describe("Sort direction"),
|
||||||
page: z.number().optional().describe("Page number"),
|
|
||||||
per_page: z.number().optional().describe("Number of results per page"),
|
|
||||||
archived: z.boolean().optional().describe("Filter for archived projects"),
|
archived: z.boolean().optional().describe("Filter for archived projects"),
|
||||||
visibility: z
|
visibility: z
|
||||||
.enum(["public", "internal", "private"])
|
.enum(["public", "internal", "private"])
|
||||||
@ -1184,14 +1226,14 @@ export const ListGroupProjectsSchema = z.object({
|
|||||||
statistics: z.boolean().optional().describe("Include project statistics"),
|
statistics: z.boolean().optional().describe("Include project statistics"),
|
||||||
with_custom_attributes: z.boolean().optional().describe("Include custom attributes"),
|
with_custom_attributes: z.boolean().optional().describe("Include custom attributes"),
|
||||||
with_security_reports: z.boolean().optional().describe("Include security reports"),
|
with_security_reports: z.boolean().optional().describe("Include security reports"),
|
||||||
});
|
}).merge(PaginationOptionsSchema);
|
||||||
|
|
||||||
// Add wiki operation schemas
|
// Add wiki operation schemas
|
||||||
export const ListWikiPagesSchema = z.object({
|
export const ListWikiPagesSchema = z.object({
|
||||||
project_id: z.string().describe("Project ID or URL-encoded path"),
|
project_id: z.string().describe("Project ID or URL-encoded path"),
|
||||||
page: z.number().optional().describe("Page number for pagination"),
|
with_content: z.boolean().optional().describe("Include content of the wiki pages"),
|
||||||
per_page: z.number().optional().describe("Number of items per page"),
|
}).merge(PaginationOptionsSchema);
|
||||||
});
|
|
||||||
export const GetWikiPageSchema = z.object({
|
export const GetWikiPageSchema = z.object({
|
||||||
project_id: z.string().describe("Project ID or URL-encoded path"),
|
project_id: z.string().describe("Project ID or URL-encoded path"),
|
||||||
slug: z.string().describe("URL-encoded slug of the wiki page"),
|
slug: z.string().describe("URL-encoded slug of the wiki page"),
|
||||||
@ -1209,6 +1251,7 @@ export const UpdateWikiPageSchema = z.object({
|
|||||||
content: z.string().optional().describe("New content of the wiki page"),
|
content: z.string().optional().describe("New content of the wiki page"),
|
||||||
format: z.string().optional().describe("Content format, e.g., markdown, rdoc"),
|
format: z.string().optional().describe("Content format, e.g., markdown, rdoc"),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const DeleteWikiPageSchema = z.object({
|
export const DeleteWikiPageSchema = z.object({
|
||||||
project_id: z.string().describe("Project ID or URL-encoded path"),
|
project_id: z.string().describe("Project ID or URL-encoded path"),
|
||||||
slug: z.string().describe("URL-encoded slug of the wiki page"),
|
slug: z.string().describe("URL-encoded slug of the wiki page"),
|
||||||
@ -1219,25 +1262,26 @@ export const GitLabWikiPageSchema = z.object({
|
|||||||
title: z.string(),
|
title: z.string(),
|
||||||
slug: z.string(),
|
slug: z.string(),
|
||||||
format: z.string(),
|
format: z.string(),
|
||||||
content: z.string(),
|
content: z.string().optional(),
|
||||||
created_at: z.string().optional(),
|
created_at: z.string().optional(),
|
||||||
updated_at: z.string().optional(),
|
updated_at: z.string().optional(),
|
||||||
});
|
});
|
||||||
|
|
||||||
// Merge Request Thread position schema - used for diff notes
|
// Merge Request Thread position schema - used for diff notes
|
||||||
export const MergeRequestThreadPositionSchema = z.object({
|
export const MergeRequestThreadPositionSchema = z.object({
|
||||||
base_sha: z.string().describe("Base commit SHA in the source branch"),
|
base_sha: z.string().describe("REQUIRED: Base commit SHA in the source branch. Get this from merge request diff_refs.base_sha."),
|
||||||
head_sha: z.string().describe("SHA referencing HEAD of the source branch"),
|
head_sha: z.string().describe("REQUIRED: SHA referencing HEAD of the source branch. Get this from merge request diff_refs.head_sha."),
|
||||||
start_sha: z.string().describe("SHA referencing the start commit of the source branch"),
|
start_sha: z.string().describe("REQUIRED: SHA referencing the start commit of the source branch. Get this from merge request diff_refs.start_sha."),
|
||||||
position_type: z.enum(["text", "image", "file"]).describe("Type of position reference"),
|
position_type: z.enum(["text", "image", "file"]).describe("REQUIRED: Position type. Use 'text' for code diffs, 'image' for image diffs, 'file' for file-level comments."),
|
||||||
new_path: z.string().optional().describe("File path after change"),
|
new_path: z.string().optional().describe("File path after changes. REQUIRED for most diff comments. Use same as old_path if file wasn't renamed."),
|
||||||
old_path: z.string().optional().describe("File path before change"),
|
old_path: z.string().optional().describe("File path before changes. REQUIRED for most diff comments. Use same as new_path if file wasn't renamed."),
|
||||||
new_line: z.number().nullable().optional().describe("Line number after change"),
|
new_line: z.number().nullable().optional().describe("Line number in modified file (after changes). Use for added lines or context lines. NULL for deleted lines. For single-line comments on new lines."),
|
||||||
old_line: z.number().nullable().optional().describe("Line number before change"),
|
old_line: z.number().nullable().optional().describe("Line number in original file (before changes). Use for deleted lines or context lines. NULL for added lines. For single-line comments on old lines."),
|
||||||
width: z.number().optional().describe("Width of the image (for image diffs)"),
|
line_range: LineRangeSchema.optional().describe("MULTILINE COMMENTS: Specify start/end line positions for commenting on multiple lines. Alternative to single old_line/new_line."),
|
||||||
height: z.number().optional().describe("Height of the image (for image diffs)"),
|
width: z.number().optional().describe("IMAGE DIFFS ONLY: Width of the image (for position_type='image')."),
|
||||||
x: z.number().optional().describe("X coordinate on the image (for image diffs)"),
|
height: z.number().optional().describe("IMAGE DIFFS ONLY: Height of the image (for position_type='image')."),
|
||||||
y: z.number().optional().describe("Y coordinate on the image (for image diffs)"),
|
x: z.number().optional().describe("IMAGE DIFFS ONLY: X coordinate on the image (for position_type='image')."),
|
||||||
|
y: z.number().optional().describe("IMAGE DIFFS ONLY: Y coordinate on the image (for position_type='image')."),
|
||||||
});
|
});
|
||||||
|
|
||||||
// Schema for creating a new merge request thread
|
// Schema for creating a new merge request thread
|
||||||
@ -1275,9 +1319,7 @@ export const ListProjectMilestonesSchema = ProjectParamsSchema.extend({
|
|||||||
.string()
|
.string()
|
||||||
.optional()
|
.optional()
|
||||||
.describe("Return milestones updated after the specified date (ISO 8601 format)"),
|
.describe("Return milestones updated after the specified date (ISO 8601 format)"),
|
||||||
page: z.number().optional().describe("Page number for pagination"),
|
}).merge(PaginationOptionsSchema);
|
||||||
per_page: z.number().optional().describe("Number of items per page (max 100)"),
|
|
||||||
});
|
|
||||||
|
|
||||||
// Schema for getting a single milestone
|
// Schema for getting a single milestone
|
||||||
export const GetProjectMilestoneSchema = ProjectParamsSchema.extend({
|
export const GetProjectMilestoneSchema = ProjectParamsSchema.extend({
|
||||||
@ -1311,18 +1353,40 @@ export const DeleteProjectMilestoneSchema = GetProjectMilestoneSchema;
|
|||||||
export const GetMilestoneIssuesSchema = GetProjectMilestoneSchema;
|
export const GetMilestoneIssuesSchema = GetProjectMilestoneSchema;
|
||||||
|
|
||||||
// Schema for getting merge requests assigned to a milestone
|
// Schema for getting merge requests assigned to a milestone
|
||||||
export const GetMilestoneMergeRequestsSchema = GetProjectMilestoneSchema.extend({
|
export const GetMilestoneMergeRequestsSchema = GetProjectMilestoneSchema.merge(PaginationOptionsSchema);
|
||||||
page: z.number().optional().describe("Page number for pagination"),
|
|
||||||
per_page: z.number().optional().describe("Number of items per page (max 100)"),
|
|
||||||
});
|
|
||||||
|
|
||||||
// Schema for promoting a project milestone to a group milestone
|
// Schema for promoting a project milestone to a group milestone
|
||||||
export const PromoteProjectMilestoneSchema = GetProjectMilestoneSchema;
|
export const PromoteProjectMilestoneSchema = GetProjectMilestoneSchema;
|
||||||
|
|
||||||
// Schema for getting burndown chart events for a milestone
|
// Schema for getting burndown chart events for a milestone
|
||||||
export const GetMilestoneBurndownEventsSchema = GetProjectMilestoneSchema.extend({
|
export const GetMilestoneBurndownEventsSchema = GetProjectMilestoneSchema.merge(PaginationOptionsSchema);
|
||||||
page: z.number().optional().describe("Page number for pagination"),
|
|
||||||
per_page: z.number().optional().describe("Number of items per page (max 100)"),
|
// Add schemas for commit operations
|
||||||
|
export const ListCommitsSchema = z.object({
|
||||||
|
project_id: z.string().describe("Project ID or complete URL-encoded path to project"),
|
||||||
|
ref_name: z.string().optional().describe("The name of a repository branch, tag or revision range, or if not given the default branch"),
|
||||||
|
since: z.string().optional().describe("Only commits after or on this date are returned in ISO 8601 format YYYY-MM-DDTHH:MM:SSZ"),
|
||||||
|
until: z.string().optional().describe("Only commits before or on this date are returned in ISO 8601 format YYYY-MM-DDTHH:MM:SSZ"),
|
||||||
|
path: z.string().optional().describe("The file path"),
|
||||||
|
author: z.string().optional().describe("Search commits by commit author"),
|
||||||
|
all: z.boolean().optional().describe("Retrieve every commit from the repository"),
|
||||||
|
with_stats: z.boolean().optional().describe("Stats about each commit are added to the response"),
|
||||||
|
first_parent: z.boolean().optional().describe("Follow only the first parent commit upon seeing a merge commit"),
|
||||||
|
order: z.enum(["default", "topo"]).optional().describe("List commits in order"),
|
||||||
|
trailers: z.boolean().optional().describe("Parse and include Git trailers for every commit"),
|
||||||
|
page: z.number().optional().describe("Page number for pagination (default: 1)"),
|
||||||
|
per_page: z.number().optional().describe("Number of items per page (max: 100, default: 20)"),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const GetCommitSchema = z.object({
|
||||||
|
project_id: z.string().describe("Project ID or complete URL-encoded path to project"),
|
||||||
|
sha: z.string().describe("The commit hash or name of a repository branch or tag"),
|
||||||
|
stats: z.boolean().optional().describe("Include commit stats"),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const GetCommitDiffSchema = z.object({
|
||||||
|
project_id: z.string().describe("Project ID or complete URL-encoded path to project"),
|
||||||
|
sha: z.string().describe("The commit hash or name of a repository branch or tag"),
|
||||||
});
|
});
|
||||||
|
|
||||||
// Export types
|
// Export types
|
||||||
@ -1352,6 +1416,7 @@ export type GitLabMergeRequestDiff = z.infer<
|
|||||||
export type CreateNoteOptions = z.infer<typeof CreateNoteSchema>;
|
export type CreateNoteOptions = z.infer<typeof CreateNoteSchema>;
|
||||||
export type GitLabIssueLink = z.infer<typeof GitLabIssueLinkSchema>;
|
export type GitLabIssueLink = z.infer<typeof GitLabIssueLinkSchema>;
|
||||||
export type ListIssueDiscussionsOptions = z.infer<typeof ListIssueDiscussionsSchema>;
|
export type ListIssueDiscussionsOptions = z.infer<typeof ListIssueDiscussionsSchema>;
|
||||||
|
export type ListMergeRequestDiscussionsOptions = z.infer<typeof ListMergeRequestDiscussionsSchema>;
|
||||||
export type UpdateIssueNoteOptions = z.infer<typeof UpdateIssueNoteSchema>;
|
export type UpdateIssueNoteOptions = z.infer<typeof UpdateIssueNoteSchema>;
|
||||||
export type CreateIssueNoteOptions = z.infer<typeof CreateIssueNoteSchema>;
|
export type CreateIssueNoteOptions = z.infer<typeof CreateIssueNoteSchema>;
|
||||||
export type GitLabNamespace = z.infer<typeof GitLabNamespaceSchema>;
|
export type GitLabNamespace = z.infer<typeof GitLabNamespaceSchema>;
|
||||||
@ -1389,3 +1454,7 @@ export type PromoteProjectMilestoneOptions = z.infer<typeof PromoteProjectMilest
|
|||||||
export type GetMilestoneBurndownEventsOptions = z.infer<typeof GetMilestoneBurndownEventsSchema>;
|
export type GetMilestoneBurndownEventsOptions = z.infer<typeof GetMilestoneBurndownEventsSchema>;
|
||||||
export type GitLabUser = z.infer<typeof GitLabUserSchema>;
|
export type GitLabUser = z.infer<typeof GitLabUserSchema>;
|
||||||
export type GitLabUsersResponse = z.infer<typeof GitLabUsersResponseSchema>;
|
export type GitLabUsersResponse = z.infer<typeof GitLabUsersResponseSchema>;
|
||||||
|
export type PaginationOptions = z.infer<typeof PaginationOptionsSchema>;
|
||||||
|
export type ListCommitsOptions = z.infer<typeof ListCommitsSchema>;
|
||||||
|
export type GetCommitOptions = z.infer<typeof GetCommitSchema>;
|
||||||
|
export type GetCommitDiffOptions = z.infer<typeof GetCommitDiffSchema>;
|
||||||
|
38
scripts/create-github-release.sh
Executable file
38
scripts/create-github-release.sh
Executable file
@ -0,0 +1,38 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Extract version from package.json
|
||||||
|
VERSION=$(jq -r .version package.json)
|
||||||
|
|
||||||
|
if [ -z "$VERSION" ]; then
|
||||||
|
echo "Could not read version from package.json."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if release notes file exists
|
||||||
|
if [ ! -f RELEASE_NOTES.md ]; then
|
||||||
|
echo "RELEASE_NOTES.md file does not exist."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Generate RELEASE_NOTES.md from CHANGELOG.md for the current version
|
||||||
|
node <<'EOF'
|
||||||
|
const fs = require('fs');
|
||||||
|
const changelog = fs.readFileSync('CHANGELOG.md', 'utf8');
|
||||||
|
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
|
||||||
|
const version = pkg.version;
|
||||||
|
|
||||||
|
const regex = new RegExp(`## \\[${version.replace(/\./g, '\\.')}\\][\\s\\S]*?(?=\\n## |\\n?$)`, 'g');
|
||||||
|
const match = changelog.match(regex);
|
||||||
|
|
||||||
|
if (match && match[0]) {
|
||||||
|
fs.writeFileSync('RELEASE_NOTES.md', match[0].trim() + '\n');
|
||||||
|
console.log('RELEASE_NOTES.md generated for version', version);
|
||||||
|
} else {
|
||||||
|
console.error('No changelog entry found for version', version);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# Create GitHub release using CLI
|
||||||
|
gh release create "$VERSION" -t "Release $VERSION" -F RELEASE_NOTES.md
|
Reference in New Issue
Block a user