Compare commits
27 Commits
v1.0.54
...
fix/get_is
Author | SHA1 | Date | |
---|---|---|---|
66d53f508c | |||
8cb7703aa1 | |||
5e254836e8 | |||
93710f2846 | |||
f3854126ac | |||
c07356bd46 | |||
c82be8c94f | |||
cd8f0e5525 | |||
547b05c88d | |||
ed0b3915aa | |||
0bcccd95ca | |||
0b5453b3fd | |||
300961f051 | |||
e23739bb38 | |||
2a9b8f1a25 | |||
82a944427d | |||
63d666739c | |||
83f08d1c50 | |||
6bc13794c8 | |||
4c90f760f0 | |||
bf369a43da | |||
fef360664e | |||
75fd5e83e0 | |||
c834ebc135 | |||
005b46a1a6 | |||
808c34d0ee | |||
067586c665 |
135
README.md
135
README.md
@ -36,8 +36,8 @@ When using with the Claude App, you need to set up your API key and URLs directl
|
||||
```
|
||||
|
||||
#### Docker
|
||||
|
||||
```json
|
||||
- stdio
|
||||
```mcp.json
|
||||
{
|
||||
"mcpServers": {
|
||||
"GitLab communication server": {
|
||||
@ -73,6 +73,30 @@ When using with the Claude App, you need to set up your API key and URLs directl
|
||||
}
|
||||
```
|
||||
|
||||
- sse
|
||||
```shell
|
||||
docker run -i --rm \
|
||||
-e GITLAB_PERSONAL_ACCESS_TOKEN=your_gitlab_token \
|
||||
-e GITLAB_API_URL= "https://gitlab.com/api/v4"\
|
||||
-e GITLAB_READ_ONLY_MODE=true \
|
||||
-e USE_GITLAB_WIKI=true \
|
||||
-e USE_MILESTONE=true \
|
||||
-e USE_PIPELINE=true \
|
||||
-e SSE=true \
|
||||
-p 3333:3002 \
|
||||
iwakitakuma/gitlab-mcp
|
||||
```
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"GitLab communication server": {
|
||||
"url": "http://localhost:3333/sse"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### Docker Image Push
|
||||
|
||||
```shell
|
||||
@ -91,7 +115,6 @@ $ sh scripts/image_push.sh docker_user_name
|
||||
## Tools 🛠️
|
||||
|
||||
+<!-- TOOLS-START -->
|
||||
|
||||
1. `create_or_update_file` - Create or update a single file in a GitLab project
|
||||
2. `search_repositories` - Search for GitLab projects
|
||||
3. `create_repository` - Create a new GitLab project
|
||||
@ -103,56 +126,58 @@ $ sh scripts/image_push.sh docker_user_name
|
||||
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)
|
||||
11. `get_merge_request_diffs` - Get the changes/diffs of a merge request (Either mergeRequestIid or branchName must be provided)
|
||||
12. `update_merge_request` - Update a merge request (Either mergeRequestIid or branchName must be provided)
|
||||
13. `create_note` - Create a new note (comment) to an issue or merge request
|
||||
14. `create_merge_request_thread` - Create a new thread on a merge request
|
||||
15. `mr_discussions` - List discussion items for a merge request
|
||||
16. `update_merge_request_note` - Modify an existing merge request thread note
|
||||
17. `create_merge_request_note` - Add a new note to an existing merge request thread
|
||||
18. `update_issue_note` - Modify an existing issue thread note
|
||||
19. `create_issue_note` - Add a new note to an existing issue thread
|
||||
20. `list_issues` - List issues in a GitLab project with filtering options
|
||||
21. `get_issue` - Get details of a specific issue in a GitLab project
|
||||
22. `update_issue` - Update an issue in a GitLab project
|
||||
23. `delete_issue` - Delete an issue from a GitLab project
|
||||
24. `list_issue_links` - List all issue links for a specific issue
|
||||
25. `list_issue_discussions` - List discussions for an issue in a GitLab project
|
||||
26. `get_issue_link` - Get a specific issue link
|
||||
27. `create_issue_link` - Create an issue link between two issues
|
||||
28. `delete_issue_link` - Delete an issue link
|
||||
29. `list_namespaces` - List all namespaces available to the current user
|
||||
30. `get_namespace` - Get details of a namespace by ID or path
|
||||
31. `verify_namespace` - Verify if a namespace path exists
|
||||
32. `get_project` - Get details of a specific project
|
||||
33. `list_projects` - List projects accessible by the current user
|
||||
34. `list_labels` - List labels for a project
|
||||
35. `get_label` - Get a single label from a project
|
||||
36. `create_label` - Create a new label in a project
|
||||
37. `update_label` - Update an existing label in a project
|
||||
38. `delete_label` - Delete a label from a project
|
||||
39. `list_group_projects` - List projects in a GitLab group with filtering options
|
||||
40. `list_wiki_pages` - List wiki pages in a GitLab project
|
||||
41. `get_wiki_page` - Get details of a specific wiki page
|
||||
42. `create_wiki_page` - Create a new wiki page in a GitLab project
|
||||
43. `update_wiki_page` - Update an existing wiki page in a GitLab project
|
||||
44. `delete_wiki_page` - Delete a wiki page from a GitLab project
|
||||
45. `get_repository_tree` - Get the repository tree for a GitLab project (list files and directories)
|
||||
46. `list_pipelines` - List pipelines in a GitLab project with filtering options
|
||||
47. `get_pipeline` - Get details of a specific pipeline in a GitLab project
|
||||
48. `list_pipeline_jobs` - List all jobs in a specific pipeline
|
||||
49. `get_pipeline_job` - Get details of a GitLab pipeline job number
|
||||
50. `get_pipeline_job_output` - Get the output/trace of a GitLab pipeline job number
|
||||
51. `create_pipeline` - Create a new pipeline for a branch or tag
|
||||
52. `retry_pipeline` - Retry a failed or canceled pipeline
|
||||
53. `cancel_pipeline` - Cancel a running pipeline
|
||||
54. `list_merge_requests` - List merge requests in a GitLab project with filtering options
|
||||
55. `list_milestones` - List milestones in a GitLab project with filtering options
|
||||
56. `get_milestone` - Get details of a specific milestone
|
||||
57. `create_milestone` - Create a new milestone in a GitLab project
|
||||
58. `edit_milestone ` - Edit an existing milestone in a GitLab project
|
||||
59. `delete_milestone` - Delete a milestone from a GitLab project
|
||||
60. `get_milestone_issue` - Get issues associated with a specific milestone
|
||||
61. `get_milestone_merge_requests` - Get merge requests associated with a specific milestone
|
||||
62. `promote_milestone` - Promote a milestone to the next stage
|
||||
63. `get_milestone_burndown_events` - Get burndown events for a specific milestone
|
||||
12. `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. `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. `mr_discussions` - List discussion items for a merge request
|
||||
17. `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. `update_issue_note` - Modify an existing issue thread note
|
||||
20. `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. `get_issue` - Get details of a specific issue in a GitLab project
|
||||
23. `update_issue` - Update an issue in a GitLab project
|
||||
24. `delete_issue` - Delete an issue from a GitLab project
|
||||
25. `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. `get_issue_link` - Get a specific issue link
|
||||
28. `create_issue_link` - Create an issue link between two issues
|
||||
29. `delete_issue_link` - Delete an issue link
|
||||
30. `list_namespaces` - List all namespaces available to the current user
|
||||
31. `get_namespace` - Get details of a namespace by ID or path
|
||||
32. `verify_namespace` - Verify if a namespace path exists
|
||||
33. `get_project` - Get details of a specific project
|
||||
34. `list_projects` - List projects accessible by the current user
|
||||
35. `list_labels` - List labels for a project
|
||||
36. `get_label` - Get a single label from a project
|
||||
37. `create_label` - Create a new label in a project
|
||||
38. `update_label` - Update an existing label in a project
|
||||
39. `delete_label` - Delete a label from a project
|
||||
40. `list_group_projects` - List projects in a GitLab group with filtering options
|
||||
41. `list_wiki_pages` - List wiki pages in a GitLab project
|
||||
42. `get_wiki_page` - Get details of a specific wiki page
|
||||
43. `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. `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. `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. `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_output` - Get the output/trace of a GitLab pipeline job number
|
||||
52. `create_pipeline` - Create a new pipeline for a branch or tag
|
||||
53. `retry_pipeline` - Retry a failed or canceled pipeline
|
||||
54. `cancel_pipeline` - Cancel a running pipeline
|
||||
55. `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. `get_milestone` - Get details of a specific milestone
|
||||
58. `create_milestone` - Create a new milestone in a GitLab project
|
||||
59. `edit_milestone` - Edit an existing milestone in a GitLab project
|
||||
60. `delete_milestone` - Delete a milestone from a GitLab project
|
||||
61. `get_milestone_issue` - Get issues associated with a specific milestone
|
||||
62. `get_milestone_merge_requests` - Get merge requests associated with a specific milestone
|
||||
63. `promote_milestone` - Promote a milestone to the next stage
|
||||
64. `get_milestone_burndown_events` - Get burndown events for a specific milestone
|
||||
65. `get_users` - Get GitLab user details by usernames
|
||||
<!-- TOOLS-END -->
|
||||
|
349
index.ts
349
index.ts
@ -2,8 +2,8 @@
|
||||
|
||||
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
||||
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
||||
import { SSEServerTransport } from "@modelcontextprotocol/sdk/server/sse.js";
|
||||
import { CallToolRequestSchema, ListToolsRequestSchema } from "@modelcontextprotocol/sdk/types.js";
|
||||
import FormData from "form-data";
|
||||
import fetch from "node-fetch";
|
||||
import { SocksProxyAgent } from "socks-proxy-agent";
|
||||
import { HttpsProxyAgent } from "https-proxy-agent";
|
||||
@ -14,6 +14,7 @@ import { fileURLToPath } from "url";
|
||||
import { dirname } from "path";
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
import express, { Request, Response } from "express";
|
||||
// Add type imports for proxy agents
|
||||
import { Agent } from "http";
|
||||
import { Agent as HttpsAgent } from 'https';
|
||||
@ -34,6 +35,9 @@ import {
|
||||
GitLabNamespaceExistsResponseSchema,
|
||||
GitLabProjectSchema,
|
||||
GitLabLabelSchema,
|
||||
GitLabUserSchema,
|
||||
GitLabUsersResponseSchema,
|
||||
GetUsersSchema,
|
||||
CreateRepositoryOptionsSchema,
|
||||
CreateIssueOptionsSchema,
|
||||
CreateMergeRequestOptionsSchema,
|
||||
@ -47,7 +51,7 @@ import {
|
||||
CreateMergeRequestSchema,
|
||||
ForkRepositorySchema,
|
||||
CreateBranchSchema,
|
||||
GitLabMergeRequestDiffSchema,
|
||||
GitLabDiffSchema,
|
||||
GetMergeRequestSchema,
|
||||
GetMergeRequestDiffsSchema,
|
||||
UpdateMergeRequestSchema,
|
||||
@ -96,6 +100,7 @@ import {
|
||||
// Discussion Schemas
|
||||
GitLabDiscussionNoteSchema, // Added
|
||||
GitLabDiscussionSchema,
|
||||
PaginatedDiscussionsResponseSchema,
|
||||
UpdateMergeRequestNoteSchema, // Added
|
||||
CreateMergeRequestNoteSchema, // Added
|
||||
ListMergeRequestDiscussionsSchema,
|
||||
@ -117,6 +122,8 @@ import {
|
||||
type GitLabNamespaceExistsResponse,
|
||||
type GitLabProject,
|
||||
type GitLabLabel,
|
||||
type GitLabUser,
|
||||
type GitLabUsersResponse,
|
||||
type GitLabPipeline,
|
||||
type ListPipelinesOptions,
|
||||
type GetPipelineOptions,
|
||||
@ -136,8 +143,10 @@ import {
|
||||
type PromoteProjectMilestoneOptions,
|
||||
type GetMilestoneBurndownEventsOptions,
|
||||
// Discussion Types
|
||||
type GitLabDiscussionNote, // Added
|
||||
type GitLabDiscussionNote,
|
||||
type GitLabDiscussion,
|
||||
type PaginatedDiscussionsResponse,
|
||||
type PaginationOptions,
|
||||
type MergeRequestThreadPosition,
|
||||
type GetWikiPageOptions,
|
||||
type CreateWikiPageOptions,
|
||||
@ -159,6 +168,10 @@ import {
|
||||
GetMilestoneMergeRequestsSchema,
|
||||
PromoteProjectMilestoneSchema,
|
||||
GetMilestoneBurndownEventsSchema,
|
||||
GitLabCompareResult,
|
||||
GitLabCompareResultSchema,
|
||||
GetBranchDiffsSchema,
|
||||
ListWikiPagesOptions,
|
||||
} from "./schemas.js";
|
||||
|
||||
/**
|
||||
@ -194,6 +207,7 @@ const GITLAB_READ_ONLY_MODE = process.env.GITLAB_READ_ONLY_MODE === "true";
|
||||
const USE_GITLAB_WIKI = process.env.USE_GITLAB_WIKI === "true";
|
||||
const USE_MILESTONE = process.env.USE_MILESTONE === "true";
|
||||
const USE_PIPELINE = process.env.USE_PIPELINE === "true";
|
||||
const SSE = process.env.SSE === "true";
|
||||
|
||||
// Add proxy configuration
|
||||
const HTTP_PROXY = process.env.HTTP_PROXY;
|
||||
@ -307,6 +321,12 @@ const allTools = [
|
||||
"Get the changes/diffs of a merge request (Either mergeRequestIid or branchName must be provided)",
|
||||
inputSchema: zodToJsonSchema(GetMergeRequestDiffsSchema),
|
||||
},
|
||||
{
|
||||
name: "get_branch_diffs",
|
||||
description:
|
||||
"Get the changes/diffs between two branches or commits in a GitLab project",
|
||||
inputSchema: zodToJsonSchema(GetBranchDiffsSchema),
|
||||
},
|
||||
{
|
||||
name: "update_merge_request",
|
||||
description: "Update a merge request (Either mergeRequestIid or branchName must be provided)",
|
||||
@ -567,6 +587,11 @@ const allTools = [
|
||||
description: "Get burndown events for a specific milestone",
|
||||
inputSchema: zodToJsonSchema(GetMilestoneBurndownEventsSchema),
|
||||
},
|
||||
{
|
||||
name: "get_users",
|
||||
description: "Get GitLab user details by usernames",
|
||||
inputSchema: zodToJsonSchema(GetUsersSchema),
|
||||
},
|
||||
];
|
||||
|
||||
// Define which tools are read-only
|
||||
@ -575,6 +600,7 @@ const readOnlyTools = [
|
||||
"get_file_contents",
|
||||
"get_merge_request",
|
||||
"get_merge_request_diffs",
|
||||
"get_branch_diffs",
|
||||
"mr_discussions",
|
||||
"list_issues",
|
||||
"list_merge_requests",
|
||||
@ -603,6 +629,7 @@ const readOnlyTools = [
|
||||
"get_milestone_burndown_events",
|
||||
"list_wiki_pages",
|
||||
"get_wiki_page",
|
||||
"get_users",
|
||||
];
|
||||
|
||||
// Define which tools are related to wiki and can be toggled by USE_GITLAB_WIKI
|
||||
@ -880,9 +907,15 @@ async function listIssues(
|
||||
// Add all query parameters
|
||||
Object.entries(options).forEach(([key, value]) => {
|
||||
if (value !== undefined) {
|
||||
if (key === "label_name" && Array.isArray(value)) {
|
||||
// Handle array of labels
|
||||
url.searchParams.append(key, value.join(","));
|
||||
if (key === "labels" ) {
|
||||
if (Array.isArray(value)) {
|
||||
// Handle array of labels
|
||||
value.forEach(label => {
|
||||
url.searchParams.append("labels[]", label.toString());
|
||||
});
|
||||
} else {
|
||||
url.searchParams.append("labels[]", value.toString());
|
||||
}
|
||||
} else {
|
||||
url.searchParams.append(key, value.toString());
|
||||
}
|
||||
@ -1161,6 +1194,9 @@ async function createMergeRequest(
|
||||
description: options.description,
|
||||
source_branch: options.source_branch,
|
||||
target_branch: options.target_branch,
|
||||
assignee_ids: options.assignee_ids,
|
||||
reviewer_ids: options.reviewer_ids,
|
||||
labels: options.labels?.join(","),
|
||||
allow_collaboration: options.allow_collaboration,
|
||||
draft: options.draft,
|
||||
}),
|
||||
@ -1181,55 +1217,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 {number} mergeRequestIid - The IID of a merge request
|
||||
* @returns {Promise<GitLabDiscussion[]>} List of discussions
|
||||
* @param {"issues" | "merge_requests"} resourceType - The type of resource (issues or merge_requests)
|
||||
* @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,
|
||||
mergeRequestIid: number
|
||||
): Promise<GitLabDiscussion[]> {
|
||||
resourceType: "issues" | "merge_requests",
|
||||
resourceIid: number,
|
||||
options: PaginationOptions = {}
|
||||
): Promise<PaginatedDiscussionsResponse> {
|
||||
projectId = decodeURIComponent(projectId); // Decode project ID
|
||||
const url = new URL(
|
||||
`${GITLAB_API_URL}/projects/${encodeURIComponent(
|
||||
projectId
|
||||
)}/merge_requests/${mergeRequestIid}/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`
|
||||
)}/${resourceType}/${resourceIid}/discussions`
|
||||
);
|
||||
|
||||
// Add query parameters for pagination and sorting
|
||||
@ -1239,22 +1246,61 @@ async function listIssueDiscussions(
|
||||
if (options.per_page) {
|
||||
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(), {
|
||||
...DEFAULT_FETCH_CONFIG,
|
||||
});
|
||||
|
||||
await handleGitLabError(response);
|
||||
const data = await response.json();
|
||||
const discussions = await response.json();
|
||||
|
||||
// Parse the response as an array of discussions
|
||||
return z.array(GitLabDiscussionSchema).parse(data);
|
||||
// Extract pagination headers
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1773,7 +1819,50 @@ async function getMergeRequestDiffs(
|
||||
|
||||
await handleGitLabError(response);
|
||||
const data = (await response.json()) as { changes: unknown };
|
||||
return z.array(GitLabMergeRequestDiffSchema).parse(data.changes);
|
||||
return z.array(GitLabDiffSchema).parse(data.changes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get branch comparison diffs
|
||||
*
|
||||
* @param {string} projectId - The ID or URL-encoded path of the project
|
||||
* @param {string} from - The branch name or commit SHA to compare from
|
||||
* @param {string} to - The branch name or commit SHA to compare to
|
||||
* @param {boolean} [straight] - Comparison method: false for '...' (default), true for '--'
|
||||
* @returns {Promise<GitLabCompareResult>} Branch comparison results
|
||||
*/
|
||||
async function getBranchDiffs(
|
||||
projectId: string,
|
||||
from: string,
|
||||
to: string,
|
||||
straight?: boolean
|
||||
): Promise<GitLabCompareResult> {
|
||||
projectId = decodeURIComponent(projectId); // Decode project ID
|
||||
|
||||
const url = new URL(
|
||||
`${GITLAB_API_URL}/projects/${encodeURIComponent(projectId)}/repository/compare`
|
||||
);
|
||||
|
||||
url.searchParams.append("from", from);
|
||||
url.searchParams.append("to", to);
|
||||
|
||||
if (straight !== undefined) {
|
||||
url.searchParams.append("straight", straight.toString());
|
||||
}
|
||||
|
||||
const response = await fetch(url.toString(), {
|
||||
...DEFAULT_FETCH_CONFIG,
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const errorBody = await response.text();
|
||||
throw new Error(
|
||||
`GitLab API error: ${response.status} ${response.statusText}\n${errorBody}`
|
||||
);
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
return GitLabCompareResultSchema.parse(data);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2292,12 +2381,14 @@ async function listGroupProjects(
|
||||
*/
|
||||
async function listWikiPages(
|
||||
projectId: string,
|
||||
options: Omit<z.infer<typeof ListWikiPagesSchema>, "project_id"> = {}
|
||||
options: Omit<ListWikiPagesOptions, "project_id"> = {}
|
||||
): Promise<GitLabWikiPage[]> {
|
||||
projectId = decodeURIComponent(projectId); // Decode project ID
|
||||
const url = new URL(`${GITLAB_API_URL}/projects/${encodeURIComponent(projectId)}/wikis`);
|
||||
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.with_content)
|
||||
url.searchParams.append("with_content", options.with_content.toString());
|
||||
const response = await fetch(url.toString(), {
|
||||
...DEFAULT_FETCH_CONFIG,
|
||||
});
|
||||
@ -2868,6 +2959,65 @@ async function getMilestoneBurndownEvents(projectId: string, milestoneId: number
|
||||
return data as any[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a single user from GitLab
|
||||
*
|
||||
* @param {string} username - The username to look up
|
||||
* @returns {Promise<GitLabUser | null>} The user data or null if not found
|
||||
*/
|
||||
async function getUser(username: string): Promise<GitLabUser | null> {
|
||||
try {
|
||||
const url = new URL(`${GITLAB_API_URL}/users`);
|
||||
url.searchParams.append("username", username);
|
||||
|
||||
const response = await fetch(url.toString(), {
|
||||
...DEFAULT_FETCH_CONFIG,
|
||||
});
|
||||
|
||||
await handleGitLabError(response);
|
||||
|
||||
const users = await response.json();
|
||||
|
||||
// GitLab returns an array of users that match the username
|
||||
if (Array.isArray(users) && users.length > 0) {
|
||||
// Find exact match for username (case-sensitive)
|
||||
const exactMatch = users.find(user => user.username === username);
|
||||
if (exactMatch) {
|
||||
return GitLabUserSchema.parse(exactMatch);
|
||||
}
|
||||
}
|
||||
|
||||
// No matching user found
|
||||
return null;
|
||||
} catch (error) {
|
||||
console.error(`Error fetching user by username '${username}':`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get multiple users from GitLab
|
||||
*
|
||||
* @param {string[]} usernames - Array of usernames to look up
|
||||
* @returns {Promise<GitLabUsersResponse>} Object with usernames as keys and user objects or null as values
|
||||
*/
|
||||
async function getUsers(usernames: string[]): Promise<GitLabUsersResponse> {
|
||||
const users: Record<string, GitLabUser | null> = {};
|
||||
|
||||
// Process usernames sequentially to avoid rate limiting
|
||||
for (const username of usernames) {
|
||||
try {
|
||||
const user = await getUser(username);
|
||||
users[username] = user;
|
||||
} catch (error) {
|
||||
console.error(`Error processing username '${username}':`, error);
|
||||
users[username] = null;
|
||||
}
|
||||
}
|
||||
|
||||
return GitLabUsersResponseSchema.parse(users);
|
||||
}
|
||||
|
||||
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
||||
// Apply read-only filter first
|
||||
const tools0 = GITLAB_READ_ONLY_MODE
|
||||
@ -2956,6 +3106,34 @@ server.setRequestHandler(CallToolRequestSchema, async request => {
|
||||
};
|
||||
}
|
||||
|
||||
case "get_branch_diffs": {
|
||||
const args = GetBranchDiffsSchema.parse(request.params.arguments);
|
||||
const diffResp = await getBranchDiffs(
|
||||
args.project_id,
|
||||
args.from,
|
||||
args.to,
|
||||
args.straight
|
||||
);
|
||||
|
||||
if (args.excluded_file_patterns?.length) {
|
||||
const regexPatterns = args.excluded_file_patterns.map(pattern => new RegExp(pattern));
|
||||
|
||||
// Helper function to check if a path matches any regex pattern
|
||||
const matchesAnyPattern = (path: string): boolean => {
|
||||
if (!path) return false;
|
||||
return regexPatterns.some(regex => regex.test(path));
|
||||
};
|
||||
|
||||
// Filter out files that match any of the regex patterns on new files
|
||||
diffResp.diffs = diffResp.diffs.filter(diff =>
|
||||
!matchesAnyPattern(diff.new_path)
|
||||
);
|
||||
}
|
||||
return {
|
||||
content: [{ type: "text", text: JSON.stringify(diffResp, null, 2) }],
|
||||
};
|
||||
}
|
||||
|
||||
case "search_repositories": {
|
||||
const args = SearchRepositoriesSchema.parse(request.params.arguments);
|
||||
const results = await searchProjects(args.search, args.page, args.per_page);
|
||||
@ -3126,9 +3304,11 @@ server.setRequestHandler(CallToolRequestSchema, async request => {
|
||||
|
||||
case "mr_discussions": {
|
||||
const args = ListMergeRequestDiscussionsSchema.parse(request.params.arguments);
|
||||
const { project_id, merge_request_iid, ...options } = args;
|
||||
const discussions = await listMergeRequestDiscussions(
|
||||
args.project_id,
|
||||
args.merge_request_iid
|
||||
project_id,
|
||||
merge_request_iid,
|
||||
options
|
||||
);
|
||||
return {
|
||||
content: [{ type: "text", text: JSON.stringify(discussions, null, 2) }],
|
||||
@ -3226,6 +3406,15 @@ server.setRequestHandler(CallToolRequestSchema, async request => {
|
||||
content: [{ type: "text", text: JSON.stringify(projects, null, 2) }],
|
||||
};
|
||||
}
|
||||
|
||||
case "get_users": {
|
||||
const args = GetUsersSchema.parse(request.params.arguments);
|
||||
const usersMap = await getUsers(args.usernames);
|
||||
|
||||
return {
|
||||
content: [{ type: "text", text: JSON.stringify(usersMap, null, 2) }],
|
||||
};
|
||||
}
|
||||
|
||||
case "create_note": {
|
||||
const args = CreateNoteSchema.parse(request.params.arguments);
|
||||
@ -3415,8 +3604,10 @@ server.setRequestHandler(CallToolRequestSchema, async request => {
|
||||
}
|
||||
|
||||
case "list_wiki_pages": {
|
||||
const { project_id, page, per_page } = ListWikiPagesSchema.parse(request.params.arguments);
|
||||
const wikiPages = await listWikiPages(project_id, { page, per_page });
|
||||
const { project_id, page, per_page, with_content } = ListWikiPagesSchema.parse(
|
||||
request.params.arguments
|
||||
);
|
||||
const wikiPages = await listWikiPages(project_id, { page, per_page, with_content });
|
||||
return {
|
||||
content: [{ type: "text", text: JSON.stringify(wikiPages, null, 2) }],
|
||||
};
|
||||
@ -3755,9 +3946,37 @@ async function runServer() {
|
||||
console.error(`GitLab MCP Server v${SERVER_VERSION}`);
|
||||
console.error(`API URL: ${GITLAB_API_URL}`);
|
||||
console.error("========================");
|
||||
|
||||
const transport = new StdioServerTransport();
|
||||
await server.connect(transport);
|
||||
if ( !SSE )
|
||||
{
|
||||
const transport = new StdioServerTransport();
|
||||
await server.connect(transport);
|
||||
} else {
|
||||
const app = express();
|
||||
const transports: { [sessionId: string]: SSEServerTransport } = {};
|
||||
app.get("/sse", async (_: Request, res: Response) => {
|
||||
const transport = new SSEServerTransport("/messages", res);
|
||||
transports[transport.sessionId] = transport;
|
||||
res.on("close", () => {
|
||||
delete transports[transport.sessionId];
|
||||
});
|
||||
await server.connect(transport);
|
||||
});
|
||||
|
||||
app.post("/messages", async (req: Request, res: Response) => {
|
||||
const sessionId = req.query.sessionId as string;
|
||||
const transport = transports[sessionId];
|
||||
if (transport) {
|
||||
await transport.handlePostMessage(req, res);
|
||||
} else {
|
||||
res.status(400).send("No transport found for sessionId");
|
||||
}
|
||||
});
|
||||
|
||||
const PORT = process.env.PORT || 3002;
|
||||
app.listen(PORT, () => {
|
||||
console.log(`Server is running on port ${PORT}`);
|
||||
});
|
||||
}
|
||||
console.error("GitLab MCP Server running on stdio");
|
||||
} catch (error) {
|
||||
console.error("Error initializing server:", error);
|
||||
|
290
package-lock.json
generated
290
package-lock.json
generated
@ -1,16 +1,17 @@
|
||||
{
|
||||
"name": "@zereight/mcp-gitlab",
|
||||
"version": "1.0.50",
|
||||
"version": "1.0.56",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@zereight/mcp-gitlab",
|
||||
"version": "1.0.50",
|
||||
"version": "1.0.56",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@modelcontextprotocol/sdk": "1.8.0",
|
||||
"@types/node-fetch": "^2.6.12",
|
||||
"express": "^5.1.0",
|
||||
"form-data": "^4.0.0",
|
||||
"http-proxy-agent": "^7.0.2",
|
||||
"https-proxy-agent": "^7.0.6",
|
||||
@ -22,6 +23,7 @@
|
||||
"mcp-gitlab": "build/index.js"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/express": "^5.0.2",
|
||||
"@types/node": "^22.13.10",
|
||||
"@typescript-eslint/eslint-plugin": "^8.21.0",
|
||||
"@typescript-eslint/parser": "^8.21.0",
|
||||
@ -415,6 +417,27 @@
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/body-parser": {
|
||||
"version": "1.19.5",
|
||||
"resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.19.5.tgz",
|
||||
"integrity": "sha512-fB3Zu92ucau0iQ0JMCFQE7b/dv8Ot07NI3KaZIkIUNXq82k4eBAqUaneXfleGY9JWskeS9y+u0nXMyspcuQrCg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/connect": "*",
|
||||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/connect": {
|
||||
"version": "3.4.38",
|
||||
"resolved": "https://registry.npmjs.org/@types/connect/-/connect-3.4.38.tgz",
|
||||
"integrity": "sha512-K6uROf1LD88uDQqJCktA4yzL1YYAK6NgfsI0v/mTgyPKWsX1CnJ0XPSDhViejru1GcRkLWb8RlzFYJRqGUbaug==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/estree": {
|
||||
"version": "1.0.7",
|
||||
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.7.tgz",
|
||||
@ -422,6 +445,38 @@
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/express": {
|
||||
"version": "5.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@types/express/-/express-5.0.2.tgz",
|
||||
"integrity": "sha512-BtjL3ZwbCQriyb0DGw+Rt12qAXPiBTPs815lsUvtt1Grk0vLRMZNMUZ741d5rjk+UQOxfDiBZ3dxpX00vSkK3g==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/body-parser": "*",
|
||||
"@types/express-serve-static-core": "^5.0.0",
|
||||
"@types/serve-static": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/express-serve-static-core": {
|
||||
"version": "5.0.6",
|
||||
"resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-5.0.6.tgz",
|
||||
"integrity": "sha512-3xhRnjJPkULekpSzgtoNYYcTWgEZkp4myc+Saevii5JPnHNvHMRlBSHDbs7Bh1iPPoVTERHEZXyhyLbMEsExsA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/node": "*",
|
||||
"@types/qs": "*",
|
||||
"@types/range-parser": "*",
|
||||
"@types/send": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/http-errors": {
|
||||
"version": "2.0.4",
|
||||
"resolved": "https://registry.npmjs.org/@types/http-errors/-/http-errors-2.0.4.tgz",
|
||||
"integrity": "sha512-D0CFMMtydbJAegzOyHjtiKPLlvnm3iTZyZRSZoLq2mRhDdmLfIWOCYPfQJ4cu2erKghU++QvjcUjp/5h7hESpA==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/json-schema": {
|
||||
"version": "7.0.15",
|
||||
"resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz",
|
||||
@ -429,6 +484,13 @@
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/mime": {
|
||||
"version": "1.3.5",
|
||||
"resolved": "https://registry.npmjs.org/@types/mime/-/mime-1.3.5.tgz",
|
||||
"integrity": "sha512-/pyBZWSLD2n0dcHE3hq8s8ZvcETHtEuF+3E7XVt0Ig2nvsVQXdghHVcEkIWjy9A0wKfTn97a/PSDYohKIlnP/w==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/node": {
|
||||
"version": "22.13.14",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.13.14.tgz",
|
||||
@ -448,6 +510,43 @@
|
||||
"form-data": "^4.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/qs": {
|
||||
"version": "6.14.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.14.0.tgz",
|
||||
"integrity": "sha512-eOunJqu0K1923aExK6y8p6fsihYEn/BYuQ4g0CxAAgFc4b/ZLN4CrsRZ55srTdqoiLzU2B2evC+apEIxprEzkQ==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/range-parser": {
|
||||
"version": "1.2.7",
|
||||
"resolved": "https://registry.npmjs.org/@types/range-parser/-/range-parser-1.2.7.tgz",
|
||||
"integrity": "sha512-hKormJbkJqzQGhziax5PItDUTMAM9uE2XXQmM37dyd4hVM+5aVl7oVxMVUiVQn2oCQFN/LKCZdvSM0pFRqbSmQ==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/send": {
|
||||
"version": "0.17.4",
|
||||
"resolved": "https://registry.npmjs.org/@types/send/-/send-0.17.4.tgz",
|
||||
"integrity": "sha512-x2EM6TJOybec7c52BX0ZspPodMsQUd5L6PRwOunVyVUhXiBSKf3AezDL8Dgvgt5o0UfKNfuA0eMLr2wLT4AiBA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/mime": "^1",
|
||||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/serve-static": {
|
||||
"version": "1.15.7",
|
||||
"resolved": "https://registry.npmjs.org/@types/serve-static/-/serve-static-1.15.7.tgz",
|
||||
"integrity": "sha512-W8Ym+h8nhuRwaKPaDw34QUkwsGi6Rc4yYqvKFo5rm2FUEhCFbzVWrxXUxuKK8TASjWsysJY0nsmNCGhCOIsrOw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/http-errors": "*",
|
||||
"@types/node": "*",
|
||||
"@types/send": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/eslint-plugin": {
|
||||
"version": "8.33.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.33.0.tgz",
|
||||
@ -817,44 +916,6 @@
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/body-parser/node_modules/debug": {
|
||||
"version": "4.4.0",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-4.4.0.tgz",
|
||||
"integrity": "sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"ms": "^2.1.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"supports-color": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/body-parser/node_modules/ms": {
|
||||
"version": "2.1.3",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
|
||||
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/body-parser/node_modules/qs": {
|
||||
"version": "6.14.0",
|
||||
"resolved": "https://registry.npmjs.org/qs/-/qs-6.14.0.tgz",
|
||||
"integrity": "sha512-YWWTjgABSKcvs/nWBi9PycY/JiPJqOD4JA6o9Sej2AtvSGarXxKC3OQSk4pAarbdQlKAh5D4FCQkJNkW+GAn3w==",
|
||||
"license": "BSD-3-Clause",
|
||||
"dependencies": {
|
||||
"side-channel": "^1.1.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.6"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/brace-expansion": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz",
|
||||
@ -1065,12 +1126,12 @@
|
||||
}
|
||||
},
|
||||
"node_modules/debug": {
|
||||
"version": "4.3.6",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.6.tgz",
|
||||
"integrity": "sha512-O/09Bd4Z1fBrU4VzkhFqVgpPzaGbw6Sm9FEkBT1A/YBXQFGuuSxa1dN2nxgxS34JmKXqYx8CZAwEVoJFImUXIg==",
|
||||
"version": "4.4.1",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-4.4.1.tgz",
|
||||
"integrity": "sha512-KcKCqiftBJcZr++7ykoDIEwSa3XWowTfNPo92BYxjXiyYEVrUQh2aLyhxBCwww+heortUFxEJYcRzosstTEBYQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"ms": "2.1.2"
|
||||
"ms": "^2.1.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.0"
|
||||
@ -1455,46 +1516,45 @@
|
||||
}
|
||||
},
|
||||
"node_modules/express": {
|
||||
"version": "5.0.1",
|
||||
"resolved": "https://registry.npmjs.org/express/-/express-5.0.1.tgz",
|
||||
"integrity": "sha512-ORF7g6qGnD+YtUG9yx4DFoqCShNMmUKiXuT5oWMHiOvt/4WFbHC6yCwQMTSBMno7AqntNCAzzcnnjowRkTL9eQ==",
|
||||
"version": "5.1.0",
|
||||
"resolved": "https://registry.npmjs.org/express/-/express-5.1.0.tgz",
|
||||
"integrity": "sha512-DT9ck5YIRU+8GYzzU5kT3eHGA5iL+1Zd0EutOmTE9Dtk+Tvuzd23VBU+ec7HPNSTxXYO55gPV/hq4pSBJDjFpA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"accepts": "^2.0.0",
|
||||
"body-parser": "^2.0.1",
|
||||
"body-parser": "^2.2.0",
|
||||
"content-disposition": "^1.0.0",
|
||||
"content-type": "~1.0.4",
|
||||
"cookie": "0.7.1",
|
||||
"content-type": "^1.0.5",
|
||||
"cookie": "^0.7.1",
|
||||
"cookie-signature": "^1.2.1",
|
||||
"debug": "4.3.6",
|
||||
"depd": "2.0.0",
|
||||
"encodeurl": "~2.0.0",
|
||||
"escape-html": "~1.0.3",
|
||||
"etag": "~1.8.1",
|
||||
"finalhandler": "^2.0.0",
|
||||
"fresh": "2.0.0",
|
||||
"http-errors": "2.0.0",
|
||||
"debug": "^4.4.0",
|
||||
"encodeurl": "^2.0.0",
|
||||
"escape-html": "^1.0.3",
|
||||
"etag": "^1.8.1",
|
||||
"finalhandler": "^2.1.0",
|
||||
"fresh": "^2.0.0",
|
||||
"http-errors": "^2.0.0",
|
||||
"merge-descriptors": "^2.0.0",
|
||||
"methods": "~1.1.2",
|
||||
"mime-types": "^3.0.0",
|
||||
"on-finished": "2.4.1",
|
||||
"once": "1.4.0",
|
||||
"parseurl": "~1.3.3",
|
||||
"proxy-addr": "~2.0.7",
|
||||
"qs": "6.13.0",
|
||||
"range-parser": "~1.2.1",
|
||||
"router": "^2.0.0",
|
||||
"safe-buffer": "5.2.1",
|
||||
"on-finished": "^2.4.1",
|
||||
"once": "^1.4.0",
|
||||
"parseurl": "^1.3.3",
|
||||
"proxy-addr": "^2.0.7",
|
||||
"qs": "^6.14.0",
|
||||
"range-parser": "^1.2.1",
|
||||
"router": "^2.2.0",
|
||||
"send": "^1.1.0",
|
||||
"serve-static": "^2.1.0",
|
||||
"setprototypeof": "1.2.0",
|
||||
"statuses": "2.0.1",
|
||||
"type-is": "^2.0.0",
|
||||
"utils-merge": "1.0.1",
|
||||
"vary": "~1.1.2"
|
||||
"serve-static": "^2.2.0",
|
||||
"statuses": "^2.0.1",
|
||||
"type-is": "^2.0.1",
|
||||
"vary": "^1.1.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 18"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/express"
|
||||
}
|
||||
},
|
||||
"node_modules/express-rate-limit": {
|
||||
@ -1639,29 +1699,6 @@
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/finalhandler/node_modules/debug": {
|
||||
"version": "4.4.0",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-4.4.0.tgz",
|
||||
"integrity": "sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"ms": "^2.1.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"supports-color": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/finalhandler/node_modules/ms": {
|
||||
"version": "2.1.3",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
|
||||
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/find-up": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz",
|
||||
@ -2204,15 +2241,6 @@
|
||||
"node": ">= 8"
|
||||
}
|
||||
},
|
||||
"node_modules/methods": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz",
|
||||
"integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/micromatch": {
|
||||
"version": "4.0.8",
|
||||
"resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz",
|
||||
@ -2265,9 +2293,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/ms": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
|
||||
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",
|
||||
"version": "2.1.3",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
|
||||
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/natural-compare": {
|
||||
@ -2537,12 +2565,12 @@
|
||||
}
|
||||
},
|
||||
"node_modules/qs": {
|
||||
"version": "6.13.0",
|
||||
"resolved": "https://registry.npmjs.org/qs/-/qs-6.13.0.tgz",
|
||||
"integrity": "sha512-+38qI9SOr8tfZ4QmJNplMUxqjbe7LKvvZgWdExBOmd+egZTtjLB67Gu0HRX3u/XOq7UU2Nx6nsjvS16Z9uwfpg==",
|
||||
"version": "6.14.0",
|
||||
"resolved": "https://registry.npmjs.org/qs/-/qs-6.14.0.tgz",
|
||||
"integrity": "sha512-YWWTjgABSKcvs/nWBi9PycY/JiPJqOD4JA6o9Sej2AtvSGarXxKC3OQSk4pAarbdQlKAh5D4FCQkJNkW+GAn3w==",
|
||||
"license": "BSD-3-Clause",
|
||||
"dependencies": {
|
||||
"side-channel": "^1.0.6"
|
||||
"side-channel": "^1.1.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.6"
|
||||
@ -2633,29 +2661,6 @@
|
||||
"node": ">= 18"
|
||||
}
|
||||
},
|
||||
"node_modules/router/node_modules/debug": {
|
||||
"version": "4.4.0",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-4.4.0.tgz",
|
||||
"integrity": "sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"ms": "^2.1.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"supports-color": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/router/node_modules/ms": {
|
||||
"version": "2.1.3",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
|
||||
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/run-parallel": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz",
|
||||
@ -2741,12 +2746,6 @@
|
||||
"node": ">= 18"
|
||||
}
|
||||
},
|
||||
"node_modules/send/node_modules/ms": {
|
||||
"version": "2.1.3",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
|
||||
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/serve-static": {
|
||||
"version": "2.2.0",
|
||||
"resolved": "https://registry.npmjs.org/serve-static/-/serve-static-2.2.0.tgz",
|
||||
@ -3085,15 +3084,6 @@
|
||||
"punycode": "^2.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/utils-merge": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz",
|
||||
"integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/v8-compile-cache-lib": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz",
|
||||
|
12
package.json
12
package.json
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@zereight/mcp-gitlab",
|
||||
"version": "1.0.54",
|
||||
"version": "1.0.58",
|
||||
"description": "MCP server for using the GitLab API",
|
||||
"license": "MIT",
|
||||
"author": "zereight",
|
||||
@ -30,8 +30,9 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@modelcontextprotocol/sdk": "1.8.0",
|
||||
"form-data": "^4.0.0",
|
||||
"@types/node-fetch": "^2.6.12",
|
||||
"express": "^5.1.0",
|
||||
"form-data": "^4.0.0",
|
||||
"http-proxy-agent": "^7.0.2",
|
||||
"https-proxy-agent": "^7.0.6",
|
||||
"node-fetch": "^3.3.2",
|
||||
@ -39,13 +40,14 @@
|
||||
"zod-to-json-schema": "^3.23.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/express": "^5.0.2",
|
||||
"@types/node": "^22.13.10",
|
||||
"typescript": "^5.8.2",
|
||||
"zod": "^3.24.2",
|
||||
"@typescript-eslint/eslint-plugin": "^8.21.0",
|
||||
"@typescript-eslint/parser": "^8.21.0",
|
||||
"eslint": "^9.18.0",
|
||||
"prettier": "^3.4.2",
|
||||
"ts-node": "^10.9.2"
|
||||
"ts-node": "^10.9.2",
|
||||
"typescript": "^5.8.2",
|
||||
"zod": "^3.24.2"
|
||||
}
|
||||
}
|
||||
|
233
schemas.ts
233
schemas.ts
@ -94,6 +94,13 @@ export const GitLabPipelineJobSchema = z.object({
|
||||
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
|
||||
export const ListPipelinesSchema = z.object({
|
||||
project_id: z.string().describe("Project ID or URL-encoded path"),
|
||||
@ -134,9 +141,7 @@ export const ListPipelinesSchema = z.object({
|
||||
.optional()
|
||||
.describe("Order pipelines by"),
|
||||
sort: z.enum(["asc", "desc"]).optional().describe("Sort pipelines"),
|
||||
page: z.number().optional().describe("Page number for pagination"),
|
||||
per_page: z.number().optional().describe("Number of items per page (max 100)"),
|
||||
});
|
||||
}).merge(PaginationOptionsSchema);
|
||||
|
||||
// Schema for getting a specific pipeline
|
||||
export const GetPipelineSchema = z.object({
|
||||
@ -153,9 +158,7 @@ export const ListPipelineJobsSchema = z.object({
|
||||
.optional()
|
||||
.describe("The scope of jobs to show"),
|
||||
include_retried: z.boolean().optional().describe("Whether to include retried jobs"),
|
||||
page: z.number().optional().describe("Page number for pagination"),
|
||||
per_page: z.number().optional().describe("Number of items per page (max 100)"),
|
||||
});
|
||||
}).merge(PaginationOptionsSchema);
|
||||
|
||||
// Schema for creating a new pipeline
|
||||
export const CreatePipelineSchema = z.object({
|
||||
@ -190,11 +193,35 @@ export const GetPipelineJobOutputSchema = z.object({
|
||||
job_id: z.number().describe("The ID of the job"),
|
||||
});
|
||||
|
||||
// User schemas
|
||||
export const GitLabUserSchema = z.object({
|
||||
username: z.string(), // Changed from login to match GitLab API
|
||||
id: z.number(),
|
||||
name: z.string(),
|
||||
avatar_url: z.string().nullable(),
|
||||
web_url: z.string(), // Changed from html_url to match GitLab API
|
||||
});
|
||||
|
||||
export const GetUsersSchema = z.object({
|
||||
usernames: z.array(z.string()).describe("Array of usernames to search for"),
|
||||
});
|
||||
|
||||
export const GitLabUsersResponseSchema = z.record(
|
||||
z.string(),
|
||||
z.object({
|
||||
id: z.number(),
|
||||
username: z.string(),
|
||||
name: z.string(),
|
||||
avatar_url: z.string(),
|
||||
web_url: z.string(),
|
||||
}).nullable()
|
||||
);
|
||||
|
||||
// Namespace related schemas
|
||||
|
||||
// Base schema for project-related operations
|
||||
const ProjectParamsSchema = z.object({
|
||||
project_id: z.string().describe("Project ID or URL-encoded path"), // Changed from owner/repo to match GitLab API
|
||||
project_id: z.string().describe("Project ID or complete URL-encoded path to project"), // Changed from owner/repo to match GitLab API
|
||||
});
|
||||
export const GitLabNamespaceSchema = z.object({
|
||||
id: z.number(),
|
||||
@ -286,6 +313,7 @@ export const GitLabRepositorySchema = z.object({
|
||||
container_registry_access_level: z.string().optional(),
|
||||
issues_enabled: z.boolean().optional(),
|
||||
merge_requests_enabled: z.boolean().optional(),
|
||||
merge_requests_template: z.string().nullable().optional(),
|
||||
wiki_enabled: z.boolean().optional(),
|
||||
jobs_enabled: z.boolean().optional(),
|
||||
snippets_enabled: z.boolean().optional(),
|
||||
@ -430,13 +458,26 @@ export const CreateMergeRequestOptionsSchema = z.object({
|
||||
description: z.string().optional(), // Changed from body to match GitLab API
|
||||
source_branch: z.string(), // Changed from head to match GitLab API
|
||||
target_branch: z.string(), // Changed from base to match GitLab API
|
||||
assignee_ids: z
|
||||
.array(z.number())
|
||||
.optional(),
|
||||
reviewer_ids: z
|
||||
.array(z.number())
|
||||
.optional(),
|
||||
labels: z.array(z.string()).optional(),
|
||||
allow_collaboration: z.boolean().optional(), // Changed from maintainer_can_modify to match GitLab API
|
||||
draft: z.boolean().optional(),
|
||||
});
|
||||
|
||||
export const CreateBranchOptionsSchema = z.object({
|
||||
name: z.string(), // Changed from ref to match GitLab API
|
||||
ref: z.string(), // The source branch/commit for the new branch
|
||||
export const GitLabDiffSchema = z.object({
|
||||
old_path: z.string(),
|
||||
new_path: z.string(),
|
||||
a_mode: z.string(),
|
||||
b_mode: z.string(),
|
||||
diff: z.string(),
|
||||
new_file: z.boolean(),
|
||||
renamed_file: z.boolean(),
|
||||
deleted_file: z.boolean(),
|
||||
});
|
||||
|
||||
// Response schemas for operations
|
||||
@ -454,6 +495,27 @@ export const GitLabSearchResponseSchema = z.object({
|
||||
items: z.array(GitLabRepositorySchema),
|
||||
});
|
||||
|
||||
// create branch schemas
|
||||
export const CreateBranchOptionsSchema = z.object({
|
||||
name: z.string(), // Changed from ref to match GitLab API
|
||||
ref: z.string(), // The source branch/commit for the new branch
|
||||
});
|
||||
|
||||
export const GitLabCompareResultSchema = z.object({
|
||||
commit: z.object({
|
||||
id: z.string().optional(),
|
||||
short_id: z.string().optional(),
|
||||
title: z.string().optional(),
|
||||
author_name: z.string().optional(),
|
||||
author_email: z.string().optional(),
|
||||
created_at: z.string().optional(),
|
||||
}).optional(),
|
||||
commits: z.array(GitLabCommitSchema),
|
||||
diffs: z.array(GitLabDiffSchema),
|
||||
compare_timeout: z.boolean().optional(),
|
||||
compare_same_ref: z.boolean().optional(),
|
||||
});
|
||||
|
||||
// Issue related schemas
|
||||
export const GitLabLabelSchema = z.object({
|
||||
id: z.number(),
|
||||
@ -470,14 +532,6 @@ export const GitLabLabelSchema = z.object({
|
||||
is_project_label: z.boolean().optional(),
|
||||
});
|
||||
|
||||
export const GitLabUserSchema = z.object({
|
||||
username: z.string(), // Changed from login to match GitLab API
|
||||
id: z.number(),
|
||||
name: z.string(),
|
||||
avatar_url: z.string().nullable(),
|
||||
web_url: z.string(), // Changed from html_url to match GitLab API
|
||||
});
|
||||
|
||||
export const GitLabMilestoneSchema = z.object({
|
||||
id: z.number(),
|
||||
iid: z.number(), // Added to match GitLab API
|
||||
@ -567,6 +621,7 @@ export const GitLabMergeRequestSchema = z.object({
|
||||
draft: z.boolean().optional(),
|
||||
author: GitLabUserSchema,
|
||||
assignees: z.array(GitLabUserSchema).optional(),
|
||||
reviewers: z.array(GitLabUserSchema).optional(),
|
||||
source_branch: z.string(),
|
||||
target_branch: z.string(),
|
||||
diff_refs: GitLabMergeRequestDiffRefSchema.nullable().optional(),
|
||||
@ -646,6 +701,24 @@ export const GitLabDiscussionNoteSchema = z.object({
|
||||
});
|
||||
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({
|
||||
id: z.string(),
|
||||
individual_note: z.boolean(),
|
||||
@ -653,10 +726,24 @@ export const GitLabDiscussionSchema = z.object({
|
||||
});
|
||||
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
|
||||
export const ListMergeRequestDiscussionsSchema = ProjectParamsSchema.extend({
|
||||
merge_request_iid: z.number().describe("The IID of a merge request"),
|
||||
});
|
||||
}).merge(PaginationOptionsSchema);
|
||||
|
||||
// Input schema for updating a merge request discussion note
|
||||
export const UpdateMergeRequestNoteSchema = ProjectParamsSchema.extend({
|
||||
@ -711,9 +798,7 @@ export const CreateOrUpdateFileSchema = ProjectParamsSchema.extend({
|
||||
|
||||
export const SearchRepositoriesSchema = z.object({
|
||||
search: z.string().describe("Search query"), // Changed from query to match GitLab API
|
||||
page: z.number().optional().describe("Page number for pagination (default: 1)"),
|
||||
per_page: z.number().optional().describe("Number of results per page (default: 20)"),
|
||||
});
|
||||
}).merge(PaginationOptionsSchema);
|
||||
|
||||
export const CreateRepositorySchema = z.object({
|
||||
name: z.string().describe("Repository name"),
|
||||
@ -756,28 +841,39 @@ export const CreateMergeRequestSchema = ProjectParamsSchema.extend({
|
||||
description: z.string().optional().describe("Merge request description"),
|
||||
source_branch: z.string().describe("Branch containing changes"),
|
||||
target_branch: z.string().describe("Branch to merge into"),
|
||||
assignee_ids: z
|
||||
.array(z.number())
|
||||
.optional()
|
||||
.describe("The ID of the users to assign the MR to"),
|
||||
reviewer_ids: z
|
||||
.array(z.number())
|
||||
.optional()
|
||||
.describe("The ID of the users to assign as reviewers of the MR"),
|
||||
labels: z.array(z.string()).optional().describe("Labels for the MR"),
|
||||
draft: z.boolean().optional().describe("Create as draft merge request"),
|
||||
allow_collaboration: z.boolean().optional().describe("Allow commits from upstream members"),
|
||||
allow_collaboration: z
|
||||
.boolean()
|
||||
.optional()
|
||||
.describe("Allow commits from upstream members"),
|
||||
});
|
||||
|
||||
export const ForkRepositorySchema = ProjectParamsSchema.extend({
|
||||
namespace: z.string().optional().describe("Namespace to fork to (full path)"),
|
||||
});
|
||||
|
||||
// Branch related schemas
|
||||
export const CreateBranchSchema = ProjectParamsSchema.extend({
|
||||
branch: z.string().describe("Name for the new branch"),
|
||||
ref: z.string().optional().describe("Source branch/commit for new branch"),
|
||||
});
|
||||
|
||||
export const GitLabMergeRequestDiffSchema = z.object({
|
||||
old_path: z.string(),
|
||||
new_path: z.string(),
|
||||
a_mode: z.string(),
|
||||
b_mode: z.string(),
|
||||
diff: z.string(),
|
||||
new_file: z.boolean(),
|
||||
renamed_file: z.boolean(),
|
||||
deleted_file: z.boolean(),
|
||||
export const GetBranchDiffsSchema = ProjectParamsSchema.extend({
|
||||
from: z.string().describe("The base branch or commit SHA to compare from"),
|
||||
to: z.string().describe("The target branch or commit SHA to compare to"),
|
||||
straight: z.boolean().optional().describe("Comparison method: false for '...' (default), true for '--'"),
|
||||
excluded_file_patterns: z.array(z.string()).optional().describe(
|
||||
"Array of regex patterns to exclude files from the diff results. Each pattern is a JavaScript-compatible regular expression that matches file paths to ignore. Examples: [\"^test/mocks/\", \"\\.spec\\.ts$\", \"package-lock\\.json\"]"
|
||||
),
|
||||
});
|
||||
|
||||
export const GetMergeRequestSchema = ProjectParamsSchema.extend({
|
||||
@ -820,17 +916,17 @@ export const CreateNoteSchema = z.object({
|
||||
export const ListIssuesSchema = z.object({
|
||||
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_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_username: z.string().optional().describe("Return issues created by the given username"),
|
||||
confidential: z.boolean().optional().describe("Filter confidential or public issues"),
|
||||
created_after: z.string().optional().describe("Return issues created after the given time"),
|
||||
created_before: z.string().optional().describe("Return issues created before the given time"),
|
||||
due_date: z.string().optional().describe("Return issues that have the due date"),
|
||||
label_name: z.array(z.string()).optional().describe("Array of label names"),
|
||||
labels: z.array(z.string()).optional().describe("Array of label names"),
|
||||
milestone: z.string().optional().describe("Milestone title"),
|
||||
scope: z
|
||||
.enum(["created-by-me", "assigned-to-me", "all"])
|
||||
.enum(["created_by_me", "assigned_to_me", "all"])
|
||||
.optional()
|
||||
.describe("Return issues from a specific scope"),
|
||||
search: z.string().optional().describe("Search for specific terms"),
|
||||
@ -841,9 +937,7 @@ export const ListIssuesSchema = z.object({
|
||||
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"),
|
||||
with_labels_details: z.boolean().optional().describe("Return more details for each label"),
|
||||
page: z.number().optional().describe("Page number for pagination"),
|
||||
per_page: z.number().optional().describe("Number of items per page"),
|
||||
});
|
||||
}).merge(PaginationOptionsSchema);
|
||||
|
||||
// Merge Requests API operation schemas
|
||||
export const ListMergeRequestsSchema = z.object({
|
||||
@ -914,9 +1008,7 @@ export const ListMergeRequestsSchema = z.object({
|
||||
.describe("Return merge requests from a specific source branch"),
|
||||
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"),
|
||||
page: z.number().optional().describe("Page number for pagination"),
|
||||
per_page: z.number().optional().describe("Number of items per page"),
|
||||
});
|
||||
}).merge(PaginationOptionsSchema);
|
||||
|
||||
export const GetIssueSchema = z.object({
|
||||
project_id: z.string().describe("Project ID or URL-encoded path"),
|
||||
@ -955,21 +1047,6 @@ export const ListIssueLinksSchema = z.object({
|
||||
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({
|
||||
project_id: z.string().describe("Project ID or URL-encoded path"),
|
||||
issue_iid: z.number().describe("The internal ID of a project's issue"),
|
||||
@ -996,10 +1073,8 @@ export const DeleteIssueLinkSchema = z.object({
|
||||
// Namespace API operation schemas
|
||||
export const ListNamespacesSchema = z.object({
|
||||
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"),
|
||||
});
|
||||
}).merge(PaginationOptionsSchema);
|
||||
|
||||
export const GetNamespaceSchema = z.object({
|
||||
namespace_id: z.string().describe("Namespace ID or full path"),
|
||||
@ -1016,8 +1091,6 @@ export const GetProjectSchema = z.object({
|
||||
|
||||
export const ListProjectsSchema = z.object({
|
||||
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"),
|
||||
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"),
|
||||
@ -1044,7 +1117,7 @@ export const ListProjectsSchema = z.object({
|
||||
.optional()
|
||||
.describe("Filter projects with merge requests feature enabled"),
|
||||
min_access_level: z.number().optional().describe("Filter by minimum access level"),
|
||||
});
|
||||
}).merge(PaginationOptionsSchema);
|
||||
|
||||
// Label operation schemas
|
||||
export const ListLabelsSchema = z.object({
|
||||
@ -1100,8 +1173,6 @@ export const ListGroupProjectsSchema = z.object({
|
||||
.optional()
|
||||
.describe("Field to sort by"),
|
||||
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"),
|
||||
visibility: z
|
||||
.enum(["public", "internal", "private"])
|
||||
@ -1121,14 +1192,14 @@ export const ListGroupProjectsSchema = z.object({
|
||||
statistics: z.boolean().optional().describe("Include project statistics"),
|
||||
with_custom_attributes: z.boolean().optional().describe("Include custom attributes"),
|
||||
with_security_reports: z.boolean().optional().describe("Include security reports"),
|
||||
});
|
||||
}).merge(PaginationOptionsSchema);
|
||||
|
||||
// Add wiki operation schemas
|
||||
export const ListWikiPagesSchema = z.object({
|
||||
project_id: z.string().describe("Project ID or URL-encoded path"),
|
||||
page: z.number().optional().describe("Page number for pagination"),
|
||||
per_page: z.number().optional().describe("Number of items per page"),
|
||||
});
|
||||
with_content: z.boolean().optional().describe("Include content of the wiki pages"),
|
||||
}).merge(PaginationOptionsSchema);
|
||||
|
||||
export const GetWikiPageSchema = z.object({
|
||||
project_id: z.string().describe("Project ID or URL-encoded path"),
|
||||
slug: z.string().describe("URL-encoded slug of the wiki page"),
|
||||
@ -1146,6 +1217,7 @@ export const UpdateWikiPageSchema = z.object({
|
||||
content: z.string().optional().describe("New content of the wiki page"),
|
||||
format: z.string().optional().describe("Content format, e.g., markdown, rdoc"),
|
||||
});
|
||||
|
||||
export const DeleteWikiPageSchema = z.object({
|
||||
project_id: z.string().describe("Project ID or URL-encoded path"),
|
||||
slug: z.string().describe("URL-encoded slug of the wiki page"),
|
||||
@ -1156,7 +1228,7 @@ export const GitLabWikiPageSchema = z.object({
|
||||
title: z.string(),
|
||||
slug: z.string(),
|
||||
format: z.string(),
|
||||
content: z.string(),
|
||||
content: z.string().optional(),
|
||||
created_at: z.string().optional(),
|
||||
updated_at: z.string().optional(),
|
||||
});
|
||||
@ -1212,9 +1284,7 @@ export const ListProjectMilestonesSchema = ProjectParamsSchema.extend({
|
||||
.string()
|
||||
.optional()
|
||||
.describe("Return milestones updated after the specified date (ISO 8601 format)"),
|
||||
page: z.number().optional().describe("Page number for pagination"),
|
||||
per_page: z.number().optional().describe("Number of items per page (max 100)"),
|
||||
});
|
||||
}).merge(PaginationOptionsSchema);
|
||||
|
||||
// Schema for getting a single milestone
|
||||
export const GetProjectMilestoneSchema = ProjectParamsSchema.extend({
|
||||
@ -1248,19 +1318,13 @@ export const DeleteProjectMilestoneSchema = GetProjectMilestoneSchema;
|
||||
export const GetMilestoneIssuesSchema = GetProjectMilestoneSchema;
|
||||
|
||||
// Schema for getting merge requests assigned to a milestone
|
||||
export const GetMilestoneMergeRequestsSchema = GetProjectMilestoneSchema.extend({
|
||||
page: z.number().optional().describe("Page number for pagination"),
|
||||
per_page: z.number().optional().describe("Number of items per page (max 100)"),
|
||||
});
|
||||
export const GetMilestoneMergeRequestsSchema = GetProjectMilestoneSchema.merge(PaginationOptionsSchema);
|
||||
|
||||
// Schema for promoting a project milestone to a group milestone
|
||||
export const PromoteProjectMilestoneSchema = GetProjectMilestoneSchema;
|
||||
|
||||
// Schema for getting burndown chart events for a milestone
|
||||
export const GetMilestoneBurndownEventsSchema = GetProjectMilestoneSchema.extend({
|
||||
page: z.number().optional().describe("Page number for pagination"),
|
||||
per_page: z.number().optional().describe("Number of items per page (max 100)"),
|
||||
});
|
||||
export const GetMilestoneBurndownEventsSchema = GetProjectMilestoneSchema.merge(PaginationOptionsSchema);
|
||||
|
||||
// Export types
|
||||
export type GitLabAuthor = z.infer<typeof GitLabAuthorSchema>;
|
||||
@ -1274,6 +1338,7 @@ export type GitLabDirectoryContent = z.infer<typeof GitLabDirectoryContentSchema
|
||||
export type GitLabContent = z.infer<typeof GitLabContentSchema>;
|
||||
export type FileOperation = z.infer<typeof FileOperationSchema>;
|
||||
export type GitLabTree = z.infer<typeof GitLabTreeSchema>;
|
||||
export type GitLabCompareResult = z.infer<typeof GitLabCompareResultSchema>;
|
||||
export type GitLabCommit = z.infer<typeof GitLabCommitSchema>;
|
||||
export type GitLabReference = z.infer<typeof GitLabReferenceSchema>;
|
||||
export type CreateRepositoryOptions = z.infer<typeof CreateRepositoryOptionsSchema>;
|
||||
@ -1282,10 +1347,13 @@ export type CreateMergeRequestOptions = z.infer<typeof CreateMergeRequestOptions
|
||||
export type CreateBranchOptions = z.infer<typeof CreateBranchOptionsSchema>;
|
||||
export type GitLabCreateUpdateFileResponse = z.infer<typeof GitLabCreateUpdateFileResponseSchema>;
|
||||
export type GitLabSearchResponse = z.infer<typeof GitLabSearchResponseSchema>;
|
||||
export type GitLabMergeRequestDiff = z.infer<typeof GitLabMergeRequestDiffSchema>;
|
||||
export type GitLabMergeRequestDiff = z.infer<
|
||||
typeof GitLabDiffSchema
|
||||
>;
|
||||
export type CreateNoteOptions = z.infer<typeof CreateNoteSchema>;
|
||||
export type GitLabIssueLink = z.infer<typeof GitLabIssueLinkSchema>;
|
||||
export type ListIssueDiscussionsOptions = z.infer<typeof ListIssueDiscussionsSchema>;
|
||||
export type ListMergeRequestDiscussionsOptions = z.infer<typeof ListMergeRequestDiscussionsSchema>;
|
||||
export type UpdateIssueNoteOptions = z.infer<typeof UpdateIssueNoteSchema>;
|
||||
export type CreateIssueNoteOptions = z.infer<typeof CreateIssueNoteSchema>;
|
||||
export type GitLabNamespace = z.infer<typeof GitLabNamespaceSchema>;
|
||||
@ -1321,3 +1389,6 @@ export type GetMilestoneIssuesOptions = z.infer<typeof GetMilestoneIssuesSchema>
|
||||
export type GetMilestoneMergeRequestsOptions = z.infer<typeof GetMilestoneMergeRequestsSchema>;
|
||||
export type PromoteProjectMilestoneOptions = z.infer<typeof PromoteProjectMilestoneSchema>;
|
||||
export type GetMilestoneBurndownEventsOptions = z.infer<typeof GetMilestoneBurndownEventsSchema>;
|
||||
export type GitLabUser = z.infer<typeof GitLabUserSchema>;
|
||||
export type GitLabUsersResponse = z.infer<typeof GitLabUsersResponseSchema>;
|
||||
export type PaginationOptions = z.infer<typeof PaginationOptionsSchema>;
|
||||
|
Reference in New Issue
Block a user