Compare commits
27 Commits
Author | SHA1 | Date | |
---|---|---|---|
e4a28a9a47 | |||
9f1e7b5bca | |||
f37e210ee8 | |||
6f789692be | |||
1bb70dccb9 | |||
676bbcd4dd | |||
0bb59a3217 | |||
b908f03801 | |||
5024a2a5af | |||
d2cced1b38 | |||
2fec95d469 | |||
3565d1b397 | |||
353e62a401 | |||
3f2b35535e | |||
026dd58887 | |||
bde83c0a91 | |||
08ab1357a0 | |||
651072dfd7 | |||
bf250b0d88 | |||
3a25e7c5e8 | |||
23a9bbc728 | |||
5398526f94 | |||
bccd5f29c3 | |||
8071fef6c4 | |||
f0eac83788 | |||
7b8cbc0806 | |||
20f62756c1 |
8
CHANGELOG.md
Normal file
8
CHANGELOG.md
Normal file
@ -0,0 +1,8 @@
|
||||
## [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"]
|
97
README.md
97
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/mcp-gitlab"
|
||||
],
|
||||
"env": {
|
||||
"GITLAB_PERSONAL_ACCESS": "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
|
||||
@ -51,34 +85,37 @@ When using with the Claude App, you need to set up your API key and URLs directl
|
||||
7. `create_merge_request` - Create a new merge request in a GitLab project
|
||||
8. `fork_repository` - Fork a GitLab project to your account or specified namespace
|
||||
9. `create_branch` - Create a new branch in a GitLab project
|
||||
10. `get_merge_request` - Get details of a merge request
|
||||
11. `get_merge_request_diffs` - Get the changes/diffs of a merge request
|
||||
12. `update_merge_request` - Update a merge request
|
||||
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. `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
|
||||
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. `list_issues` - List issues in a GitLab project with filtering options
|
||||
19. `get_issue` - Get details of a specific issue in a GitLab project
|
||||
20. `update_issue` - Update an issue in a GitLab project
|
||||
21. `delete_issue` - Delete an issue from a GitLab project
|
||||
22. `list_issue_links` - List all issue links for a specific issue
|
||||
23. `get_issue_link` - Get a specific issue link
|
||||
24. `create_issue_link` - Create an issue link between two issues
|
||||
25. `delete_issue_link` - Delete an issue link
|
||||
26. `list_namespaces` - List all namespaces available to the current user
|
||||
27. `get_namespace` - Get details of a namespace by ID or path
|
||||
28. `verify_namespace` - Verify if a namespace path exists
|
||||
29. `get_project` - Get details of a specific project
|
||||
30. `list_projects` - List projects accessible by the current user
|
||||
31. `list_labels` - List labels for a project
|
||||
32. `get_label` - Get a single label from a project
|
||||
33. `create_label` - Create a new label in a project
|
||||
34. `update_label` - Update an existing label in a project
|
||||
35. `delete_label` - Delete a label from a project
|
||||
36. `list_group_projects` - List projects in a GitLab group with filtering options
|
||||
37. `list_wiki_pages` - List wiki pages in a GitLab project
|
||||
38. `get_wiki_page` - Get details of a specific wiki page
|
||||
39. `create_wiki_page` - Create a new wiki page in a GitLab project
|
||||
40. `update_wiki_page` - Update an existing wiki page in a GitLab project
|
||||
41. `delete_wiki_page` - Delete a wiki page from a GitLab project
|
||||
42. `get_repository_tree` - Get the repository tree for a GitLab project (list files and directories)
|
||||
<!-- TOOLS-END -->
|
||||
|
492
index.ts
492
index.ts
@ -8,9 +8,9 @@ import {
|
||||
} 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';
|
||||
import { HttpProxyAgent } from 'http-proxy-agent';
|
||||
import { SocksProxyAgent } from "socks-proxy-agent";
|
||||
import { HttpsProxyAgent } from "https-proxy-agent";
|
||||
import { HttpProxyAgent } from "http-proxy-agent";
|
||||
import { z } from "zod";
|
||||
import { zodToJsonSchema } from "zod-to-json-schema";
|
||||
import { fileURLToPath } from "url";
|
||||
@ -19,8 +19,8 @@ import fs from "fs";
|
||||
import path from "path";
|
||||
|
||||
// Add type imports for proxy agents
|
||||
import { Agent } from 'http';
|
||||
import { URL } from 'url';
|
||||
import { Agent } from "http";
|
||||
import { URL } from "url";
|
||||
|
||||
import {
|
||||
GitLabForkSchema,
|
||||
@ -75,6 +75,7 @@ import {
|
||||
UpdateLabelSchema,
|
||||
DeleteLabelSchema,
|
||||
CreateNoteSchema,
|
||||
CreateMergeRequestThreadSchema,
|
||||
ListGroupProjectsSchema,
|
||||
ListWikiPagesSchema,
|
||||
GetWikiPageSchema,
|
||||
@ -86,6 +87,7 @@ import {
|
||||
GitLabDiscussionNoteSchema, // Added
|
||||
GitLabDiscussionSchema,
|
||||
UpdateMergeRequestNoteSchema, // Added
|
||||
CreateMergeRequestNoteSchema, // Added
|
||||
ListMergeRequestDiscussionsSchema,
|
||||
type GitLabFork,
|
||||
type GitLabReference,
|
||||
@ -108,11 +110,16 @@ import {
|
||||
// Discussion Types
|
||||
type GitLabDiscussionNote, // Added
|
||||
type GitLabDiscussion,
|
||||
type MergeRequestThreadPosition,
|
||||
type GetWikiPageOptions,
|
||||
type CreateWikiPageOptions,
|
||||
type UpdateWikiPageOptions,
|
||||
type DeleteWikiPageOptions,
|
||||
type GitLabWikiPage,
|
||||
GitLabTreeItemSchema,
|
||||
GetRepositoryTreeSchema,
|
||||
type GitLabTreeItem,
|
||||
type GetRepositoryTreeOptions,
|
||||
} from "./schemas.js";
|
||||
|
||||
/**
|
||||
@ -156,14 +163,14 @@ let httpAgent: Agent | undefined = undefined;
|
||||
let httpsAgent: Agent | undefined = undefined;
|
||||
|
||||
if (HTTP_PROXY) {
|
||||
if (HTTP_PROXY.startsWith('socks')) {
|
||||
if (HTTP_PROXY.startsWith("socks")) {
|
||||
httpAgent = new SocksProxyAgent(HTTP_PROXY);
|
||||
} else {
|
||||
httpAgent = new HttpProxyAgent(HTTP_PROXY);
|
||||
}
|
||||
}
|
||||
if (HTTPS_PROXY) {
|
||||
if (HTTPS_PROXY.startsWith('socks')) {
|
||||
if (HTTPS_PROXY.startsWith("socks")) {
|
||||
httpsAgent = new SocksProxyAgent(HTTPS_PROXY);
|
||||
} else {
|
||||
httpsAgent = new HttpsProxyAgent(HTTPS_PROXY);
|
||||
@ -181,11 +188,11 @@ const DEFAULT_HEADERS = {
|
||||
const DEFAULT_FETCH_CONFIG = {
|
||||
headers: DEFAULT_HEADERS,
|
||||
agent: (parsedUrl: URL) => {
|
||||
if (parsedUrl.protocol === 'https:') {
|
||||
if (parsedUrl.protocol === "https:") {
|
||||
return httpsAgent;
|
||||
}
|
||||
return httpAgent;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
// Define all available tools
|
||||
@ -238,17 +245,20 @@ const allTools = [
|
||||
},
|
||||
{
|
||||
name: "get_merge_request",
|
||||
description: "Get details of a merge request",
|
||||
description:
|
||||
"Get details of a merge request (Either mergeRequestIid or branchName must be provided)",
|
||||
inputSchema: zodToJsonSchema(GetMergeRequestSchema),
|
||||
},
|
||||
{
|
||||
name: "get_merge_request_diffs",
|
||||
description: "Get the changes/diffs of a merge request",
|
||||
description:
|
||||
"Get the changes/diffs of a merge request (Either mergeRequestIid or branchName must be provided)",
|
||||
inputSchema: zodToJsonSchema(GetMergeRequestDiffsSchema),
|
||||
},
|
||||
{
|
||||
name: "update_merge_request",
|
||||
description: "Update a merge request",
|
||||
description:
|
||||
"Update a merge request (Either mergeRequestIid or branchName must be provided)",
|
||||
inputSchema: zodToJsonSchema(UpdateMergeRequestSchema),
|
||||
},
|
||||
{
|
||||
@ -256,6 +266,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",
|
||||
@ -266,6 +281,11 @@ 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: "list_issues",
|
||||
description: "List issues in a GitLab project with filtering options",
|
||||
@ -385,7 +405,13 @@ const allTools = [
|
||||
name: "delete_wiki_page",
|
||||
description: "Delete a wiki page from a GitLab project",
|
||||
inputSchema: zodToJsonSchema(DeleteWikiPageSchema),
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "get_repository_tree",
|
||||
description:
|
||||
"Get the repository tree for a GitLab project (list files and directories)",
|
||||
inputSchema: zodToJsonSchema(GetRepositoryTreeSchema),
|
||||
},
|
||||
];
|
||||
|
||||
// Define which tools are read-only
|
||||
@ -466,12 +492,13 @@ async function handleGitLabError(
|
||||
if (!response.ok) {
|
||||
const errorBody = await response.text();
|
||||
// Check specifically for Rate Limit error
|
||||
if (response.status === 403 && errorBody.includes("User API Key Rate limit exceeded")) {
|
||||
if (
|
||||
response.status === 403 &&
|
||||
errorBody.includes("User API Key Rate limit exceeded")
|
||||
) {
|
||||
console.error("GitLab API Rate Limit Exceeded:", errorBody);
|
||||
console.log("User API Key Rate limit exceeded. Please try again later.");
|
||||
throw new Error(
|
||||
`GitLab API Rate Limit Exceeded: ${errorBody}`
|
||||
);
|
||||
throw new Error(`GitLab API Rate Limit Exceeded: ${errorBody}`);
|
||||
} else {
|
||||
// Handle other API errors
|
||||
throw new Error(
|
||||
@ -493,6 +520,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`
|
||||
);
|
||||
@ -528,6 +556,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
|
||||
@ -555,6 +584,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)}`
|
||||
);
|
||||
@ -582,6 +612,7 @@ async function getFileContents(
|
||||
filePath: string,
|
||||
ref?: string
|
||||
): Promise<GitLabContent> {
|
||||
projectId = decodeURIComponent(projectId); // Decode project ID
|
||||
const encodedPath = encodeURIComponent(filePath);
|
||||
|
||||
// ref가 없는 경우 default branch를 가져옴
|
||||
@ -633,6 +664,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`
|
||||
);
|
||||
@ -672,6 +704,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`
|
||||
);
|
||||
@ -709,6 +742,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
|
||||
@ -738,6 +772,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
|
||||
@ -770,6 +805,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
|
||||
@ -796,6 +832,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
|
||||
@ -825,6 +862,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
|
||||
@ -858,6 +896,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
|
||||
@ -893,6 +933,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
|
||||
@ -919,6 +960,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`
|
||||
);
|
||||
@ -964,6 +1006,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
|
||||
@ -997,17 +1040,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;
|
||||
}
|
||||
|
||||
@ -1022,6 +1069,47 @@ async function updateMergeRequestNote(
|
||||
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
|
||||
* 파일 생성 또는 업데이트
|
||||
@ -1044,6 +1132,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(
|
||||
@ -1126,6 +1215,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
|
||||
@ -1180,6 +1270,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
|
||||
@ -1303,25 +1394,48 @@ async function createRepository(
|
||||
* MR 조회 함수 (Function to retrieve merge request)
|
||||
*
|
||||
* @param {string} projectId - The ID or URL-encoded path of the project
|
||||
* @param {number} mergeRequestIid - The internal ID of the merge request
|
||||
* @param {number} mergeRequestIid - The internal ID of the merge request (Optional)
|
||||
* @param {string} [branchName] - The name of the branch to search for merge request by branch name (Optional)
|
||||
* @returns {Promise<GitLabMergeRequest>} The merge request details
|
||||
*/
|
||||
async function getMergeRequest(
|
||||
projectId: string,
|
||||
mergeRequestIid: number
|
||||
mergeRequestIid?: number,
|
||||
branchName?: string
|
||||
): Promise<GitLabMergeRequest> {
|
||||
const url = new URL(
|
||||
projectId = decodeURIComponent(projectId); // Decode project ID
|
||||
let url: URL;
|
||||
|
||||
if (mergeRequestIid) {
|
||||
url = new URL(
|
||||
`${GITLAB_API_URL}/projects/${encodeURIComponent(
|
||||
projectId
|
||||
)}/merge_requests/${mergeRequestIid}`
|
||||
);
|
||||
} else if (branchName) {
|
||||
url = new URL(
|
||||
`${GITLAB_API_URL}/projects/${encodeURIComponent(
|
||||
projectId
|
||||
)}/merge_requests?source_branch=${encodeURIComponent(branchName)}`
|
||||
);
|
||||
} else {
|
||||
throw new Error("Either mergeRequestIid or branchName must be provided");
|
||||
}
|
||||
|
||||
const response = await fetch(url.toString(), {
|
||||
...DEFAULT_FETCH_CONFIG,
|
||||
});
|
||||
|
||||
await handleGitLabError(response);
|
||||
return GitLabMergeRequestSchema.parse(await response.json());
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
// If response is an array (Comes from branchName search), return the first item if exist
|
||||
if (Array.isArray(data) && data.length > 0) {
|
||||
return GitLabMergeRequestSchema.parse(data[0]);
|
||||
}
|
||||
|
||||
return GitLabMergeRequestSchema.parse(data);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1329,15 +1443,31 @@ async function getMergeRequest(
|
||||
* MR 변경사항 조회 함수 (Function to retrieve merge request changes)
|
||||
*
|
||||
* @param {string} projectId - The ID or URL-encoded path of the project
|
||||
* @param {number} mergeRequestIid - The internal ID of the merge request
|
||||
* @param {number} mergeRequestIid - The internal ID of the merge request (Either mergeRequestIid or branchName must be provided)
|
||||
* @param {string} [branchName] - The name of the branch to search for merge request by branch name (Either mergeRequestIid or branchName must be provided)
|
||||
* @param {string} [view] - The view type for the diff (inline or parallel)
|
||||
* @returns {Promise<GitLabMergeRequestDiff[]>} The merge request diffs
|
||||
*/
|
||||
async function getMergeRequestDiffs(
|
||||
projectId: string,
|
||||
mergeRequestIid: number,
|
||||
mergeRequestIid?: number,
|
||||
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");
|
||||
}
|
||||
|
||||
if (branchName && !mergeRequestIid) {
|
||||
const mergeRequest = await getMergeRequest(
|
||||
projectId,
|
||||
undefined,
|
||||
branchName
|
||||
);
|
||||
mergeRequestIid = mergeRequest.iid;
|
||||
}
|
||||
|
||||
const url = new URL(
|
||||
`${GITLAB_API_URL}/projects/${encodeURIComponent(
|
||||
projectId
|
||||
@ -1362,18 +1492,34 @@ async function getMergeRequestDiffs(
|
||||
* MR 업데이트 함수 (Function to update merge request)
|
||||
*
|
||||
* @param {string} projectId - The ID or URL-encoded path of the project
|
||||
* @param {number} mergeRequestIid - The internal ID of the merge request
|
||||
* @param {number} mergeRequestIid - The internal ID of the merge request (Optional)
|
||||
* @param {string} branchName - The name of the branch to search for merge request by branch name (Optional)
|
||||
* @param {Object} options - The update options
|
||||
* @returns {Promise<GitLabMergeRequest>} The updated merge request
|
||||
*/
|
||||
async function updateMergeRequest(
|
||||
projectId: string,
|
||||
mergeRequestIid: number,
|
||||
options: Omit<
|
||||
z.infer<typeof UpdateMergeRequestSchema>,
|
||||
"project_id" | "merge_request_iid"
|
||||
>
|
||||
"project_id" | "merge_request_iid" | "source_branch"
|
||||
>,
|
||||
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");
|
||||
}
|
||||
|
||||
if (branchName && !mergeRequestIid) {
|
||||
const mergeRequest = await getMergeRequest(
|
||||
projectId,
|
||||
undefined,
|
||||
branchName
|
||||
);
|
||||
mergeRequestIid = mergeRequest.iid;
|
||||
}
|
||||
|
||||
const url = new URL(
|
||||
`${GITLAB_API_URL}/projects/${encodeURIComponent(
|
||||
projectId
|
||||
@ -1407,6 +1553,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(
|
||||
@ -1430,6 +1577,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
|
||||
* 사용 가능한 모든 네임스페이스 목록 조회
|
||||
@ -1535,6 +1735,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)}`
|
||||
);
|
||||
@ -1609,6 +1810,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`
|
||||
@ -1651,6 +1853,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
|
||||
@ -1689,6 +1892,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`,
|
||||
@ -1720,6 +1924,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(
|
||||
@ -1750,6 +1955,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(
|
||||
@ -1841,13 +2047,15 @@ async function listGroupProjects(
|
||||
*/
|
||||
async function listWikiPages(
|
||||
projectId: string,
|
||||
options: Omit<z.infer<typeof ListWikiPagesSchema>, 'project_id'> = {}
|
||||
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`
|
||||
);
|
||||
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.page) url.searchParams.append("page", options.page.toString());
|
||||
if (options.per_page)
|
||||
url.searchParams.append("per_page", options.per_page.toString());
|
||||
const response = await fetch(url.toString(), {
|
||||
...DEFAULT_FETCH_CONFIG,
|
||||
});
|
||||
@ -1863,10 +2071,11 @@ 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)}/wikis/${encodeURIComponent(
|
||||
slug
|
||||
)}`,
|
||||
`${GITLAB_API_URL}/projects/${encodeURIComponent(
|
||||
projectId
|
||||
)}/wikis/${encodeURIComponent(slug)}`,
|
||||
{ ...DEFAULT_FETCH_CONFIG }
|
||||
);
|
||||
await handleGitLabError(response);
|
||||
@ -1883,13 +2092,14 @@ 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(
|
||||
`${GITLAB_API_URL}/projects/${encodeURIComponent(projectId)}/wikis`,
|
||||
{
|
||||
...DEFAULT_FETCH_CONFIG,
|
||||
method: 'POST',
|
||||
method: "POST",
|
||||
body: JSON.stringify(body),
|
||||
}
|
||||
);
|
||||
@ -1908,17 +2118,18 @@ 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;
|
||||
if (format) body.format = format;
|
||||
const response = await fetch(
|
||||
`${GITLAB_API_URL}/projects/${encodeURIComponent(projectId)}/wikis/${encodeURIComponent(
|
||||
slug
|
||||
)}`,
|
||||
`${GITLAB_API_URL}/projects/${encodeURIComponent(
|
||||
projectId
|
||||
)}/wikis/${encodeURIComponent(slug)}`,
|
||||
{
|
||||
...DEFAULT_FETCH_CONFIG,
|
||||
method: 'PUT',
|
||||
method: "PUT",
|
||||
body: JSON.stringify(body),
|
||||
}
|
||||
);
|
||||
@ -1930,34 +2141,96 @@ async function updateWikiPage(
|
||||
/**
|
||||
* Delete a wiki page
|
||||
*/
|
||||
async function deleteWikiPage(
|
||||
projectId: string,
|
||||
slug: string
|
||||
): Promise<void> {
|
||||
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)}/wikis/${encodeURIComponent(
|
||||
slug
|
||||
)}`,
|
||||
`${GITLAB_API_URL}/projects/${encodeURIComponent(
|
||||
projectId
|
||||
)}/wikis/${encodeURIComponent(slug)}`,
|
||||
{
|
||||
...DEFAULT_FETCH_CONFIG,
|
||||
method: 'DELETE',
|
||||
method: "DELETE",
|
||||
}
|
||||
);
|
||||
await handleGitLabError(response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the repository tree for a project
|
||||
* @param {string} projectId - The ID or URL-encoded path of the project
|
||||
* @param {GetRepositoryTreeOptions} options - Options for the tree
|
||||
* @returns {Promise<GitLabTreeItem[]>}
|
||||
*/
|
||||
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.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()}`,
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${GITLAB_PERSONAL_ACCESS_TOKEN}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
if (response.status === 404) {
|
||||
throw new Error("Repository or path not found");
|
||||
}
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Failed to get repository tree: ${response.statusText}`);
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
return z.array(GitLabTreeItemSchema).parse(data);
|
||||
}
|
||||
|
||||
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
||||
// Apply read-only filter first
|
||||
const tools0 = GITLAB_READ_ONLY_MODE
|
||||
? 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가 제거된 도구 목록 반환
|
||||
};
|
||||
});
|
||||
|
||||
@ -2107,8 +2380,24 @@ 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) }],
|
||||
@ -2119,7 +2408,8 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
||||
const args = GetMergeRequestSchema.parse(request.params.arguments);
|
||||
const mergeRequest = await getMergeRequest(
|
||||
args.project_id,
|
||||
args.merge_request_iid
|
||||
args.merge_request_iid,
|
||||
args.source_branch
|
||||
);
|
||||
return {
|
||||
content: [
|
||||
@ -2133,6 +2423,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
||||
const diffs = await getMergeRequestDiffs(
|
||||
args.project_id,
|
||||
args.merge_request_iid,
|
||||
args.source_branch,
|
||||
args.view
|
||||
);
|
||||
return {
|
||||
@ -2142,11 +2433,13 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
||||
|
||||
case "update_merge_request": {
|
||||
const args = UpdateMergeRequestSchema.parse(request.params.arguments);
|
||||
const { project_id, merge_request_iid, ...options } = args;
|
||||
const { project_id, merge_request_iid, source_branch, ...options } =
|
||||
args;
|
||||
const mergeRequest = await updateMergeRequest(
|
||||
project_id,
|
||||
options,
|
||||
merge_request_iid,
|
||||
options
|
||||
source_branch
|
||||
);
|
||||
return {
|
||||
content: [
|
||||
@ -2287,6 +2580,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;
|
||||
@ -2451,33 +2760,82 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
||||
}
|
||||
|
||||
case "list_wiki_pages": {
|
||||
const { project_id, page, per_page } = ListWikiPagesSchema.parse(request.params.arguments);
|
||||
const { project_id, page, per_page } = ListWikiPagesSchema.parse(
|
||||
request.params.arguments
|
||||
);
|
||||
const wikiPages = await listWikiPages(project_id, { page, per_page });
|
||||
return { content: [{ type: "text", text: JSON.stringify(wikiPages, null, 2) }] };
|
||||
return {
|
||||
content: [{ type: "text", text: JSON.stringify(wikiPages, null, 2) }],
|
||||
};
|
||||
}
|
||||
|
||||
case "get_wiki_page": {
|
||||
const { project_id, slug } = GetWikiPageSchema.parse(request.params.arguments);
|
||||
const { project_id, slug } = GetWikiPageSchema.parse(
|
||||
request.params.arguments
|
||||
);
|
||||
const wikiPage = await getWikiPage(project_id, slug);
|
||||
return { content: [{ type: "text", text: JSON.stringify(wikiPage, null, 2) }] };
|
||||
return {
|
||||
content: [{ type: "text", text: JSON.stringify(wikiPage, null, 2) }],
|
||||
};
|
||||
}
|
||||
|
||||
case "create_wiki_page": {
|
||||
const { project_id, title, content, format } = CreateWikiPageSchema.parse(request.params.arguments);
|
||||
const wikiPage = await createWikiPage(project_id, title, content, format);
|
||||
return { content: [{ type: "text", text: JSON.stringify(wikiPage, null, 2) }] };
|
||||
const { project_id, title, content, format } =
|
||||
CreateWikiPageSchema.parse(request.params.arguments);
|
||||
const wikiPage = await createWikiPage(
|
||||
project_id,
|
||||
title,
|
||||
content,
|
||||
format
|
||||
);
|
||||
return {
|
||||
content: [{ type: "text", text: JSON.stringify(wikiPage, null, 2) }],
|
||||
};
|
||||
}
|
||||
|
||||
case "update_wiki_page": {
|
||||
const { project_id, slug, title, content, format } = UpdateWikiPageSchema.parse(request.params.arguments);
|
||||
const wikiPage = await updateWikiPage(project_id, slug, title, content, format);
|
||||
return { content: [{ type: "text", text: JSON.stringify(wikiPage, null, 2) }] };
|
||||
const { project_id, slug, title, content, format } =
|
||||
UpdateWikiPageSchema.parse(request.params.arguments);
|
||||
const wikiPage = await updateWikiPage(
|
||||
project_id,
|
||||
slug,
|
||||
title,
|
||||
content,
|
||||
format
|
||||
);
|
||||
return {
|
||||
content: [{ type: "text", text: JSON.stringify(wikiPage, null, 2) }],
|
||||
};
|
||||
}
|
||||
|
||||
case "delete_wiki_page": {
|
||||
const { project_id, slug } = DeleteWikiPageSchema.parse(request.params.arguments);
|
||||
const { project_id, slug } = DeleteWikiPageSchema.parse(
|
||||
request.params.arguments
|
||||
);
|
||||
await deleteWikiPage(project_id, slug);
|
||||
return { content: [{ type: "text", text: JSON.stringify({ status: "success", message: "Wiki page deleted successfully" }, null, 2) }] };
|
||||
return {
|
||||
content: [
|
||||
{
|
||||
type: "text",
|
||||
text: JSON.stringify(
|
||||
{
|
||||
status: "success",
|
||||
message: "Wiki page deleted successfully",
|
||||
},
|
||||
null,
|
||||
2
|
||||
),
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
case "get_repository_tree": {
|
||||
const args = GetRepositoryTreeSchema.parse(request.params.arguments);
|
||||
const tree = await getRepositoryTree(args);
|
||||
return {
|
||||
content: [{ type: "text", text: JSON.stringify(tree, null, 2) }],
|
||||
};
|
||||
}
|
||||
|
||||
default:
|
||||
|
5
package-lock.json
generated
5
package-lock.json
generated
@ -1,16 +1,17 @@
|
||||
{
|
||||
"name": "@zereight/mcp-gitlab",
|
||||
"version": "1.0.30",
|
||||
"version": "1.0.38",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@zereight/mcp-gitlab",
|
||||
"version": "1.0.30",
|
||||
"version": "1.0.38",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@modelcontextprotocol/sdk": "1.8.0",
|
||||
"@types/node-fetch": "^2.6.12",
|
||||
"form-data": "^4.0.0",
|
||||
"http-proxy-agent": "^7.0.2",
|
||||
"https-proxy-agent": "^7.0.6",
|
||||
"node-fetch": "^3.3.2",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@zereight/mcp-gitlab",
|
||||
"version": "1.0.32",
|
||||
"version": "1.0.39",
|
||||
"description": "MCP server for using the GitLab API",
|
||||
"license": "MIT",
|
||||
"author": "zereight",
|
||||
|
6
release-notes.md
Normal file
6
release-notes.md
Normal file
@ -0,0 +1,6 @@
|
||||
### 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))
|
455
schemas.ts
455
schemas.ts
@ -63,7 +63,8 @@ export const GitLabRepositorySchema = z.object({
|
||||
created_at: z.string().optional(),
|
||||
last_activity_at: z.string().optional(),
|
||||
default_branch: z.string().optional(),
|
||||
namespace: z.object({
|
||||
namespace: z
|
||||
.object({
|
||||
id: z.number(),
|
||||
name: z.string(),
|
||||
path: z.string(),
|
||||
@ -71,7 +72,8 @@ export const GitLabRepositorySchema = z.object({
|
||||
full_path: z.string(),
|
||||
avatar_url: z.string().nullable().optional(),
|
||||
web_url: z.string().optional(),
|
||||
}).optional(),
|
||||
})
|
||||
.optional(),
|
||||
readme_url: z.string().optional().nullable(),
|
||||
topics: z.array(z.string()).optional(),
|
||||
tag_list: z.array(z.string()).optional(), // deprecated but still present
|
||||
@ -79,16 +81,24 @@ export const GitLabRepositorySchema = z.object({
|
||||
archived: z.boolean().optional(),
|
||||
forks_count: z.number().optional(),
|
||||
star_count: z.number().optional(),
|
||||
permissions: z.object({
|
||||
project_access: z.object({
|
||||
permissions: z
|
||||
.object({
|
||||
project_access: z
|
||||
.object({
|
||||
access_level: z.number(),
|
||||
notification_level: z.number().optional(),
|
||||
}).optional().nullable(),
|
||||
group_access: z.object({
|
||||
})
|
||||
.optional()
|
||||
.nullable(),
|
||||
group_access: z
|
||||
.object({
|
||||
access_level: z.number(),
|
||||
notification_level: z.number().optional(),
|
||||
}).optional().nullable(),
|
||||
}).optional(),
|
||||
})
|
||||
.optional()
|
||||
.nullable(),
|
||||
})
|
||||
.optional(),
|
||||
container_registry_enabled: z.boolean().optional(),
|
||||
container_registry_access_level: z.string().optional(),
|
||||
issues_enabled: z.boolean().optional(),
|
||||
@ -97,14 +107,18 @@ 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(z.object({
|
||||
shared_with_groups: z
|
||||
.array(
|
||||
z.object({
|
||||
group_id: z.number(),
|
||||
group_name: z.string(),
|
||||
group_full_path: z.string(),
|
||||
group_access_level: z.number(),
|
||||
})).optional(),
|
||||
})
|
||||
)
|
||||
.optional(),
|
||||
});
|
||||
|
||||
// Project schema (extended from repository schema)
|
||||
@ -146,17 +160,41 @@ export const FileOperationSchema = z.object({
|
||||
});
|
||||
|
||||
// Tree and commit schemas
|
||||
export const GitLabTreeEntrySchema = z.object({
|
||||
id: z.string(), // Changed from sha to match GitLab API
|
||||
export const GitLabTreeItemSchema = z.object({
|
||||
id: z.string(),
|
||||
name: z.string(),
|
||||
type: z.enum(["blob", "tree"]),
|
||||
type: z.enum(["tree", "blob"]),
|
||||
path: z.string(),
|
||||
mode: z.string(),
|
||||
});
|
||||
|
||||
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)"),
|
||||
});
|
||||
|
||||
export const GitLabTreeSchema = z.object({
|
||||
id: z.string(), // Changed from sha to match GitLab API
|
||||
tree: z.array(GitLabTreeEntrySchema),
|
||||
tree: z.array(GitLabTreeItemSchema),
|
||||
});
|
||||
|
||||
export const GitLabCommitSchema = z.object({
|
||||
@ -276,17 +314,21 @@ export const GitLabIssueSchema = z.object({
|
||||
updated_at: z.string(),
|
||||
closed_at: z.string().nullable(),
|
||||
web_url: z.string(), // Changed from html_url to match GitLab API
|
||||
references: z.object({
|
||||
references: z
|
||||
.object({
|
||||
short: z.string(),
|
||||
relative: z.string(),
|
||||
full: z.string(),
|
||||
}).optional(),
|
||||
time_stats: z.object({
|
||||
})
|
||||
.optional(),
|
||||
time_stats: z
|
||||
.object({
|
||||
time_estimate: z.number(),
|
||||
total_time_spent: z.number(),
|
||||
human_time_estimate: z.string().nullable(),
|
||||
human_total_time_spent: z.string().nullable(),
|
||||
}).optional(),
|
||||
})
|
||||
.optional(),
|
||||
confidential: z.boolean().optional(),
|
||||
due_date: z.string().nullable().optional(),
|
||||
discussion_locked: z.boolean().nullable().optional(),
|
||||
@ -296,7 +338,7 @@ export const GitLabIssueSchema = z.object({
|
||||
// NEW SCHEMA: For issue with link details (used in listing issue links)
|
||||
export const GitLabIssueWithLinkDetailsSchema = GitLabIssueSchema.extend({
|
||||
issue_link_id: z.number(),
|
||||
link_type: z.enum(['relates_to', 'blocks', 'is_blocked_by']),
|
||||
link_type: z.enum(["relates_to", "blocks", "is_blocked_by"]),
|
||||
link_created_at: z.string(),
|
||||
link_updated_at: z.string(),
|
||||
});
|
||||
@ -305,11 +347,13 @@ export const GitLabIssueWithLinkDetailsSchema = GitLabIssueSchema.extend({
|
||||
export const GitLabForkParentSchema = z.object({
|
||||
name: z.string(),
|
||||
path_with_namespace: z.string(), // Changed from full_name to match GitLab API
|
||||
owner: z.object({
|
||||
owner: z
|
||||
.object({
|
||||
username: z.string(), // Changed from login to match GitLab API
|
||||
id: z.number(),
|
||||
avatar_url: z.string(),
|
||||
}).optional(), // Made optional to handle cases where GitLab API doesn't include it
|
||||
})
|
||||
.optional(), // Made optional to handle cases where GitLab API doesn't include it
|
||||
web_url: z.string(), // Changed from html_url to match GitLab API
|
||||
});
|
||||
|
||||
@ -377,7 +421,9 @@ export const GitLabDiscussionNoteSchema = z.object({
|
||||
resolved: z.boolean().optional(),
|
||||
resolved_by: GitLabUserSchema.nullable().optional(),
|
||||
resolved_at: z.string().nullable().optional(),
|
||||
position: z.object({ // Only present for DiffNote
|
||||
position: z
|
||||
.object({
|
||||
// Only present for DiffNote
|
||||
base_sha: z.string(),
|
||||
start_sha: z.string(),
|
||||
head_sha: z.string(),
|
||||
@ -386,25 +432,29 @@ export const GitLabDiscussionNoteSchema = z.object({
|
||||
position_type: z.enum(["text", "image", "file"]),
|
||||
old_line: z.number().nullable(),
|
||||
new_line: z.number().nullable(),
|
||||
line_range: z.object({
|
||||
line_range: z
|
||||
.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(),
|
||||
}),
|
||||
}).nullable().optional(), // For multi-line diff notes
|
||||
})
|
||||
.nullable()
|
||||
.optional(), // For multi-line diff notes
|
||||
width: z.number().optional(), // For image diff notes
|
||||
height: z.number().optional(), // For image diff notes
|
||||
x: z.number().optional(), // For image diff notes
|
||||
y: z.number().optional(), // For image diff notes
|
||||
}).optional(),
|
||||
})
|
||||
.optional(),
|
||||
});
|
||||
export type GitLabDiscussionNote = z.infer<typeof GitLabDiscussionNoteSchema>;
|
||||
|
||||
@ -425,8 +475,20 @@ 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)"),
|
||||
});
|
||||
|
||||
// API Operation Parameter Schemas
|
||||
@ -440,10 +502,7 @@ export const CreateOrUpdateFileSchema = ProjectParamsSchema.extend({
|
||||
.string()
|
||||
.optional()
|
||||
.describe("Path of the file to move/rename"),
|
||||
last_commit_id: z
|
||||
.string()
|
||||
.optional()
|
||||
.describe("Last known file commit ID"),
|
||||
last_commit_id: z.string().optional().describe("Last known file commit ID"),
|
||||
commit_id: z
|
||||
.string()
|
||||
.optional()
|
||||
@ -539,7 +598,9 @@ export const GitLabMergeRequestDiffSchema = z.object({
|
||||
export const GetMergeRequestSchema = ProjectParamsSchema.extend({
|
||||
merge_request_iid: z
|
||||
.number()
|
||||
.describe("The internal ID of the merge request"),
|
||||
.optional()
|
||||
.describe("The IID of a merge request"),
|
||||
source_branch: z.string().optional().describe("Source branch name"),
|
||||
});
|
||||
|
||||
export const UpdateMergeRequestSchema = GetMergeRequestSchema.extend({
|
||||
@ -585,22 +646,61 @@ export const CreateNoteSchema = z.object({
|
||||
// Issues API operation schemas
|
||||
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"),
|
||||
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"),
|
||||
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"),
|
||||
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"),
|
||||
milestone: z.string().optional().describe("Milestone title"),
|
||||
scope: z.enum(['created-by-me', 'assigned-to-me', 'all']).optional().describe("Return issues from a specific scope"),
|
||||
scope: z
|
||||
.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"),
|
||||
state: z.enum(['opened', 'closed', 'all']).optional().describe("Return issues with a specific state"),
|
||||
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"),
|
||||
state: z
|
||||
.enum(["opened", "closed", "all"])
|
||||
.optional()
|
||||
.describe("Return issues with a specific state"),
|
||||
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"),
|
||||
});
|
||||
@ -615,13 +715,28 @@ export const UpdateIssueSchema = z.object({
|
||||
issue_iid: z.number().describe("The internal ID of the project issue"),
|
||||
title: z.string().optional().describe("The title of the issue"),
|
||||
description: z.string().optional().describe("The description of the issue"),
|
||||
assignee_ids: z.array(z.number()).optional().describe("Array of user IDs to assign issue to"),
|
||||
confidential: z.boolean().optional().describe("Set the issue to be confidential"),
|
||||
discussion_locked: z.boolean().optional().describe("Flag to lock discussions"),
|
||||
due_date: z.string().optional().describe("Date the issue is due (YYYY-MM-DD)"),
|
||||
assignee_ids: z
|
||||
.array(z.number())
|
||||
.optional()
|
||||
.describe("Array of user IDs to assign issue to"),
|
||||
confidential: z
|
||||
.boolean()
|
||||
.optional()
|
||||
.describe("Set the issue to be confidential"),
|
||||
discussion_locked: z
|
||||
.boolean()
|
||||
.optional()
|
||||
.describe("Flag to lock discussions"),
|
||||
due_date: z
|
||||
.string()
|
||||
.optional()
|
||||
.describe("Date the issue is due (YYYY-MM-DD)"),
|
||||
labels: z.array(z.string()).optional().describe("Array of label names"),
|
||||
milestone_id: z.number().optional().describe("Milestone ID to assign"),
|
||||
state_event: z.enum(['close', 'reopen']).optional().describe("Update issue state (close/reopen)"),
|
||||
state_event: z
|
||||
.enum(["close", "reopen"])
|
||||
.optional()
|
||||
.describe("Update issue state (close/reopen)"),
|
||||
weight: z.number().optional().describe("Weight of the issue (0-9)"),
|
||||
});
|
||||
|
||||
@ -634,7 +749,7 @@ export const DeleteIssueSchema = z.object({
|
||||
export const GitLabIssueLinkSchema = z.object({
|
||||
source_issue: GitLabIssueSchema,
|
||||
target_issue: GitLabIssueSchema,
|
||||
link_type: z.enum(['relates_to', 'blocks', 'is_blocked_by']),
|
||||
link_type: z.enum(["relates_to", "blocks", "is_blocked_by"]),
|
||||
});
|
||||
|
||||
export const ListIssueLinksSchema = z.object({
|
||||
@ -651,9 +766,16 @@ export const GetIssueLinkSchema = z.object({
|
||||
export const CreateIssueLinkSchema = 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"),
|
||||
target_project_id: z.string().describe("The ID or URL-encoded path of a target project"),
|
||||
target_issue_iid: z.number().describe("The internal ID of a target project's issue"),
|
||||
link_type: z.enum(['relates_to', 'blocks', 'is_blocked_by']).optional().describe("The type of the relation, defaults to relates_to"),
|
||||
target_project_id: z
|
||||
.string()
|
||||
.describe("The ID or URL-encoded path of a target project"),
|
||||
target_issue_iid: z
|
||||
.number()
|
||||
.describe("The internal ID of a target project's issue"),
|
||||
link_type: z
|
||||
.enum(["relates_to", "blocks", "is_blocked_by"])
|
||||
.optional()
|
||||
.describe("The type of the relation, defaults to relates_to"),
|
||||
});
|
||||
|
||||
export const DeleteIssueLinkSchema = z.object({
|
||||
@ -667,7 +789,10 @@ 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"),
|
||||
owned: z
|
||||
.boolean()
|
||||
.optional()
|
||||
.describe("Filter for namespaces owned by current user"),
|
||||
});
|
||||
|
||||
export const GetNamespaceSchema = z.object({
|
||||
@ -687,73 +812,164 @@ 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"),
|
||||
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"),
|
||||
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"),
|
||||
simple: z.boolean().optional().describe("Return only limited fields"),
|
||||
archived: z.boolean().optional().describe("Filter for archived projects"),
|
||||
visibility: z.enum(["public", "internal", "private"]).optional().describe("Filter by project visibility"),
|
||||
order_by: z.enum(["id", "name", "path", "created_at", "updated_at", "last_activity_at"]).optional().describe("Return projects ordered by field"),
|
||||
sort: z.enum(["asc", "desc"]).optional().describe("Return projects sorted in ascending or descending order"),
|
||||
with_issues_enabled: z.boolean().optional().describe("Filter projects with issues feature enabled"),
|
||||
with_merge_requests_enabled: z.boolean().optional().describe("Filter projects with merge requests feature enabled"),
|
||||
min_access_level: z.number().optional().describe("Filter by minimum access level"),
|
||||
visibility: z
|
||||
.enum(["public", "internal", "private"])
|
||||
.optional()
|
||||
.describe("Filter by project visibility"),
|
||||
order_by: z
|
||||
.enum([
|
||||
"id",
|
||||
"name",
|
||||
"path",
|
||||
"created_at",
|
||||
"updated_at",
|
||||
"last_activity_at",
|
||||
])
|
||||
.optional()
|
||||
.describe("Return projects ordered by field"),
|
||||
sort: z
|
||||
.enum(["asc", "desc"])
|
||||
.optional()
|
||||
.describe("Return projects sorted in ascending or descending order"),
|
||||
with_issues_enabled: z
|
||||
.boolean()
|
||||
.optional()
|
||||
.describe("Filter projects with issues feature enabled"),
|
||||
with_merge_requests_enabled: z
|
||||
.boolean()
|
||||
.optional()
|
||||
.describe("Filter projects with merge requests feature enabled"),
|
||||
min_access_level: z
|
||||
.number()
|
||||
.optional()
|
||||
.describe("Filter by minimum access level"),
|
||||
});
|
||||
|
||||
// Label operation schemas
|
||||
export const ListLabelsSchema = z.object({
|
||||
project_id: z.string().describe("Project ID or URL-encoded path"),
|
||||
with_counts: z.boolean().optional().describe("Whether or not to include issue and merge request counts"),
|
||||
include_ancestor_groups: z.boolean().optional().describe("Include ancestor groups"),
|
||||
with_counts: z
|
||||
.boolean()
|
||||
.optional()
|
||||
.describe("Whether or not to include issue and merge request counts"),
|
||||
include_ancestor_groups: z
|
||||
.boolean()
|
||||
.optional()
|
||||
.describe("Include ancestor groups"),
|
||||
search: z.string().optional().describe("Keyword to filter labels by"),
|
||||
});
|
||||
|
||||
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"),
|
||||
include_ancestor_groups: z.boolean().optional().describe("Include ancestor groups"),
|
||||
label_id: z.string().describe("The ID or title of a project's label"),
|
||||
include_ancestor_groups: z
|
||||
.boolean()
|
||||
.optional()
|
||||
.describe("Include ancestor groups"),
|
||||
});
|
||||
|
||||
export const CreateLabelSchema = z.object({
|
||||
project_id: z.string().describe("Project ID or URL-encoded path"),
|
||||
name: z.string().describe("The name of the label"),
|
||||
color: z.string().describe("The color of the label given in 6-digit hex notation with leading '#' sign"),
|
||||
color: z
|
||||
.string()
|
||||
.describe(
|
||||
"The color of the label given in 6-digit hex notation with leading '#' sign"
|
||||
),
|
||||
description: z.string().optional().describe("The description of the label"),
|
||||
priority: z.number().nullable().optional().describe("The priority of the label"),
|
||||
priority: z
|
||||
.number()
|
||||
.nullable()
|
||||
.optional()
|
||||
.describe("The priority of the label"),
|
||||
});
|
||||
|
||||
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().optional().describe("The color of the label given in 6-digit hex notation with leading '#' sign"),
|
||||
description: z.string().optional().describe("The new description of the label"),
|
||||
priority: z.number().nullable().optional().describe("The new priority of the label"),
|
||||
color: z
|
||||
.string()
|
||||
.optional()
|
||||
.describe(
|
||||
"The color of the label given in 6-digit hex notation with leading '#' sign"
|
||||
),
|
||||
description: z
|
||||
.string()
|
||||
.optional()
|
||||
.describe("The new description of the label"),
|
||||
priority: z
|
||||
.number()
|
||||
.nullable()
|
||||
.optional()
|
||||
.describe("The new priority of the label"),
|
||||
});
|
||||
|
||||
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
|
||||
export const ListGroupProjectsSchema = z.object({
|
||||
group_id: z.string().describe("Group ID or path"),
|
||||
include_subgroups: z.boolean().optional().describe("Include projects from subgroups"),
|
||||
include_subgroups: z
|
||||
.boolean()
|
||||
.optional()
|
||||
.describe("Include projects from subgroups"),
|
||||
search: z.string().optional().describe("Search term to filter projects"),
|
||||
order_by: z.enum(['name', 'path', 'created_at', 'updated_at', 'last_activity_at']).optional().describe("Field to sort by"),
|
||||
sort: z.enum(['asc', 'desc']).optional().describe("Sort direction"),
|
||||
order_by: z
|
||||
.enum(["name", "path", "created_at", "updated_at", "last_activity_at"])
|
||||
.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"]).optional().describe("Filter by project visibility"),
|
||||
with_issues_enabled: z.boolean().optional().describe("Filter projects with issues feature enabled"),
|
||||
with_merge_requests_enabled: z.boolean().optional().describe("Filter projects with merge requests feature enabled"),
|
||||
min_access_level: z.number().optional().describe("Filter by minimum access level"),
|
||||
with_programming_language: z.string().optional().describe("Filter by programming language"),
|
||||
visibility: z
|
||||
.enum(["public", "internal", "private"])
|
||||
.optional()
|
||||
.describe("Filter by project visibility"),
|
||||
with_issues_enabled: z
|
||||
.boolean()
|
||||
.optional()
|
||||
.describe("Filter projects with issues feature enabled"),
|
||||
with_merge_requests_enabled: z
|
||||
.boolean()
|
||||
.optional()
|
||||
.describe("Filter projects with merge requests feature enabled"),
|
||||
min_access_level: z
|
||||
.number()
|
||||
.optional()
|
||||
.describe("Filter by minimum access level"),
|
||||
with_programming_language: z
|
||||
.string()
|
||||
.optional()
|
||||
.describe("Filter by programming language"),
|
||||
starred: z.boolean().optional().describe("Filter by starred projects"),
|
||||
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")
|
||||
with_custom_attributes: z
|
||||
.boolean()
|
||||
.optional()
|
||||
.describe("Include custom attributes"),
|
||||
with_security_reports: z
|
||||
.boolean()
|
||||
.optional()
|
||||
.describe("Include security reports"),
|
||||
});
|
||||
|
||||
// Add wiki operation schemas
|
||||
@ -770,14 +986,20 @@ export const CreateWikiPageSchema = z.object({
|
||||
project_id: z.string().describe("Project ID or URL-encoded path"),
|
||||
title: z.string().describe("Title of the wiki page"),
|
||||
content: z.string().describe("Content of the wiki page"),
|
||||
format: z.string().optional().describe("Content format, e.g., markdown, rdoc"),
|
||||
format: z
|
||||
.string()
|
||||
.optional()
|
||||
.describe("Content format, e.g., markdown, rdoc"),
|
||||
});
|
||||
export const UpdateWikiPageSchema = z.object({
|
||||
project_id: z.string().describe("Project ID or URL-encoded path"),
|
||||
slug: z.string().describe("URL-encoded slug of the wiki page"),
|
||||
title: z.string().optional().describe("New title of the wiki page"),
|
||||
content: z.string().optional().describe("New content of the wiki page"),
|
||||
format: z.string().optional().describe("Content format, e.g., markdown, rdoc"),
|
||||
format: z
|
||||
.string()
|
||||
.optional()
|
||||
.describe("Content format, e.g., markdown, rdoc"),
|
||||
});
|
||||
export const DeleteWikiPageSchema = z.object({
|
||||
project_id: z.string().describe("Project ID or URL-encoded path"),
|
||||
@ -794,31 +1016,69 @@ 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>;
|
||||
export type GitLabIssue = z.infer<typeof GitLabIssueSchema>;
|
||||
export type GitLabIssueWithLinkDetails = z.infer<typeof GitLabIssueWithLinkDetailsSchema>;
|
||||
export type GitLabIssueWithLinkDetails = z.infer<
|
||||
typeof GitLabIssueWithLinkDetailsSchema
|
||||
>;
|
||||
export type GitLabMergeRequest = z.infer<typeof GitLabMergeRequestSchema>;
|
||||
export type GitLabRepository = z.infer<typeof GitLabRepositorySchema>;
|
||||
export type GitLabFileContent = z.infer<typeof GitLabFileContentSchema>;
|
||||
export type GitLabDirectoryContent = z.infer<typeof GitLabDirectoryContentSchema>;
|
||||
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 GitLabCommit = z.infer<typeof GitLabCommitSchema>;
|
||||
export type GitLabReference = z.infer<typeof GitLabReferenceSchema>;
|
||||
export type CreateRepositoryOptions = z.infer<typeof CreateRepositoryOptionsSchema>;
|
||||
export type CreateRepositoryOptions = z.infer<
|
||||
typeof CreateRepositoryOptionsSchema
|
||||
>;
|
||||
export type CreateIssueOptions = z.infer<typeof CreateIssueOptionsSchema>;
|
||||
export type CreateMergeRequestOptions = z.infer<typeof CreateMergeRequestOptionsSchema>;
|
||||
export type CreateMergeRequestOptions = z.infer<
|
||||
typeof CreateMergeRequestOptionsSchema
|
||||
>;
|
||||
export type CreateBranchOptions = z.infer<typeof CreateBranchOptionsSchema>;
|
||||
export type GitLabCreateUpdateFileResponse = z.infer<typeof GitLabCreateUpdateFileResponseSchema>;
|
||||
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 GitLabMergeRequestDiffSchema
|
||||
>;
|
||||
export type CreateNoteOptions = z.infer<typeof CreateNoteSchema>;
|
||||
export type GitLabIssueLink = z.infer<typeof GitLabIssueLinkSchema>;
|
||||
export type GitLabNamespace = z.infer<typeof GitLabNamespaceSchema>;
|
||||
export type GitLabNamespaceExistsResponse = z.infer<typeof GitLabNamespaceExistsResponseSchema>;
|
||||
export type GitLabNamespaceExistsResponse = z.infer<
|
||||
typeof GitLabNamespaceExistsResponseSchema
|
||||
>;
|
||||
export type GitLabProject = z.infer<typeof GitLabProjectSchema>;
|
||||
export type GitLabLabel = z.infer<typeof GitLabLabelSchema>;
|
||||
export type ListWikiPagesOptions = z.infer<typeof ListWikiPagesSchema>;
|
||||
@ -827,3 +1087,8 @@ export type CreateWikiPageOptions = z.infer<typeof CreateWikiPageSchema>;
|
||||
export type UpdateWikiPageOptions = z.infer<typeof UpdateWikiPageSchema>;
|
||||
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