Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
cdf4697ef1 |
14
CHANGELOG.md
14
CHANGELOG.md
@ -1,17 +1,3 @@
|
|||||||
## [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
|
## [1.0.62] - 2025-06-10
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
116
README.md
116
README.md
@ -36,9 +36,7 @@ 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": {
|
||||||
@ -76,7 +74,6 @@ 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 \
|
||||||
@ -114,14 +111,10 @@ $ 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
|
||||||
@ -133,59 +126,58 @@ $ 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. `list_merge_request_diffs` - List merge request diffs with pagination support (Either mergeRequestIid or branchName must be provided)
|
12. `get_branch_diffs` - Get the changes/diffs between two branches or commits in a GitLab project
|
||||||
13. `get_branch_diffs` - Get the changes/diffs between two branches or commits in a GitLab project
|
13. `update_merge_request` - Update a merge request (Either mergeRequestIid or branchName must be provided)
|
||||||
14. `update_merge_request` - Update a merge request (Either mergeRequestIid or branchName must be provided)
|
14. `create_note` - Create a new note (comment) to an issue or merge request
|
||||||
15. `create_note` - Create a new note (comment) to an issue or merge request
|
15. `create_merge_request_thread` - Create a new thread on a merge request
|
||||||
16. `create_merge_request_thread` - Create a new thread on a merge request
|
16. `mr_discussions` - List discussion items for a merge request
|
||||||
17. `mr_discussions` - List discussion items for a merge request
|
17. `update_merge_request_note` - Modify an existing merge request thread note
|
||||||
18. `update_merge_request_note` - Modify an existing merge request thread note
|
18. `create_merge_request_note` - Add a new note to an existing merge request thread
|
||||||
19. `create_merge_request_note` - Add a new note to an existing merge request thread
|
19. `update_issue_note` - Modify an existing issue thread note
|
||||||
20. `update_issue_note` - Modify an existing issue thread note
|
20. `create_issue_note` - Add a new note to an existing issue thread
|
||||||
21. `create_issue_note` - Add a new note to an existing issue thread
|
21. `list_issues` - List issues in a GitLab project with filtering options
|
||||||
22. `list_issues` - List issues in a GitLab project with filtering options
|
22. `get_issue` - Get details of a specific issue in a GitLab project
|
||||||
23. `get_issue` - Get details of a specific issue in a GitLab project
|
23. `update_issue` - Update an issue in a GitLab project
|
||||||
24. `update_issue` - Update an issue in a GitLab project
|
24. `delete_issue` - Delete an issue from a GitLab project
|
||||||
25. `delete_issue` - Delete an issue from a GitLab project
|
25. `list_issue_links` - List all issue links for a specific issue
|
||||||
26. `list_issue_links` - List all issue links for a specific issue
|
26. `list_issue_discussions` - List discussions for an issue in a GitLab project
|
||||||
27. `list_issue_discussions` - List discussions for an issue in a GitLab project
|
27. `get_issue_link` - Get a specific issue link
|
||||||
28. `get_issue_link` - Get a specific issue link
|
28. `create_issue_link` - Create an issue link between two issues
|
||||||
29. `create_issue_link` - Create an issue link between two issues
|
29. `delete_issue_link` - Delete an issue link
|
||||||
30. `delete_issue_link` - Delete an issue link
|
30. `list_namespaces` - List all namespaces available to the current user
|
||||||
31. `list_namespaces` - List all namespaces available to the current user
|
31. `get_namespace` - Get details of a namespace by ID or path
|
||||||
32. `get_namespace` - Get details of a namespace by ID or path
|
32. `verify_namespace` - Verify if a namespace path exists
|
||||||
33. `verify_namespace` - Verify if a namespace path exists
|
33. `get_project` - Get details of a specific project
|
||||||
34. `get_project` - Get details of a specific project
|
34. `list_projects` - List projects accessible by the current user
|
||||||
35. `list_projects` - List projects accessible by the current user
|
35. `list_labels` - List labels for a project
|
||||||
36. `list_labels` - List labels for a project
|
36. `get_label` - Get a single label from a project
|
||||||
37. `get_label` - Get a single label from a project
|
37. `create_label` - Create a new label in a project
|
||||||
38. `create_label` - Create a new label in a project
|
38. `update_label` - Update an existing label in a project
|
||||||
39. `update_label` - Update an existing label in a project
|
39. `delete_label` - Delete a label from a project
|
||||||
40. `delete_label` - Delete a label from a project
|
40. `list_group_projects` - List projects in a GitLab group with filtering options
|
||||||
41. `list_group_projects` - List projects in a GitLab group with filtering options
|
41. `list_wiki_pages` - List wiki pages in a GitLab project
|
||||||
42. `list_wiki_pages` - List wiki pages in a GitLab project
|
42. `get_wiki_page` - Get details of a specific wiki page
|
||||||
43. `get_wiki_page` - Get details of a specific wiki page
|
43. `create_wiki_page` - Create a new wiki page in a GitLab project
|
||||||
44. `create_wiki_page` - Create a new wiki page in a GitLab project
|
44. `update_wiki_page` - Update an existing wiki page in a GitLab project
|
||||||
45. `update_wiki_page` - Update an existing wiki page in a GitLab project
|
45. `delete_wiki_page` - Delete a wiki page from a GitLab project
|
||||||
46. `delete_wiki_page` - Delete a wiki page from a GitLab project
|
46. `get_repository_tree` - Get the repository tree for a GitLab project (list files and directories)
|
||||||
47. `get_repository_tree` - Get the repository tree for a GitLab project (list files and directories)
|
47. `list_pipelines` - List pipelines in a GitLab project with filtering options
|
||||||
48. `list_pipelines` - List pipelines in a GitLab project with filtering options
|
48. `get_pipeline` - Get details of a specific pipeline in a GitLab project
|
||||||
49. `get_pipeline` - Get details of a specific pipeline in a GitLab project
|
49. `list_pipeline_jobs` - List all jobs in a specific pipeline
|
||||||
50. `list_pipeline_jobs` - List all jobs in a specific pipeline
|
50. `get_pipeline_job` - Get details of a GitLab pipeline job number
|
||||||
51. `get_pipeline_job` - Get details of a GitLab pipeline job number
|
51. `get_pipeline_job_output` - Get the output/trace of a GitLab pipeline job number
|
||||||
52. `get_pipeline_job_output` - Get the output/trace of a GitLab pipeline job number
|
52. `create_pipeline` - Create a new pipeline for a branch or tag
|
||||||
53. `create_pipeline` - Create a new pipeline for a branch or tag
|
53. `retry_pipeline` - Retry a failed or canceled pipeline
|
||||||
54. `retry_pipeline` - Retry a failed or canceled pipeline
|
54. `cancel_pipeline` - Cancel a running pipeline
|
||||||
55. `cancel_pipeline` - Cancel a running pipeline
|
55. `list_merge_requests` - List merge requests in a GitLab project with filtering options
|
||||||
56. `list_merge_requests` - List merge requests in a GitLab project with filtering options
|
56. `list_milestones` - List milestones in a GitLab project with filtering options
|
||||||
57. `list_milestones` - List milestones in a GitLab project with filtering options
|
57. `get_milestone` - Get details of a specific milestone
|
||||||
58. `get_milestone` - Get details of a specific milestone
|
58. `create_milestone` - Create a new milestone in a GitLab project
|
||||||
59. `create_milestone` - Create a new milestone in a GitLab project
|
59. `edit_milestone` - Edit an existing milestone in a GitLab project
|
||||||
60. `edit_milestone` - Edit an existing milestone in a GitLab project
|
60. `delete_milestone` - Delete a milestone from a GitLab project
|
||||||
61. `delete_milestone` - Delete a milestone from a GitLab project
|
61. `get_milestone_issue` - Get issues associated with a specific milestone
|
||||||
62. `get_milestone_issue` - Get issues associated with a specific milestone
|
62. `get_milestone_merge_requests` - Get merge requests associated with a specific milestone
|
||||||
63. `get_milestone_merge_requests` - Get merge requests associated with a specific milestone
|
63. `promote_milestone` - Promote a milestone to the next stage
|
||||||
64. `promote_milestone` - Promote a milestone to the next stage
|
64. `get_milestone_burndown_events` - Get burndown events for a specific milestone
|
||||||
65. `get_milestone_burndown_events` - Get burndown events for a specific milestone
|
65. `get_users` - Get GitLab user details by usernames
|
||||||
66. `get_users` - Get GitLab user details by usernames
|
|
||||||
<!-- TOOLS-END -->
|
<!-- TOOLS-END -->
|
||||||
|
208
index.ts
208
index.ts
@ -4,9 +4,7 @@ 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 nodeFetch from "node-fetch";
|
import fetch 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";
|
||||||
@ -180,7 +178,6 @@ import {
|
|||||||
type ListCommitsOptions,
|
type ListCommitsOptions,
|
||||||
type GetCommitOptions,
|
type GetCommitOptions,
|
||||||
type GetCommitDiffOptions,
|
type GetCommitDiffOptions,
|
||||||
ListMergeRequestDiffsSchema,
|
|
||||||
} from "./schemas.js";
|
} from "./schemas.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -212,7 +209,6 @@ 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 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";
|
||||||
@ -255,88 +251,6 @@ 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: Record<string, string> = {
|
const DEFAULT_HEADERS: Record<string, string> = {
|
||||||
Accept: "application/json",
|
Accept: "application/json",
|
||||||
@ -418,12 +332,6 @@ const allTools = [
|
|||||||
"Get the changes/diffs of a merge request (Either mergeRequestIid or branchName must be provided)",
|
"Get the changes/diffs of a merge request (Either mergeRequestIid or branchName must be provided)",
|
||||||
inputSchema: zodToJsonSchema(GetMergeRequestDiffsSchema),
|
inputSchema: zodToJsonSchema(GetMergeRequestDiffsSchema),
|
||||||
},
|
},
|
||||||
{
|
|
||||||
name: "list_merge_request_diffs",
|
|
||||||
description:
|
|
||||||
"List merge request diffs with pagination support (Either mergeRequestIid or branchName must be provided)",
|
|
||||||
inputSchema: zodToJsonSchema(ListMergeRequestDiffsSchema),
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
name: "get_branch_diffs",
|
name: "get_branch_diffs",
|
||||||
description: "Get the changes/diffs between two branches or commits in a GitLab project",
|
description: "Get the changes/diffs between two branches or commits in a GitLab project",
|
||||||
@ -621,7 +529,7 @@ const allTools = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "get_pipeline_job_output",
|
name: "get_pipeline_job_output",
|
||||||
description: "Get the output/trace of a GitLab pipeline job with optional pagination to limit context window usage",
|
description: "Get the output/trace of a GitLab pipeline job number",
|
||||||
inputSchema: zodToJsonSchema(GetPipelineJobOutputSchema),
|
inputSchema: zodToJsonSchema(GetPipelineJobOutputSchema),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -1953,60 +1861,6 @@ 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
|
||||||
*
|
*
|
||||||
@ -2781,11 +2635,9 @@ 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, limit?: number, offset?: number): Promise<string> {
|
async function getPipelineJobOutput(projectId: string, jobId: 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`
|
||||||
@ -2804,35 +2656,7 @@ async function getPipelineJobOutput(projectId: string, jobId: number, limit?: nu
|
|||||||
}
|
}
|
||||||
|
|
||||||
await handleGitLabError(response);
|
await handleGitLabError(response);
|
||||||
const fullTrace = await response.text();
|
return 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -3383,11 +3207,6 @@ 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": {
|
||||||
@ -3606,21 +3425,6 @@ 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;
|
||||||
@ -4053,8 +3857,8 @@ server.setRequestHandler(CallToolRequestSchema, async request => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case "get_pipeline_job_output": {
|
case "get_pipeline_job_output": {
|
||||||
const { project_id, job_id, limit, offset } = GetPipelineJobOutputSchema.parse(request.params.arguments);
|
const { project_id, job_id } = GetPipelineJobOutputSchema.parse(request.params.arguments);
|
||||||
const jobOutput = await getPipelineJobOutput(project_id, job_id, limit, offset);
|
const jobOutput = await getPipelineJobOutput(project_id, job_id);
|
||||||
return {
|
return {
|
||||||
content: [
|
content: [
|
||||||
{
|
{
|
||||||
|
52
package-lock.json
generated
52
package-lock.json
generated
@ -1,24 +1,22 @@
|
|||||||
{
|
{
|
||||||
"name": "@zereight/mcp-gitlab",
|
"name": "@zereight/mcp-gitlab",
|
||||||
"version": "1.0.64",
|
"version": "1.0.60",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@zereight/mcp-gitlab",
|
"name": "@zereight/mcp-gitlab",
|
||||||
"version": "1.0.64",
|
"version": "1.0.60",
|
||||||
"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": {
|
||||||
@ -1711,16 +1709,6 @@
|
|||||||
"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",
|
||||||
@ -2914,12 +2902,6 @@
|
|||||||
"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",
|
||||||
@ -3108,24 +3090,6 @@
|
|||||||
"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",
|
||||||
@ -3148,18 +3112,6 @@
|
|||||||
"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": {
|
"node_modules/tr46": {
|
||||||
"version": "0.0.3",
|
"version": "0.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@zereight/mcp-gitlab",
|
"name": "@zereight/mcp-gitlab",
|
||||||
"version": "1.0.64",
|
"version": "1.0.62",
|
||||||
"description": "MCP server for using the GitLab API",
|
"description": "MCP server for using the GitLab API",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"author": "zereight",
|
"author": "zereight",
|
||||||
@ -33,13 +33,11 @@
|
|||||||
"@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": {
|
||||||
|
72
schemas.ts
72
schemas.ts
@ -191,8 +191,6 @@ 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
|
||||||
@ -298,14 +296,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().nullable().optional(),
|
notification_level: z.number().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().nullable().optional(),
|
notification_level: z.number().optional(),
|
||||||
})
|
})
|
||||||
.optional()
|
.optional()
|
||||||
.nullable(),
|
.nullable(),
|
||||||
@ -659,21 +657,6 @@ 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(),
|
||||||
@ -698,24 +681,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().optional().describe("File path before change"),
|
old_path: z.string(),
|
||||||
new_path: z.string().optional().describe("File path after change"),
|
new_path: z.string(),
|
||||||
position_type: z.enum(["text", "image", "file"]),
|
position_type: z.enum(["text", "image", "file"]),
|
||||||
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."),
|
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). Used for deleted lines and context lines. Null for newly added lines."),
|
new_line: z.number().nullish(), // This is missing for image diffs
|
||||||
line_range: z
|
line_range: z
|
||||||
.object({
|
.object({
|
||||||
start: z.object({
|
start: z.object({
|
||||||
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."),
|
line_code: z.string(),
|
||||||
type: z.enum(["new", "old", "expanded"]),
|
type: z.enum(["new", "old", "expanded"]),
|
||||||
old_line: z.number().nullable().optional().describe("Line number in the original file (before changes). Null for newly added lines or unchanged context lines."),
|
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). Null for deleted lines or unchanged context lines."),
|
new_line: z.number().nullish(), // This is missing for image diffs
|
||||||
}),
|
}),
|
||||||
end: z.object({
|
end: z.object({
|
||||||
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."),
|
line_code: z.string(),
|
||||||
type: z.enum(["new", "old", "expanded"]),
|
type: z.enum(["new", "old", "expanded"]),
|
||||||
old_line: z.number().nullable().optional().describe("Line number in the original file (before changes). Null for newly added lines or unchanged context lines."),
|
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). Null for deleted lines or unchanged context lines."),
|
new_line: z.number().nullish(), // This is missing for image diffs
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.nullable()
|
.nullable()
|
||||||
@ -931,12 +914,6 @@ 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
|
||||||
@ -1269,19 +1246,18 @@ export const GitLabWikiPageSchema = z.object({
|
|||||||
|
|
||||||
// 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("REQUIRED: Base commit SHA in the source branch. Get this from merge request diff_refs.base_sha."),
|
base_sha: z.string().describe("Base commit SHA in 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."),
|
head_sha: z.string().describe("SHA referencing HEAD 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."),
|
start_sha: z.string().describe("SHA referencing the start commit of the source branch"),
|
||||||
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."),
|
position_type: z.enum(["text", "image", "file"]).describe("Type of position reference"),
|
||||||
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."),
|
new_path: z.string().optional().describe("File path after 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."),
|
old_path: z.string().optional().describe("File path before 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."),
|
new_line: z.number().nullable().optional().describe("Line number after 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."),
|
old_line: z.number().nullable().optional().describe("Line number before change"),
|
||||||
line_range: LineRangeSchema.optional().describe("MULTILINE COMMENTS: Specify start/end line positions for commenting on multiple lines. Alternative to single old_line/new_line."),
|
width: z.number().optional().describe("Width of the image (for image diffs)"),
|
||||||
width: z.number().optional().describe("IMAGE DIFFS ONLY: Width of the image (for position_type='image')."),
|
height: z.number().optional().describe("Height of the image (for image diffs)"),
|
||||||
height: z.number().optional().describe("IMAGE DIFFS ONLY: Height of the image (for position_type='image')."),
|
x: z.number().optional().describe("X 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("Y coordinate on the image (for image diffs)"),
|
||||||
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
|
||||||
|
Reference in New Issue
Block a user