Compare commits
27 Commits
Author | SHA1 | Date | |
---|---|---|---|
25be1947b9 | |||
864ee77ae6 | |||
dc6cc59434 | |||
5924fd3ed4 | |||
f4b265bf2e | |||
b326f4c3c3 | |||
1350a024b5 | |||
4c57c37888 | |||
e4a28a9a47 | |||
9f1e7b5bca | |||
f37e210ee8 | |||
6f789692be | |||
1bb70dccb9 | |||
676bbcd4dd | |||
0bb59a3217 | |||
b908f03801 | |||
5024a2a5af | |||
d2cced1b38 | |||
2fec95d469 | |||
3565d1b397 | |||
353e62a401 | |||
3f2b35535e | |||
026dd58887 | |||
bde83c0a91 | |||
08ab1357a0 | |||
651072dfd7 | |||
bf250b0d88 |
20
CHANGELOG.md
Normal file
20
CHANGELOG.md
Normal file
@ -0,0 +1,20 @@
|
||||
## [1.0.42] - 2025-05-22
|
||||
|
||||
### Added
|
||||
|
||||
- 이슈(issues)에 노트(note)를 생성하고 수정할 수 있는 기능이 추가되었습니다.
|
||||
- 이제 버그나 할 일 같은 이슈에도 댓글(메모)을 달거나, 이미 단 댓글을 고칠 수 있습니다.
|
||||
- 예시: "버그를 고쳤어요!"라는 댓글을 이슈에 달 수 있고, 필요하면 "버그를 완전히 고쳤어요!"로 바꿀 수 있습니다.
|
||||
- 함수형 프로그래밍 원칙과 SOLID 원칙을 준수하여, 코드의 재사용성과 유지보수성이 높아졌습니다.
|
||||
- 출처: [PR #47](https://github.com/zereight/gitlab-mcp/pull/47)
|
||||
|
||||
---
|
||||
|
||||
## [1.0.38] - 2025-05-17
|
||||
|
||||
### Fixed
|
||||
|
||||
- Added `expanded` property to `start` and `end` in `GitLabDiscussionNoteSchema`
|
||||
Now you can expand or collapse more information at the start and end of discussion notes.
|
||||
Example: In code review, you can choose to show or hide specific parts of the discussion.
|
||||
(See: [PR #40](https://github.com/zereight/gitlab-mcp/pull/40))
|
24
Dockerfile
Normal file
24
Dockerfile
Normal file
@ -0,0 +1,24 @@
|
||||
FROM node:22.15-alpine AS builder
|
||||
|
||||
COPY . /app
|
||||
COPY tsconfig.json /tsconfig.json
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
RUN --mount=type=cache,target=/root/.npm npm install
|
||||
|
||||
RUN --mount=type=cache,target=/root/.npm-production npm ci --ignore-scripts --omit-dev
|
||||
|
||||
FROM node:22.12-alpine AS release
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY --from=builder /app/build /app/build
|
||||
COPY --from=builder /app/package.json /app/package.json
|
||||
COPY --from=builder /app/package-lock.json /app/package-lock.json
|
||||
|
||||
ENV NODE_ENV=production
|
||||
|
||||
RUN npm ci --ignore-scripts --omit-dev
|
||||
|
||||
ENTRYPOINT ["node", "build/index.js"]
|
95
README.md
95
README.md
@ -14,6 +14,8 @@ GitLab MCP(Model Context Protocol) Server. **Includes bug fixes and improvements
|
||||
|
||||
When using with the Claude App, you need to set up your API key and URLs directly.
|
||||
|
||||
#### npx
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
@ -31,8 +33,39 @@ When using with the Claude App, you need to set up your API key and URLs directl
|
||||
}
|
||||
```
|
||||
|
||||
### Environment Variables
|
||||
#### Docker
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"GitLab communication server": {
|
||||
"command": "docker",
|
||||
"args": [
|
||||
"run",
|
||||
"-i",
|
||||
"--rm",
|
||||
"-e",
|
||||
"GITLAB_PERSONAL_ACCESS_TOKEN",
|
||||
"-e",
|
||||
"GITLAB_API_URL",
|
||||
"-e",
|
||||
"GITLAB_READ_ONLY_MODE",
|
||||
"-e",
|
||||
"USE_GITLAB_WIKI",
|
||||
"nkwd/gitlab-mcp"
|
||||
],
|
||||
"env": {
|
||||
"GITLAB_PERSONAL_ACCESS_TOKEN": "your_gitlab_token",
|
||||
"GITLAB_API_URL": "https://gitlab.com/api/v4", // Optional, for self-hosted GitLab
|
||||
"GITLAB_READ_ONLY_MODE": "false",
|
||||
"USE_GITLAB_WIKI": "true"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Environment Variables
|
||||
|
||||
- `GITLAB_PERSONAL_ACCESS_TOKEN`: Your GitLab personal access token.
|
||||
- `GITLAB_API_URL`: Your GitLab API URL. (Default: `https://gitlab.com/api/v4`)
|
||||
@ -42,6 +75,7 @@ When using with the Claude App, you need to set up your API key and URLs directl
|
||||
## 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
|
||||
@ -55,31 +89,36 @@ When using with the Claude App, you need to set up your API key and URLs directl
|
||||
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. `mr_discussions` - List discussion items for a merge request
|
||||
15. `update_merge_request_note` - Modify an existing merge request thread note
|
||||
16. `list_issues` - List issues in a GitLab project with filtering options
|
||||
17. `get_issue` - Get details of a specific issue in a GitLab project
|
||||
18. `update_issue` - Update an issue in a GitLab project
|
||||
19. `delete_issue` - Delete an issue from a GitLab project
|
||||
20. `list_issue_links` - List all issue links for a specific issue
|
||||
21. `get_issue_link` - Get a specific issue link
|
||||
22. `create_issue_link` - Create an issue link between two issues
|
||||
23. `delete_issue_link` - Delete an issue link
|
||||
24. `list_namespaces` - List all namespaces available to the current user
|
||||
25. `get_namespace` - Get details of a namespace by ID or path
|
||||
26. `verify_namespace` - Verify if a namespace path exists
|
||||
27. `get_project` - Get details of a specific project
|
||||
28. `list_projects` - List projects accessible by the current user
|
||||
29. `list_labels` - List labels for a project
|
||||
30. `get_label` - Get a single label from a project
|
||||
31. `create_label` - Create a new label in a project
|
||||
32. `update_label` - Update an existing label in a project
|
||||
33. `delete_label` - Delete a label from a project
|
||||
34. `list_group_projects` - List projects in a GitLab group with filtering options
|
||||
35. `list_wiki_pages` - List wiki pages in a GitLab project
|
||||
36. `get_wiki_page` - Get details of a specific wiki page
|
||||
37. `create_wiki_page` - Create a new wiki page in a GitLab project
|
||||
38. `update_wiki_page` - Update an existing wiki page in a GitLab project
|
||||
39. `delete_wiki_page` - Delete a wiki page from a GitLab project
|
||||
40. `get_repository_tree` - Get the repository tree for a GitLab project (list files and directories)
|
||||
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` - Update the content of an existing issue 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)
|
||||
<!-- TOOLS-END -->
|
||||
|
407
index.ts
407
index.ts
@ -61,6 +61,7 @@ import {
|
||||
GitLabIssueLinkSchema,
|
||||
GitLabIssueWithLinkDetailsSchema,
|
||||
ListIssueLinksSchema,
|
||||
ListIssueDiscussionsSchema,
|
||||
GetIssueLinkSchema,
|
||||
CreateIssueLinkSchema,
|
||||
DeleteIssueLinkSchema,
|
||||
@ -75,6 +76,7 @@ import {
|
||||
UpdateLabelSchema,
|
||||
DeleteLabelSchema,
|
||||
CreateNoteSchema,
|
||||
CreateMergeRequestThreadSchema,
|
||||
ListGroupProjectsSchema,
|
||||
ListWikiPagesSchema,
|
||||
GetWikiPageSchema,
|
||||
@ -86,6 +88,7 @@ import {
|
||||
GitLabDiscussionNoteSchema, // Added
|
||||
GitLabDiscussionSchema,
|
||||
UpdateMergeRequestNoteSchema, // Added
|
||||
CreateMergeRequestNoteSchema, // Added
|
||||
ListMergeRequestDiscussionsSchema,
|
||||
type GitLabFork,
|
||||
type GitLabReference,
|
||||
@ -108,6 +111,7 @@ import {
|
||||
// Discussion Types
|
||||
type GitLabDiscussionNote, // Added
|
||||
type GitLabDiscussion,
|
||||
type MergeRequestThreadPosition,
|
||||
type GetWikiPageOptions,
|
||||
type CreateWikiPageOptions,
|
||||
type UpdateWikiPageOptions,
|
||||
@ -117,6 +121,8 @@ import {
|
||||
GetRepositoryTreeSchema,
|
||||
type GitLabTreeItem,
|
||||
type GetRepositoryTreeOptions,
|
||||
UpdateIssueNoteSchema,
|
||||
CreateIssueNoteSchema,
|
||||
} from "./schemas.js";
|
||||
|
||||
/**
|
||||
@ -263,6 +269,11 @@ const allTools = [
|
||||
description: "Create a new note (comment) to an issue or merge request",
|
||||
inputSchema: zodToJsonSchema(CreateNoteSchema),
|
||||
},
|
||||
{
|
||||
name: "create_merge_request_thread",
|
||||
description: "Create a new thread on a merge request",
|
||||
inputSchema: zodToJsonSchema(CreateMergeRequestThreadSchema),
|
||||
},
|
||||
{
|
||||
name: "mr_discussions",
|
||||
description: "List discussion items for a merge request",
|
||||
@ -273,6 +284,21 @@ const allTools = [
|
||||
description: "Modify an existing merge request thread note",
|
||||
inputSchema: zodToJsonSchema(UpdateMergeRequestNoteSchema),
|
||||
},
|
||||
{
|
||||
name: "create_merge_request_note",
|
||||
description: "Add a new note to an existing merge request thread",
|
||||
inputSchema: zodToJsonSchema(CreateMergeRequestNoteSchema),
|
||||
},
|
||||
{
|
||||
name: "update_issue_note",
|
||||
description: "Modify an existing issue thread note",
|
||||
inputSchema: zodToJsonSchema(UpdateIssueNoteSchema),
|
||||
},
|
||||
{
|
||||
name: "create_issue_note",
|
||||
description: "Add a new note to an existing issue thread",
|
||||
inputSchema: zodToJsonSchema(CreateIssueNoteSchema),
|
||||
},
|
||||
{
|
||||
name: "list_issues",
|
||||
description: "List issues in a GitLab project with filtering options",
|
||||
@ -298,6 +324,11 @@ const allTools = [
|
||||
description: "List all issue links for a specific issue",
|
||||
inputSchema: zodToJsonSchema(ListIssueLinksSchema),
|
||||
},
|
||||
{
|
||||
name: "list_issue_discussions",
|
||||
description: "List discussions for an issue in a GitLab project",
|
||||
inputSchema: zodToJsonSchema(ListIssueDiscussionsSchema),
|
||||
},
|
||||
{
|
||||
name: "get_issue_link",
|
||||
description: "Get a specific issue link",
|
||||
@ -395,7 +426,8 @@ const allTools = [
|
||||
},
|
||||
{
|
||||
name: "get_repository_tree",
|
||||
description: "Get the repository tree for a GitLab project (list files and directories)",
|
||||
description:
|
||||
"Get the repository tree for a GitLab project (list files and directories)",
|
||||
inputSchema: zodToJsonSchema(GetRepositoryTreeSchema),
|
||||
},
|
||||
];
|
||||
@ -410,6 +442,7 @@ const readOnlyTools = [
|
||||
"list_issues",
|
||||
"get_issue",
|
||||
"list_issue_links",
|
||||
"list_issue_discussions",
|
||||
"get_issue_link",
|
||||
"list_namespaces",
|
||||
"get_namespace",
|
||||
@ -506,6 +539,7 @@ async function forkProject(
|
||||
projectId: string,
|
||||
namespace?: string
|
||||
): Promise<GitLabFork> {
|
||||
projectId = decodeURIComponent(projectId); // Decode project ID
|
||||
const url = new URL(
|
||||
`${GITLAB_API_URL}/projects/${encodeURIComponent(projectId)}/fork`
|
||||
);
|
||||
@ -541,6 +575,7 @@ async function createBranch(
|
||||
projectId: string,
|
||||
options: z.infer<typeof CreateBranchOptionsSchema>
|
||||
): Promise<GitLabReference> {
|
||||
projectId = decodeURIComponent(projectId); // Decode project ID
|
||||
const url = new URL(
|
||||
`${GITLAB_API_URL}/projects/${encodeURIComponent(
|
||||
projectId
|
||||
@ -568,6 +603,7 @@ async function createBranch(
|
||||
* @returns {Promise<string>} The name of the default branch
|
||||
*/
|
||||
async function getDefaultBranchRef(projectId: string): Promise<string> {
|
||||
projectId = decodeURIComponent(projectId); // Decode project ID
|
||||
const url = new URL(
|
||||
`${GITLAB_API_URL}/projects/${encodeURIComponent(projectId)}`
|
||||
);
|
||||
@ -595,6 +631,7 @@ async function getFileContents(
|
||||
filePath: string,
|
||||
ref?: string
|
||||
): Promise<GitLabContent> {
|
||||
projectId = decodeURIComponent(projectId); // Decode project ID
|
||||
const encodedPath = encodeURIComponent(filePath);
|
||||
|
||||
// ref가 없는 경우 default branch를 가져옴
|
||||
@ -646,6 +683,7 @@ async function createIssue(
|
||||
projectId: string,
|
||||
options: z.infer<typeof CreateIssueOptionsSchema>
|
||||
): Promise<GitLabIssue> {
|
||||
projectId = decodeURIComponent(projectId); // Decode project ID
|
||||
const url = new URL(
|
||||
`${GITLAB_API_URL}/projects/${encodeURIComponent(projectId)}/issues`
|
||||
);
|
||||
@ -685,6 +723,7 @@ async function listIssues(
|
||||
projectId: string,
|
||||
options: Omit<z.infer<typeof ListIssuesSchema>, "project_id"> = {}
|
||||
): Promise<GitLabIssue[]> {
|
||||
projectId = decodeURIComponent(projectId); // Decode project ID
|
||||
const url = new URL(
|
||||
`${GITLAB_API_URL}/projects/${encodeURIComponent(projectId)}/issues`
|
||||
);
|
||||
@ -722,6 +761,7 @@ async function getIssue(
|
||||
projectId: string,
|
||||
issueIid: number
|
||||
): Promise<GitLabIssue> {
|
||||
projectId = decodeURIComponent(projectId); // Decode project ID
|
||||
const url = new URL(
|
||||
`${GITLAB_API_URL}/projects/${encodeURIComponent(
|
||||
projectId
|
||||
@ -751,6 +791,7 @@ async function updateIssue(
|
||||
issueIid: number,
|
||||
options: Omit<z.infer<typeof UpdateIssueSchema>, "project_id" | "issue_iid">
|
||||
): Promise<GitLabIssue> {
|
||||
projectId = decodeURIComponent(projectId); // Decode project ID
|
||||
const url = new URL(
|
||||
`${GITLAB_API_URL}/projects/${encodeURIComponent(
|
||||
projectId
|
||||
@ -783,6 +824,7 @@ async function updateIssue(
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async function deleteIssue(projectId: string, issueIid: number): Promise<void> {
|
||||
projectId = decodeURIComponent(projectId); // Decode project ID
|
||||
const url = new URL(
|
||||
`${GITLAB_API_URL}/projects/${encodeURIComponent(
|
||||
projectId
|
||||
@ -809,6 +851,7 @@ async function listIssueLinks(
|
||||
projectId: string,
|
||||
issueIid: number
|
||||
): Promise<GitLabIssueWithLinkDetails[]> {
|
||||
projectId = decodeURIComponent(projectId); // Decode project ID
|
||||
const url = new URL(
|
||||
`${GITLAB_API_URL}/projects/${encodeURIComponent(
|
||||
projectId
|
||||
@ -838,6 +881,7 @@ async function getIssueLink(
|
||||
issueIid: number,
|
||||
issueLinkId: number
|
||||
): Promise<GitLabIssueLink> {
|
||||
projectId = decodeURIComponent(projectId); // Decode project ID
|
||||
const url = new URL(
|
||||
`${GITLAB_API_URL}/projects/${encodeURIComponent(
|
||||
projectId
|
||||
@ -871,6 +915,8 @@ async function createIssueLink(
|
||||
targetIssueIid: number,
|
||||
linkType: "relates_to" | "blocks" | "is_blocked_by" = "relates_to"
|
||||
): Promise<GitLabIssueLink> {
|
||||
projectId = decodeURIComponent(projectId); // Decode project ID
|
||||
targetProjectId = decodeURIComponent(targetProjectId); // Decode target project ID as well
|
||||
const url = new URL(
|
||||
`${GITLAB_API_URL}/projects/${encodeURIComponent(
|
||||
projectId
|
||||
@ -906,6 +952,7 @@ async function deleteIssueLink(
|
||||
issueIid: number,
|
||||
issueLinkId: number
|
||||
): Promise<void> {
|
||||
projectId = decodeURIComponent(projectId); // Decode project ID
|
||||
const url = new URL(
|
||||
`${GITLAB_API_URL}/projects/${encodeURIComponent(
|
||||
projectId
|
||||
@ -932,6 +979,7 @@ async function createMergeRequest(
|
||||
projectId: string,
|
||||
options: z.infer<typeof CreateMergeRequestOptionsSchema>
|
||||
): Promise<GitLabMergeRequest> {
|
||||
projectId = decodeURIComponent(projectId); // Decode project ID
|
||||
const url = new URL(
|
||||
`${GITLAB_API_URL}/projects/${encodeURIComponent(projectId)}/merge_requests`
|
||||
);
|
||||
@ -977,6 +1025,7 @@ async function listMergeRequestDiscussions(
|
||||
projectId: string,
|
||||
mergeRequestIid: number
|
||||
): Promise<GitLabDiscussion[]> {
|
||||
projectId = decodeURIComponent(projectId); // Decode project ID
|
||||
const url = new URL(
|
||||
`${GITLAB_API_URL}/projects/${encodeURIComponent(
|
||||
projectId
|
||||
@ -993,6 +1042,56 @@ async function listMergeRequestDiscussions(
|
||||
return z.array(GitLabDiscussionSchema).parse(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* List discussions for an issue
|
||||
*
|
||||
* @param {string} projectId - The ID or URL-encoded path of the project
|
||||
* @param {number} issueIid - The internal ID of the project issue
|
||||
* @param {Object} options - Pagination and sorting options
|
||||
* @returns {Promise<GitLabDiscussion[]>} List of issue discussions
|
||||
*/
|
||||
async function listIssueDiscussions(
|
||||
projectId: string,
|
||||
issueIid: number,
|
||||
options: {
|
||||
page?: number,
|
||||
per_page?: number,
|
||||
sort?: "asc" | "desc",
|
||||
order_by?: "created_at" | "updated_at"
|
||||
} = {}
|
||||
): Promise<GitLabDiscussion[]> {
|
||||
projectId = decodeURIComponent(projectId); // Decode project ID
|
||||
const url = new URL(
|
||||
`${GITLAB_API_URL}/projects/${encodeURIComponent(
|
||||
projectId
|
||||
)}/issues/${issueIid}/discussions`
|
||||
);
|
||||
|
||||
// Add query parameters for pagination and sorting
|
||||
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.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();
|
||||
|
||||
// Parse the response as an array of discussions
|
||||
return z.array(GitLabDiscussionSchema).parse(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Modify an existing merge request thread note
|
||||
* 병합 요청 토론 노트 수정
|
||||
@ -1010,17 +1109,21 @@ async function updateMergeRequestNote(
|
||||
mergeRequestIid: number,
|
||||
discussionId: string,
|
||||
noteId: number,
|
||||
body: string,
|
||||
body?: string,
|
||||
resolved?: boolean
|
||||
): Promise<GitLabDiscussionNote> {
|
||||
projectId = decodeURIComponent(projectId); // Decode project ID
|
||||
const url = new URL(
|
||||
`${GITLAB_API_URL}/projects/${encodeURIComponent(
|
||||
projectId
|
||||
)}/merge_requests/${mergeRequestIid}/discussions/${discussionId}/notes/${noteId}`
|
||||
);
|
||||
|
||||
const payload: { body: string; resolved?: boolean } = { body };
|
||||
if (resolved !== undefined) {
|
||||
// Only one of body or resolved can be sent according to GitLab API
|
||||
const payload: { body?: string; resolved?: boolean } = {};
|
||||
if (body !== undefined) {
|
||||
payload.body = body;
|
||||
} else if (resolved !== undefined) {
|
||||
payload.resolved = resolved;
|
||||
}
|
||||
|
||||
@ -1035,6 +1138,122 @@ async function updateMergeRequestNote(
|
||||
return GitLabDiscussionNoteSchema.parse(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update an issue discussion note
|
||||
* @param {string} projectId - The ID or URL-encoded path of the project
|
||||
* @param {number} issueIid - The IID of an issue
|
||||
* @param {string} discussionId - The ID of a thread
|
||||
* @param {number} noteId - The ID of a thread note
|
||||
* @param {string} body - The new content of the note
|
||||
* @returns {Promise<GitLabDiscussionNote>} The updated note
|
||||
*/
|
||||
async function updateIssueNote(
|
||||
projectId: string,
|
||||
issueIid: number,
|
||||
discussionId: string,
|
||||
noteId: number,
|
||||
body: string
|
||||
): Promise<GitLabDiscussionNote> {
|
||||
projectId = decodeURIComponent(projectId); // Decode project ID
|
||||
const url = new URL(
|
||||
`${GITLAB_API_URL}/projects/${encodeURIComponent(
|
||||
projectId
|
||||
)}/issues/${issueIid}/discussions/${discussionId}/notes/${noteId}`
|
||||
);
|
||||
|
||||
const payload = { body };
|
||||
|
||||
const response = await fetch(url.toString(), {
|
||||
...DEFAULT_FETCH_CONFIG,
|
||||
method: "PUT",
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
|
||||
await handleGitLabError(response);
|
||||
const data = await response.json();
|
||||
return GitLabDiscussionNoteSchema.parse(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a note in an issue discussion
|
||||
* @param {string} projectId - The ID or URL-encoded path of the project
|
||||
* @param {number} issueIid - The IID of an issue
|
||||
* @param {string} discussionId - The ID of a thread
|
||||
* @param {string} body - The content of the new note
|
||||
* @param {string} [createdAt] - The creation date of the note (ISO 8601 format)
|
||||
* @returns {Promise<GitLabDiscussionNote>} The created note
|
||||
*/
|
||||
async function createIssueNote(
|
||||
projectId: string,
|
||||
issueIid: number,
|
||||
discussionId: string,
|
||||
body: string,
|
||||
createdAt?: string
|
||||
): Promise<GitLabDiscussionNote> {
|
||||
projectId = decodeURIComponent(projectId); // Decode project ID
|
||||
const url = new URL(
|
||||
`${GITLAB_API_URL}/projects/${encodeURIComponent(
|
||||
projectId
|
||||
)}/issues/${issueIid}/discussions/${discussionId}/notes`
|
||||
);
|
||||
|
||||
const payload: { body: string; created_at?: string } = { body };
|
||||
if (createdAt) {
|
||||
payload.created_at = createdAt;
|
||||
}
|
||||
|
||||
const response = await fetch(url.toString(), {
|
||||
...DEFAULT_FETCH_CONFIG,
|
||||
method: "POST",
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
|
||||
await handleGitLabError(response);
|
||||
const data = await response.json();
|
||||
return GitLabDiscussionNoteSchema.parse(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new note to an existing merge request thread
|
||||
* 기존 병합 요청 스레드에 새 노트 추가
|
||||
*
|
||||
* @param {string} projectId - The ID or URL-encoded path of the project
|
||||
* @param {number} mergeRequestIid - The IID of a merge request
|
||||
* @param {string} discussionId - The ID of a thread
|
||||
* @param {string} body - The content of the new note
|
||||
* @param {string} [createdAt] - The creation date of the note (ISO 8601 format)
|
||||
* @returns {Promise<GitLabDiscussionNote>} The created note
|
||||
*/
|
||||
async function createMergeRequestNote(
|
||||
projectId: string,
|
||||
mergeRequestIid: number,
|
||||
discussionId: string,
|
||||
body: string,
|
||||
createdAt?: string
|
||||
): Promise<GitLabDiscussionNote> {
|
||||
projectId = decodeURIComponent(projectId); // Decode project ID
|
||||
const url = new URL(
|
||||
`${GITLAB_API_URL}/projects/${encodeURIComponent(
|
||||
projectId
|
||||
)}/merge_requests/${mergeRequestIid}/discussions/${discussionId}/notes`
|
||||
);
|
||||
|
||||
const payload: { body: string; created_at?: string } = { body };
|
||||
if (createdAt) {
|
||||
payload.created_at = createdAt;
|
||||
}
|
||||
|
||||
const response = await fetch(url.toString(), {
|
||||
...DEFAULT_FETCH_CONFIG,
|
||||
method: "POST",
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
|
||||
await handleGitLabError(response);
|
||||
const data = await response.json();
|
||||
return GitLabDiscussionNoteSchema.parse(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create or update a file in a GitLab project
|
||||
* 파일 생성 또는 업데이트
|
||||
@ -1057,6 +1276,7 @@ async function createOrUpdateFile(
|
||||
last_commit_id?: string,
|
||||
commit_id?: string
|
||||
): Promise<GitLabCreateUpdateFileResponse> {
|
||||
projectId = decodeURIComponent(projectId); // Decode project ID
|
||||
const encodedPath = encodeURIComponent(filePath);
|
||||
const url = new URL(
|
||||
`${GITLAB_API_URL}/projects/${encodeURIComponent(
|
||||
@ -1139,6 +1359,7 @@ async function createTree(
|
||||
files: FileOperation[],
|
||||
ref?: string
|
||||
): Promise<GitLabTree> {
|
||||
projectId = decodeURIComponent(projectId); // Decode project ID
|
||||
const url = new URL(
|
||||
`${GITLAB_API_URL}/projects/${encodeURIComponent(
|
||||
projectId
|
||||
@ -1193,6 +1414,7 @@ async function createCommit(
|
||||
branch: string,
|
||||
actions: FileOperation[]
|
||||
): Promise<GitLabCommit> {
|
||||
projectId = decodeURIComponent(projectId); // Decode project ID
|
||||
const url = new URL(
|
||||
`${GITLAB_API_URL}/projects/${encodeURIComponent(
|
||||
projectId
|
||||
@ -1325,6 +1547,7 @@ async function getMergeRequest(
|
||||
mergeRequestIid?: number,
|
||||
branchName?: string
|
||||
): Promise<GitLabMergeRequest> {
|
||||
projectId = decodeURIComponent(projectId); // Decode project ID
|
||||
let url: URL;
|
||||
|
||||
if (mergeRequestIid) {
|
||||
@ -1375,6 +1598,7 @@ async function getMergeRequestDiffs(
|
||||
branchName?: string,
|
||||
view?: "inline" | "parallel"
|
||||
): Promise<GitLabMergeRequestDiff[]> {
|
||||
projectId = decodeURIComponent(projectId); // Decode project ID
|
||||
if (!mergeRequestIid && !branchName) {
|
||||
throw new Error("Either mergeRequestIid or branchName must be provided");
|
||||
}
|
||||
@ -1426,6 +1650,7 @@ async function updateMergeRequest(
|
||||
mergeRequestIid?: number,
|
||||
branchName?: string
|
||||
): Promise<GitLabMergeRequest> {
|
||||
projectId = decodeURIComponent(projectId); // Decode project ID
|
||||
if (!mergeRequestIid && !branchName) {
|
||||
throw new Error("Either mergeRequestIid or branchName must be provided");
|
||||
}
|
||||
@ -1472,6 +1697,7 @@ async function createNote(
|
||||
noteableIid: number,
|
||||
body: string
|
||||
): Promise<any> {
|
||||
projectId = decodeURIComponent(projectId); // Decode project ID
|
||||
// ⚙️ 응답 타입은 GitLab API 문서에 따라 조정 가능
|
||||
const url = new URL(
|
||||
`${GITLAB_API_URL}/projects/${encodeURIComponent(
|
||||
@ -1495,6 +1721,59 @@ async function createNote(
|
||||
return await response.json();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new thread on a merge request
|
||||
* 📦 새로운 함수: createMergeRequestThread - 병합 요청에 새로운 스레드(토론)를 생성하는 함수
|
||||
* (New function: createMergeRequestThread - Function to create a new thread (discussion) on a merge request)
|
||||
*
|
||||
* This function provides more capabilities than createNote, including the ability to:
|
||||
* - Create diff notes (comments on specific lines of code)
|
||||
* - Specify exact positions for comments
|
||||
* - Set creation timestamps
|
||||
*
|
||||
* @param {string} projectId - The ID or URL-encoded path of the project
|
||||
* @param {number} mergeRequestIid - The internal ID of the merge request
|
||||
* @param {string} body - The content of the thread
|
||||
* @param {MergeRequestThreadPosition} [position] - Position information for diff notes
|
||||
* @param {string} [createdAt] - ISO 8601 formatted creation date
|
||||
* @returns {Promise<GitLabDiscussion>} The created discussion thread
|
||||
*/
|
||||
async function createMergeRequestThread(
|
||||
projectId: string,
|
||||
mergeRequestIid: number,
|
||||
body: string,
|
||||
position?: MergeRequestThreadPosition,
|
||||
createdAt?: string
|
||||
): Promise<GitLabDiscussion> {
|
||||
projectId = decodeURIComponent(projectId); // Decode project ID
|
||||
const url = new URL(
|
||||
`${GITLAB_API_URL}/projects/${encodeURIComponent(
|
||||
projectId
|
||||
)}/merge_requests/${mergeRequestIid}/discussions`
|
||||
);
|
||||
|
||||
const payload: Record<string, any> = { body };
|
||||
|
||||
// Add optional parameters if provided
|
||||
if (position) {
|
||||
payload.position = position;
|
||||
}
|
||||
|
||||
if (createdAt) {
|
||||
payload.created_at = createdAt;
|
||||
}
|
||||
|
||||
const response = await fetch(url.toString(), {
|
||||
...DEFAULT_FETCH_CONFIG,
|
||||
method: "POST",
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
|
||||
await handleGitLabError(response);
|
||||
const data = await response.json();
|
||||
return GitLabDiscussionSchema.parse(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* List all namespaces
|
||||
* 사용 가능한 모든 네임스페이스 목록 조회
|
||||
@ -1600,6 +1879,7 @@ async function getProject(
|
||||
with_custom_attributes?: boolean;
|
||||
} = {}
|
||||
): Promise<GitLabProject> {
|
||||
projectId = decodeURIComponent(projectId); // Decode project ID
|
||||
const url = new URL(
|
||||
`${GITLAB_API_URL}/projects/${encodeURIComponent(projectId)}`
|
||||
);
|
||||
@ -1674,6 +1954,7 @@ async function listLabels(
|
||||
projectId: string,
|
||||
options: Omit<z.infer<typeof ListLabelsSchema>, "project_id"> = {}
|
||||
): Promise<GitLabLabel[]> {
|
||||
projectId = decodeURIComponent(projectId); // Decode project ID
|
||||
// Construct the URL with project path
|
||||
const url = new URL(
|
||||
`${GITLAB_API_URL}/projects/${encodeURIComponent(projectId)}/labels`
|
||||
@ -1716,6 +1997,7 @@ async function getLabel(
|
||||
labelId: number | string,
|
||||
includeAncestorGroups?: boolean
|
||||
): Promise<GitLabLabel> {
|
||||
projectId = decodeURIComponent(projectId); // Decode project ID
|
||||
const url = new URL(
|
||||
`${GITLAB_API_URL}/projects/${encodeURIComponent(
|
||||
projectId
|
||||
@ -1754,6 +2036,7 @@ async function createLabel(
|
||||
projectId: string,
|
||||
options: Omit<z.infer<typeof CreateLabelSchema>, "project_id">
|
||||
): Promise<GitLabLabel> {
|
||||
projectId = decodeURIComponent(projectId); // Decode project ID
|
||||
// Make the API request
|
||||
const response = await fetch(
|
||||
`${GITLAB_API_URL}/projects/${encodeURIComponent(projectId)}/labels`,
|
||||
@ -1785,6 +2068,7 @@ async function updateLabel(
|
||||
labelId: number | string,
|
||||
options: Omit<z.infer<typeof UpdateLabelSchema>, "project_id" | "label_id">
|
||||
): Promise<GitLabLabel> {
|
||||
projectId = decodeURIComponent(projectId); // Decode project ID
|
||||
// Make the API request
|
||||
const response = await fetch(
|
||||
`${GITLAB_API_URL}/projects/${encodeURIComponent(
|
||||
@ -1815,6 +2099,7 @@ async function deleteLabel(
|
||||
projectId: string,
|
||||
labelId: number | string
|
||||
): Promise<void> {
|
||||
projectId = decodeURIComponent(projectId); // Decode project ID
|
||||
// Make the API request
|
||||
const response = await fetch(
|
||||
`${GITLAB_API_URL}/projects/${encodeURIComponent(
|
||||
@ -1908,6 +2193,7 @@ async function listWikiPages(
|
||||
projectId: string,
|
||||
options: Omit<z.infer<typeof ListWikiPagesSchema>, "project_id"> = {}
|
||||
): Promise<GitLabWikiPage[]> {
|
||||
projectId = decodeURIComponent(projectId); // Decode project ID
|
||||
const url = new URL(
|
||||
`${GITLAB_API_URL}/projects/${encodeURIComponent(projectId)}/wikis`
|
||||
);
|
||||
@ -1929,6 +2215,7 @@ async function getWikiPage(
|
||||
projectId: string,
|
||||
slug: string
|
||||
): Promise<GitLabWikiPage> {
|
||||
projectId = decodeURIComponent(projectId); // Decode project ID
|
||||
const response = await fetch(
|
||||
`${GITLAB_API_URL}/projects/${encodeURIComponent(
|
||||
projectId
|
||||
@ -1949,6 +2236,7 @@ async function createWikiPage(
|
||||
content: string,
|
||||
format?: string
|
||||
): Promise<GitLabWikiPage> {
|
||||
projectId = decodeURIComponent(projectId); // Decode project ID
|
||||
const body: Record<string, any> = { title, content };
|
||||
if (format) body.format = format;
|
||||
const response = await fetch(
|
||||
@ -1974,6 +2262,7 @@ async function updateWikiPage(
|
||||
content?: string,
|
||||
format?: string
|
||||
): Promise<GitLabWikiPage> {
|
||||
projectId = decodeURIComponent(projectId); // Decode project ID
|
||||
const body: Record<string, any> = {};
|
||||
if (title) body.title = title;
|
||||
if (content) body.content = content;
|
||||
@ -1997,6 +2286,7 @@ async function updateWikiPage(
|
||||
* Delete a wiki page
|
||||
*/
|
||||
async function deleteWikiPage(projectId: string, slug: string): Promise<void> {
|
||||
projectId = decodeURIComponent(projectId); // Decode project ID
|
||||
const response = await fetch(
|
||||
`${GITLAB_API_URL}/projects/${encodeURIComponent(
|
||||
projectId
|
||||
@ -2018,16 +2308,20 @@ async function deleteWikiPage(projectId: string, slug: string): Promise<void> {
|
||||
async function getRepositoryTree(
|
||||
options: GetRepositoryTreeOptions
|
||||
): Promise<GitLabTreeItem[]> {
|
||||
options.project_id = decodeURIComponent(options.project_id); // Decode project_id within options
|
||||
const queryParams = new URLSearchParams();
|
||||
if (options.path) queryParams.append("path", options.path);
|
||||
if (options.ref) queryParams.append("ref", options.ref);
|
||||
if (options.recursive) queryParams.append("recursive", "true");
|
||||
if (options.per_page) queryParams.append("per_page", options.per_page.toString());
|
||||
if (options.per_page)
|
||||
queryParams.append("per_page", options.per_page.toString());
|
||||
if (options.page_token) queryParams.append("page_token", options.page_token);
|
||||
if (options.pagination) queryParams.append("pagination", options.pagination);
|
||||
|
||||
const response = await fetch(
|
||||
`${GITLAB_API_URL}/projects/${encodeURIComponent(options.project_id)}/repository/tree?${queryParams.toString()}`,
|
||||
`${GITLAB_API_URL}/projects/${encodeURIComponent(
|
||||
options.project_id
|
||||
)}/repository/tree?${queryParams.toString()}`,
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${GITLAB_PERSONAL_ACCESS_TOKEN}`,
|
||||
@ -2054,12 +2348,33 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
||||
? allTools.filter((tool) => readOnlyTools.includes(tool.name))
|
||||
: allTools;
|
||||
// Toggle wiki tools by USE_GITLAB_WIKI flag
|
||||
const tools = USE_GITLAB_WIKI
|
||||
let tools = USE_GITLAB_WIKI
|
||||
? tools0
|
||||
: tools0.filter((tool) => !wikiToolNames.includes(tool.name));
|
||||
|
||||
// <<< START: Gemini 호환성을 위해 $schema 제거 >>>
|
||||
tools = tools.map((tool) => {
|
||||
// inputSchema가 존재하고 객체인지 확인
|
||||
if (
|
||||
tool.inputSchema &&
|
||||
typeof tool.inputSchema === "object" &&
|
||||
tool.inputSchema !== null
|
||||
) {
|
||||
// $schema 키가 존재하면 삭제
|
||||
if ("$schema" in tool.inputSchema) {
|
||||
// 불변성을 위해 새로운 객체 생성 (선택적이지만 권장)
|
||||
const modifiedSchema = { ...tool.inputSchema };
|
||||
delete modifiedSchema.$schema;
|
||||
return { ...tool, inputSchema: modifiedSchema };
|
||||
}
|
||||
}
|
||||
// 변경이 필요 없으면 그대로 반환
|
||||
return tool;
|
||||
});
|
||||
// <<< END: Gemini 호환성을 위해 $schema 제거 >>>
|
||||
|
||||
return {
|
||||
tools,
|
||||
tools, // $schema가 제거된 도구 목록 반환
|
||||
};
|
||||
});
|
||||
|
||||
@ -2209,8 +2524,56 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
||||
args.merge_request_iid,
|
||||
args.discussion_id,
|
||||
args.note_id,
|
||||
args.body, // Now optional
|
||||
args.resolved // Now one of body or resolved must be provided, not both
|
||||
);
|
||||
return {
|
||||
content: [{ type: "text", text: JSON.stringify(note, null, 2) }],
|
||||
};
|
||||
}
|
||||
|
||||
case "create_merge_request_note": {
|
||||
const args = CreateMergeRequestNoteSchema.parse(
|
||||
request.params.arguments
|
||||
);
|
||||
const note = await createMergeRequestNote(
|
||||
args.project_id,
|
||||
args.merge_request_iid,
|
||||
args.discussion_id,
|
||||
args.body,
|
||||
args.resolved // Pass resolved if provided
|
||||
args.created_at
|
||||
);
|
||||
return {
|
||||
content: [{ type: "text", text: JSON.stringify(note, null, 2) }],
|
||||
};
|
||||
}
|
||||
|
||||
case "update_issue_note": {
|
||||
const args = UpdateIssueNoteSchema.parse(
|
||||
request.params.arguments
|
||||
);
|
||||
const note = await updateIssueNote(
|
||||
args.project_id,
|
||||
args.issue_iid,
|
||||
args.discussion_id,
|
||||
args.note_id,
|
||||
args.body
|
||||
);
|
||||
return {
|
||||
content: [{ type: "text", text: JSON.stringify(note, null, 2) }],
|
||||
};
|
||||
}
|
||||
|
||||
case "create_issue_note": {
|
||||
const args = CreateIssueNoteSchema.parse(
|
||||
request.params.arguments
|
||||
);
|
||||
const note = await createIssueNote(
|
||||
args.project_id,
|
||||
args.issue_iid,
|
||||
args.discussion_id,
|
||||
args.body,
|
||||
args.created_at
|
||||
);
|
||||
return {
|
||||
content: [{ type: "text", text: JSON.stringify(note, null, 2) }],
|
||||
@ -2393,6 +2756,22 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
||||
};
|
||||
}
|
||||
|
||||
case "create_merge_request_thread": {
|
||||
const args = CreateMergeRequestThreadSchema.parse(request.params.arguments);
|
||||
const { project_id, merge_request_iid, body, position, created_at } = args;
|
||||
|
||||
const thread = await createMergeRequestThread(
|
||||
project_id,
|
||||
merge_request_iid,
|
||||
body,
|
||||
position,
|
||||
created_at
|
||||
);
|
||||
return {
|
||||
content: [{ type: "text", text: JSON.stringify(thread, null, 2) }],
|
||||
};
|
||||
}
|
||||
|
||||
case "list_issues": {
|
||||
const args = ListIssuesSchema.parse(request.params.arguments);
|
||||
const { project_id, ...options } = args;
|
||||
@ -2444,6 +2823,16 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
||||
};
|
||||
}
|
||||
|
||||
case "list_issue_discussions": {
|
||||
const args = ListIssueDiscussionsSchema.parse(request.params.arguments);
|
||||
const { project_id, issue_iid, ...options } = args;
|
||||
|
||||
const discussions = await listIssueDiscussions(project_id, issue_iid, options);
|
||||
return {
|
||||
content: [{ type: "text", text: JSON.stringify(discussions, null, 2) }],
|
||||
};
|
||||
}
|
||||
|
||||
case "get_issue_link": {
|
||||
const args = GetIssueLinkSchema.parse(request.params.arguments);
|
||||
const link = await getIssueLink(
|
||||
|
4
package-lock.json
generated
4
package-lock.json
generated
@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@zereight/mcp-gitlab",
|
||||
"version": "1.0.33",
|
||||
"version": "1.0.38",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@zereight/mcp-gitlab",
|
||||
"version": "1.0.33",
|
||||
"version": "1.0.38",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@modelcontextprotocol/sdk": "1.8.0",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@zereight/mcp-gitlab",
|
||||
"version": "1.0.34",
|
||||
"version": "1.0.42",
|
||||
"description": "MCP server for using the GitLab API",
|
||||
"license": "MIT",
|
||||
"author": "zereight",
|
||||
|
5
release-notes.md
Normal file
5
release-notes.md
Normal file
@ -0,0 +1,5 @@
|
||||
### 1.0.40 (2025-05-21)
|
||||
|
||||
- Added support for listing discussions (comments/notes) on GitLab issues.
|
||||
- Example: You can now easily fetch all conversations (comments) attached to an issue via the API.
|
||||
- Related PR: [#44](https://github.com/zereight/gitlab-mcp/pull/44)
|
111
schemas.ts
111
schemas.ts
@ -107,7 +107,7 @@ export const GitLabRepositorySchema = z.object({
|
||||
jobs_enabled: z.boolean().optional(),
|
||||
snippets_enabled: z.boolean().optional(),
|
||||
can_create_merge_request_in: z.boolean().optional(),
|
||||
resolve_outdated_diff_discussions: z.boolean().optional(),
|
||||
resolve_outdated_diff_discussions: z.boolean().nullable().optional(),
|
||||
shared_runners_enabled: z.boolean().optional(),
|
||||
shared_with_groups: z
|
||||
.array(
|
||||
@ -171,11 +171,25 @@ export const GitLabTreeItemSchema = z.object({
|
||||
export const GetRepositoryTreeSchema = z.object({
|
||||
project_id: z.string().describe("The ID or URL-encoded path of the project"),
|
||||
path: z.string().optional().describe("The path inside the repository"),
|
||||
ref: z.string().optional().describe("The name of a repository branch or tag. Defaults to the default branch."),
|
||||
recursive: z.boolean().optional().describe("Boolean value to get a recursive tree"),
|
||||
per_page: z.number().optional().describe("Number of results to show per page"),
|
||||
page_token: z.string().optional().describe("The tree record ID for pagination"),
|
||||
pagination: z.string().optional().describe("Pagination method (keyset)")
|
||||
ref: z
|
||||
.string()
|
||||
.optional()
|
||||
.describe(
|
||||
"The name of a repository branch or tag. Defaults to the default branch."
|
||||
),
|
||||
recursive: z
|
||||
.boolean()
|
||||
.optional()
|
||||
.describe("Boolean value to get a recursive tree"),
|
||||
per_page: z
|
||||
.number()
|
||||
.optional()
|
||||
.describe("Number of results to show per page"),
|
||||
page_token: z
|
||||
.string()
|
||||
.optional()
|
||||
.describe("The tree record ID for pagination"),
|
||||
pagination: z.string().optional().describe("Pagination method (keyset)"),
|
||||
});
|
||||
|
||||
export const GitLabTreeSchema = z.object({
|
||||
@ -422,13 +436,13 @@ export const GitLabDiscussionNoteSchema = z.object({
|
||||
.object({
|
||||
start: z.object({
|
||||
line_code: z.string(),
|
||||
type: z.enum(["new", "old"]),
|
||||
type: z.enum(["new", "old", "expanded"]),
|
||||
old_line: z.number().nullable(),
|
||||
new_line: z.number().nullable(),
|
||||
}),
|
||||
end: z.object({
|
||||
line_code: z.string(),
|
||||
type: z.enum(["new", "old"]),
|
||||
type: z.enum(["new", "old", "expanded"]),
|
||||
old_line: z.number().nullable(),
|
||||
new_line: z.number().nullable(),
|
||||
}),
|
||||
@ -461,8 +475,36 @@ export const UpdateMergeRequestNoteSchema = ProjectParamsSchema.extend({
|
||||
merge_request_iid: z.number().describe("The IID of a merge request"),
|
||||
discussion_id: z.string().describe("The ID of a thread"),
|
||||
note_id: z.number().describe("The ID of a thread note"),
|
||||
body: z.string().optional().describe("The content of the note or reply"),
|
||||
resolved: z.boolean().optional().describe("Resolve or unresolve the note"),
|
||||
}).refine(data => data.body !== undefined || data.resolved !== undefined, {
|
||||
message: "At least one of 'body' or 'resolved' must be provided"
|
||||
}).refine(data => !(data.body !== undefined && data.resolved !== undefined), {
|
||||
message: "Only one of 'body' or 'resolved' can be provided, not both"
|
||||
});
|
||||
|
||||
// Input schema for adding a note to an existing merge request discussion
|
||||
export const CreateMergeRequestNoteSchema = ProjectParamsSchema.extend({
|
||||
merge_request_iid: z.number().describe("The IID of a merge request"),
|
||||
discussion_id: z.string().describe("The ID of a thread"),
|
||||
body: z.string().describe("The content of the note or reply"),
|
||||
resolved: z.boolean().optional().describe("Resolve or unresolve the note"), // Optional based on API docs
|
||||
created_at: z.string().optional().describe("Date the note was created at (ISO 8601 format)"),
|
||||
});
|
||||
|
||||
// Input schema for updating an issue discussion note
|
||||
export const UpdateIssueNoteSchema = ProjectParamsSchema.extend({
|
||||
issue_iid: z.number().describe("The IID of an issue"),
|
||||
discussion_id: z.string().describe("The ID of a thread"),
|
||||
note_id: z.number().describe("The ID of a thread note"),
|
||||
body: z.string().describe("The content of the note or reply"),
|
||||
});
|
||||
|
||||
// Input schema for adding a note to an existing issue discussion
|
||||
export const CreateIssueNoteSchema = ProjectParamsSchema.extend({
|
||||
issue_iid: z.number().describe("The IID of an issue"),
|
||||
discussion_id: z.string().describe("The ID of a thread"),
|
||||
body: z.string().describe("The content of the note or reply"),
|
||||
created_at: z.string().optional().describe("Date the note was created at (ISO 8601 format)"),
|
||||
});
|
||||
|
||||
// API Operation Parameter Schemas
|
||||
@ -731,6 +773,15 @@ 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"),
|
||||
@ -849,9 +900,7 @@ export const ListLabelsSchema = z.object({
|
||||
|
||||
export const GetLabelSchema = z.object({
|
||||
project_id: z.string().describe("Project ID or URL-encoded path"),
|
||||
label_id: z
|
||||
.union([z.number(), z.string()])
|
||||
.describe("The ID or title of a project's label"),
|
||||
label_id: z.string().describe("The ID or title of a project's label"),
|
||||
include_ancestor_groups: z
|
||||
.boolean()
|
||||
.optional()
|
||||
@ -876,9 +925,7 @@ export const CreateLabelSchema = z.object({
|
||||
|
||||
export const UpdateLabelSchema = z.object({
|
||||
project_id: z.string().describe("Project ID or URL-encoded path"),
|
||||
label_id: z
|
||||
.union([z.number(), z.string()])
|
||||
.describe("The ID or title of a project's label"),
|
||||
label_id: z.string().describe("The ID or title of a project's label"),
|
||||
new_name: z.string().optional().describe("The new name of the label"),
|
||||
color: z
|
||||
.string()
|
||||
@ -899,9 +946,7 @@ export const UpdateLabelSchema = z.object({
|
||||
|
||||
export const DeleteLabelSchema = z.object({
|
||||
project_id: z.string().describe("Project ID or URL-encoded path"),
|
||||
label_id: z
|
||||
.union([z.number(), z.string()])
|
||||
.describe("The ID or title of a project's label"),
|
||||
label_id: z.string().describe("The ID or title of a project's label"),
|
||||
});
|
||||
|
||||
// Group projects schema
|
||||
@ -996,6 +1041,30 @@ export const GitLabWikiPageSchema = z.object({
|
||||
updated_at: z.string().optional(),
|
||||
});
|
||||
|
||||
// Merge Request Thread position schema - used for diff notes
|
||||
export const MergeRequestThreadPositionSchema = z.object({
|
||||
base_sha: z.string().describe("Base commit SHA in the source branch"),
|
||||
head_sha: z.string().describe("SHA referencing HEAD of the source branch"),
|
||||
start_sha: z.string().describe("SHA referencing the start commit of the source branch"),
|
||||
position_type: z.enum(["text", "image", "file"]).describe("Type of position reference"),
|
||||
new_path: z.string().optional().describe("File path after change"),
|
||||
old_path: z.string().optional().describe("File path before change"),
|
||||
new_line: z.number().nullable().optional().describe("Line number after change"),
|
||||
old_line: z.number().nullable().optional().describe("Line number before change"),
|
||||
width: z.number().optional().describe("Width of the image (for image diffs)"),
|
||||
height: z.number().optional().describe("Height of the image (for image diffs)"),
|
||||
x: z.number().optional().describe("X coordinate on the image (for image diffs)"),
|
||||
y: z.number().optional().describe("Y coordinate on the image (for image diffs)"),
|
||||
});
|
||||
|
||||
// Schema for creating a new merge request thread
|
||||
export const CreateMergeRequestThreadSchema = ProjectParamsSchema.extend({
|
||||
merge_request_iid: z.number().describe("The IID of a merge request"),
|
||||
body: z.string().describe("The content of the thread"),
|
||||
position: MergeRequestThreadPositionSchema.optional().describe("Position when creating a diff note"),
|
||||
created_at: z.string().optional().describe("Date the thread was created at (ISO 8601 format)"),
|
||||
});
|
||||
|
||||
// Export types
|
||||
export type GitLabAuthor = z.infer<typeof GitLabAuthorSchema>;
|
||||
export type GitLabFork = z.infer<typeof GitLabForkSchema>;
|
||||
@ -1031,6 +1100,9 @@ export type GitLabMergeRequestDiff = z.infer<
|
||||
>;
|
||||
export type CreateNoteOptions = z.infer<typeof CreateNoteSchema>;
|
||||
export type GitLabIssueLink = z.infer<typeof GitLabIssueLinkSchema>;
|
||||
export type ListIssueDiscussionsOptions = z.infer<typeof ListIssueDiscussionsSchema>;
|
||||
export type UpdateIssueNoteOptions = z.infer<typeof UpdateIssueNoteSchema>;
|
||||
export type CreateIssueNoteOptions = z.infer<typeof CreateIssueNoteSchema>;
|
||||
export type GitLabNamespace = z.infer<typeof GitLabNamespaceSchema>;
|
||||
export type GitLabNamespaceExistsResponse = z.infer<
|
||||
typeof GitLabNamespaceExistsResponseSchema
|
||||
@ -1045,3 +1117,6 @@ export type DeleteWikiPageOptions = z.infer<typeof DeleteWikiPageSchema>;
|
||||
export type GitLabWikiPage = z.infer<typeof GitLabWikiPageSchema>;
|
||||
export type GitLabTreeItem = z.infer<typeof GitLabTreeItemSchema>;
|
||||
export type GetRepositoryTreeOptions = z.infer<typeof GetRepositoryTreeSchema>;
|
||||
export type MergeRequestThreadPosition = z.infer<typeof MergeRequestThreadPositionSchema>;
|
||||
export type CreateMergeRequestThreadOptions = z.infer<typeof CreateMergeRequestThreadSchema>;
|
||||
export type CreateMergeRequestNoteOptions = z.infer<typeof CreateMergeRequestNoteSchema>;
|
||||
|
Reference in New Issue
Block a user