@zereight/mcp-gitlab 2.3.25-next.221 → 2.3.25-next.222
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ko.md +4 -0
- package/README.md +2 -0
- package/README.pt-BR.md +4 -0
- package/README.zh-CN.md +4 -0
- package/build/index.js +20 -202
- package/build/tools/tags.js +226 -0
- package/package.json +1 -1
package/README.ko.md
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
# GitLab MCP Server
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/@zereight/mcp-gitlab)
|
|
4
|
+
[](https://github.com/zereight/gitlab-mcp/blob/main/LICENSE)
|
|
5
|
+
[](https://scorecard.dev/viewer/?uri=github.com/zereight/gitlab-mcp)
|
|
6
|
+
[](https://github.com/zereight/gitlab-mcp/actions/workflows/codeql.yml?query=branch%3Amain)
|
|
7
|
+
[](https://github.com/zereight/gitlab-mcp/actions/workflows/live-tests.yml?query=branch%3Amain)
|
|
4
8
|
|
|
5
9
|
[English](./README.md) | [한국어](./README.ko.md) | [简体中文](./README.zh-CN.md) | [Português (Brasil)](./README.pt-BR.md)
|
|
6
10
|
|
package/README.md
CHANGED
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
[](https://www.npmjs.com/package/@zereight/mcp-gitlab)
|
|
6
6
|
[](https://github.com/zereight/gitlab-mcp/blob/main/LICENSE)
|
|
7
7
|
[](https://scorecard.dev/viewer/?uri=github.com/zereight/gitlab-mcp)
|
|
8
|
+
[](https://github.com/zereight/gitlab-mcp/actions/workflows/codeql.yml?query=branch%3Amain)
|
|
9
|
+
[](https://github.com/zereight/gitlab-mcp/actions/workflows/live-tests.yml?query=branch%3Amain)
|
|
8
10
|
[](https://deepwiki.com/zereight/gitlab-mcp)
|
|
9
11
|
[](https://mcptoplist.com/server/io.github.zereight%2Fgitlab-mcp)
|
|
10
12
|
[](https://mcpindex.ai/server/io-github-zereight-gitlab-mcp)
|
package/README.pt-BR.md
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
# GitLab MCP Server
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/@zereight/mcp-gitlab)
|
|
4
|
+
[](https://github.com/zereight/gitlab-mcp/blob/main/LICENSE)
|
|
5
|
+
[](https://scorecard.dev/viewer/?uri=github.com/zereight/gitlab-mcp)
|
|
6
|
+
[](https://github.com/zereight/gitlab-mcp/actions/workflows/codeql.yml?query=branch%3Amain)
|
|
7
|
+
[](https://github.com/zereight/gitlab-mcp/actions/workflows/live-tests.yml?query=branch%3Amain)
|
|
4
8
|
|
|
5
9
|
[English](./README.md) | [한국어](./README.ko.md) | [简体中文](./README.zh-CN.md) | [Português (Brasil)](./README.pt-BR.md)
|
|
6
10
|
|
package/README.zh-CN.md
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
# GitLab MCP Server
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/@zereight/mcp-gitlab)
|
|
4
|
+
[](https://github.com/zereight/gitlab-mcp/blob/main/LICENSE)
|
|
5
|
+
[](https://scorecard.dev/viewer/?uri=github.com/zereight/gitlab-mcp)
|
|
6
|
+
[](https://github.com/zereight/gitlab-mcp/actions/workflows/codeql.yml?query=branch%3Amain)
|
|
7
|
+
[](https://github.com/zereight/gitlab-mcp/actions/workflows/live-tests.yml?query=branch%3Amain)
|
|
4
8
|
|
|
5
9
|
[English](./README.md) | [한국어](./README.ko.md) | [简体中文](./README.zh-CN.md) | [Português (Brasil)](./README.pt-BR.md)
|
|
6
10
|
|
package/build/index.js
CHANGED
|
@@ -135,6 +135,7 @@ import { executeGitLabApiRequestAsync, GitLabApiRequestHttpError, GitLabApiReque
|
|
|
135
135
|
import { configureWikiTools, handleWikiToolCall } from "./tools/wiki.js";
|
|
136
136
|
import { configureMilestoneTools, handleMilestoneToolCall } from "./tools/milestones.js";
|
|
137
137
|
import { configureLabelTools, handleLabelToolCall } from "./tools/labels.js";
|
|
138
|
+
import { configureTagTools, handleTagToolCall } from "./tools/tags.js";
|
|
138
139
|
import { buildUnavailableToolMessage, isSkippedByDiscoverActivation, } from "./tools/discover-activation.js";
|
|
139
140
|
import { selectCallableHiddenToolNames, selectExposedTools } from "./tools/exposed-tools.js";
|
|
140
141
|
import { createListedToolsCache, decorateToolsForList, } from "./tools/listed-tools.js";
|
|
@@ -145,8 +146,8 @@ import { BulkPublishDraftNotesSchema, CancelPipelineJobSchema, ErasePipelineJobS
|
|
|
145
146
|
GitLabDiscussionNoteSchema, // Added
|
|
146
147
|
GitLabDiscussionSchema,
|
|
147
148
|
// Draft Notes Schemas
|
|
148
|
-
GitLabDraftNoteSchema, GitLabForkSchema, GitLabBranchSchema, GitLabProtectedBranchSchema,
|
|
149
|
-
GetMergeRequestFileDiffSchema, ListMergeRequestChangedFilesSchema, ListMergeRequestDiscussionsSchema, ListMergeRequestPipelinesSchema, ListMergeRequestsSchema, ListGroupMergeRequestsSchema, ListMergeRequestVersionsSchema, GetMergeRequestVersionSchema, GitLabMergeRequestVersionSchema, GitLabMergeRequestVersionDetailSchema, ListNamespacesSchema, ListPipelineJobsSchema, ListPipelinesSchema, ListDeploymentsSchema, ListEnvironmentsSchema, ListProjectRunnersSchema, GetRunnerSchema, ListPipelineTriggerJobsSchema, ValidateCiLintSchema, ValidateProjectCiLintSchema, ListCiCatalogResourcesSchema, GetCiCatalogResourceSchema, ListProjectMembersSchema, ListGroupMembersSchema, ListProjectsSchema, MarkdownUploadSchema, MarkdownUploadRemoteSchema, DownloadAttachmentSchema, DownloadJobArtifactsSchema, GetJobArtifactFileSchema, GitLabArtifactEntrySchema, ListJobArtifactsSchema, MergeMergeRequestSchema, ApproveMergeRequestSchema, UnapproveMergeRequestSchema, RebaseMergeRequestSchema, GetMergeRequestApprovalStateSchema, GetMergeRequestConflictsSchema, GitLabMergeRequestApprovalStateSchema, MyIssuesSchema, OrbitQuerySchema, OrbitSchemaSchema, OrbitStatusSchema, OrbitToolsSchema, MarkAllTodosDoneSchema, MarkTodoDoneSchema, PaginatedDiscussionsResponseSchema, PublishDraftNoteSchema, PlayPipelineJobSchema, PushFilesSchema, RetryPipelineJobSchema, RetryPipelineSchema, SearchCodeSchema, SearchGroupCodeSchema, SearchProjectCodeSchema, SearchRepositoriesSchema, UpdateDraftNoteSchema, UpdateIssueNoteSchema, UpdateIssueSchema, UpdateIssueDescriptionPatchSchema, ReorderIssueSchema, UpdateProjectSchema, UpdateMergeRequestNoteSchema, UpdateMergeRequestDiscussionNoteSchema, UpdateMergeRequestSchema, VerifyNamespaceSchema, GitLabEventSchema, ListEventsSchema, GetProjectEventsSchema, ExecuteGraphQLSchema, GitLabReleaseSchema, ListReleasesSchema, GetReleaseSchema, CreateReleaseSchema, UpdateReleaseSchema, DeleteReleaseSchema, CreateReleaseEvidenceSchema, DownloadReleaseAssetSchema,
|
|
149
|
+
GitLabDraftNoteSchema, GitLabForkSchema, GitLabBranchSchema, GitLabProtectedBranchSchema, GitLabGroupSchema, GitLabIssueLinkSchema, GitLabIssueSchema, GitLabIssueWithLinkDetailsSchema, GitLabMarkdownUploadSchema, GitLabMergeRequestPipelineSchema, GitLabMergeRequestSchema, GitLabNamespaceExistsResponseSchema, GitLabNamespaceSchema, GitLabPipelineJobSchema, GitLabDeploymentSchema, GitLabEnvironmentSchema, GitLabPipelineSchema, GitLabPipelineScheduleSchema, GitLabPipelineScheduleVariableSchema, GitLabPipelineSchedulePlayResultSchema, ListPipelineSchedulesSchema, GetPipelineScheduleSchema, ListPipelineSchedulePipelinesSchema, CreatePipelineScheduleSchema, UpdatePipelineScheduleSchema, DeletePipelineScheduleSchema, PlayPipelineScheduleSchema, TakeOwnershipPipelineScheduleSchema, GetPipelineScheduleVariableSchema, CreatePipelineScheduleVariableSchema, UpdatePipelineScheduleVariableSchema, DeletePipelineScheduleVariableSchema, GitLabPipelineTriggerJobSchema, GitLabProjectMemberSchema, GitLabProjectSchema, GitLabTodoSchema, GitLabReferenceSchema, GitLabRepositorySchema, GitLabSearchBlobResultSchema, GitLabSearchResponseSchema, GitLabTreeItemSchema, GitLabUserSchema, GitLabUsersResponseSchema, GroupIteration, ListCommitStatusesSchema, ListBranchesSchema, ListCommitsSchema, ListDraftNotesSchema, ListGroupIterationsSchema, GetGroupIterationSchema, UpdateGroupIterationSchema, CreateGroupIterationSchema, GroupIterationCadence, ListGroupIterationCadencesSchema, DeleteGroupIterationSchema, ListProjectIterationsSchema, CreateGroupIterationCadenceSchema, UpdateGroupIterationCadenceSchema, DeleteGroupIterationCadenceSchema, ListGroupProjectsSchema, GitLabCiVariableSchema, ListProjectVariablesSchema, GetProjectVariableSchema, CreateProjectVariableSchema, UpdateProjectVariableSchema, DeleteProjectVariableSchema, ListGroupVariablesSchema, GetGroupVariableSchema, CreateGroupVariableSchema, UpdateGroupVariableSchema, DeleteGroupVariableSchema, GitLabDependencyProxySchema, GitLabDependencyProxyBlobSchema, GetDependencyProxySettingsSchema, UpdateDependencyProxySettingsSchema, ListDependencyProxyBlobsSchema, PurgeDependencyProxyCacheSchema, ListProjectVulnerabilitiesSchema, GetVulnerabilitySchema, DismissVulnerabilitySchema, ConfirmVulnerabilitySchema, ListIssueDiscussionsSchema, ListIssueLinksSchema, ListIssuesSchema, ListTodosSchema, ListMergeRequestDiffsSchema, // Added
|
|
150
|
+
GetMergeRequestFileDiffSchema, ListMergeRequestChangedFilesSchema, ListMergeRequestDiscussionsSchema, ListMergeRequestPipelinesSchema, ListMergeRequestsSchema, ListGroupMergeRequestsSchema, ListMergeRequestVersionsSchema, GetMergeRequestVersionSchema, GitLabMergeRequestVersionSchema, GitLabMergeRequestVersionDetailSchema, ListNamespacesSchema, ListPipelineJobsSchema, ListPipelinesSchema, ListDeploymentsSchema, ListEnvironmentsSchema, ListProjectRunnersSchema, GetRunnerSchema, ListPipelineTriggerJobsSchema, ValidateCiLintSchema, ValidateProjectCiLintSchema, ListCiCatalogResourcesSchema, GetCiCatalogResourceSchema, ListProjectMembersSchema, ListGroupMembersSchema, ListProjectsSchema, MarkdownUploadSchema, MarkdownUploadRemoteSchema, DownloadAttachmentSchema, DownloadJobArtifactsSchema, GetJobArtifactFileSchema, GitLabArtifactEntrySchema, ListJobArtifactsSchema, MergeMergeRequestSchema, ApproveMergeRequestSchema, UnapproveMergeRequestSchema, RebaseMergeRequestSchema, GetMergeRequestApprovalStateSchema, GetMergeRequestConflictsSchema, GitLabMergeRequestApprovalStateSchema, MyIssuesSchema, OrbitQuerySchema, OrbitSchemaSchema, OrbitStatusSchema, OrbitToolsSchema, MarkAllTodosDoneSchema, MarkTodoDoneSchema, PaginatedDiscussionsResponseSchema, PublishDraftNoteSchema, PlayPipelineJobSchema, PushFilesSchema, RetryPipelineJobSchema, RetryPipelineSchema, SearchCodeSchema, SearchGroupCodeSchema, SearchProjectCodeSchema, SearchRepositoriesSchema, UpdateDraftNoteSchema, UpdateIssueNoteSchema, UpdateIssueSchema, UpdateIssueDescriptionPatchSchema, ReorderIssueSchema, UpdateProjectSchema, UpdateMergeRequestNoteSchema, UpdateMergeRequestDiscussionNoteSchema, UpdateMergeRequestSchema, VerifyNamespaceSchema, GitLabEventSchema, ListEventsSchema, GetProjectEventsSchema, ExecuteGraphQLSchema, GitLabReleaseSchema, ListReleasesSchema, GetReleaseSchema, CreateReleaseSchema, UpdateReleaseSchema, DeleteReleaseSchema, CreateReleaseEvidenceSchema, DownloadReleaseAssetSchema, ListSnippetsSchema, GetSnippetSchema, CreateSnippetSchema, UpdateSnippetSchema, DeleteSnippetSchema, GitLabSnippetSchema, GetMergeRequestNotesSchema, GetMergeRequestNoteSchema, GetMergeRequestDiscussionSchema, DeleteMergeRequestDiscussionNoteSchema, ResolveMergeRequestThreadSchema, GetWorkItemSchema, ListWorkItemsSchema, CreateWorkItemSchema, UpdateWorkItemSchema, ConvertWorkItemTypeSchema, ListWorkItemStatusesSchema, ListWorkItemNotesSchema, CreateWorkItemNoteSchema, CreateWorkItemEmojiReactionSchema, CreateWorkItemNoteEmojiReactionSchema, ListWorkItemEmojiReactionsSchema, ListWorkItemNoteEmojiReactionsSchema, DeleteWorkItemEmojiReactionSchema, DeleteWorkItemNoteEmojiReactionSchema, MoveWorkItemSchema, ListCustomFieldDefinitionsSchema, GetTimelineEventsSchema, CreateTimelineEventSchema, ListWebhooksSchema, CreateWebhookSchema, UpdateWebhookSchema, DeleteWebhookSchema, ListWebhookEventsSchema, GetWebhookEventSchema, HealthCheckSchema, } from "./schemas.js";
|
|
150
151
|
import { createHash, randomUUID, timingSafeEqual } from "node:crypto";
|
|
151
152
|
import { createLogger, flushBufferedLogs, flushStartupLogs } from "./utils/logger.js";
|
|
152
153
|
const logger = createLogger();
|
|
@@ -989,8 +990,8 @@ configureGitLabRequestContext({
|
|
|
989
990
|
getDispatcherForUrl: apiUrl => clientPool.getDispatcherForUrl(apiUrl),
|
|
990
991
|
getOAuthAccessToken: () => OAUTH_ACCESS_TOKEN,
|
|
991
992
|
});
|
|
992
|
-
// The wiki, milestone, and
|
|
993
|
-
// scope helpers below; fetch is read at call time because the cookie reload replaces it.
|
|
993
|
+
// The wiki, milestone, label, and tag handlers call back into the fetch, error handling, and
|
|
994
|
+
// project scope helpers below; fetch is read at call time because the cookie reload replaces it.
|
|
994
995
|
configureWikiTools({
|
|
995
996
|
getFetch: () => fetch,
|
|
996
997
|
handleGitLabError,
|
|
@@ -1008,6 +1009,11 @@ configureLabelTools({
|
|
|
1008
1009
|
handleGitLabError,
|
|
1009
1010
|
getEffectiveProjectId,
|
|
1010
1011
|
});
|
|
1012
|
+
configureTagTools({
|
|
1013
|
+
getFetch: () => fetch,
|
|
1014
|
+
handleGitLabError,
|
|
1015
|
+
getEffectiveProjectId,
|
|
1016
|
+
});
|
|
1011
1017
|
// Create cookie jar with clean Netscape file parsing
|
|
1012
1018
|
// Resolve cookie path once using os.homedir() for cross-platform support
|
|
1013
1019
|
const resolvedCookiePath = GITLAB_AUTH_COOKIE_PATH
|
|
@@ -7717,88 +7723,6 @@ async function downloadReleaseAsset(projectId, tagName, directAssetPath) {
|
|
|
7717
7723
|
await handleGitLabError(response);
|
|
7718
7724
|
return await response.text();
|
|
7719
7725
|
}
|
|
7720
|
-
/**
|
|
7721
|
-
* List repository tags
|
|
7722
|
-
*
|
|
7723
|
-
* @param projectId The ID or URL-encoded path of the project
|
|
7724
|
-
* @param options Optional parameters for filtering and pagination
|
|
7725
|
-
* @returns Array of GitLab tags
|
|
7726
|
-
*/
|
|
7727
|
-
async function listTags(projectId, options = {}) {
|
|
7728
|
-
const effectiveProjectId = getEffectiveProjectId(projectId);
|
|
7729
|
-
const url = new URL(`${getEffectiveApiUrl()}/projects/${encodeGitLabPathSegment(effectiveProjectId)}/repository/tags`);
|
|
7730
|
-
appendFilterParams(url.searchParams, options);
|
|
7731
|
-
const response = await fetch(url.toString(), {
|
|
7732
|
-
...getFetchConfig(),
|
|
7733
|
-
});
|
|
7734
|
-
await handleGitLabError(response);
|
|
7735
|
-
const data = await response.json();
|
|
7736
|
-
return GitLabTagSchema.array().parse(data);
|
|
7737
|
-
}
|
|
7738
|
-
/**
|
|
7739
|
-
* Get a repository tag by name
|
|
7740
|
-
*
|
|
7741
|
-
* @param projectId The ID or URL-encoded path of the project
|
|
7742
|
-
* @param tagName The name of the tag
|
|
7743
|
-
* @returns GitLab tag
|
|
7744
|
-
*/
|
|
7745
|
-
async function getTag(projectId, tagName) {
|
|
7746
|
-
const effectiveProjectId = getEffectiveProjectId(projectId);
|
|
7747
|
-
const response = await fetch(`${getEffectiveApiUrl()}/projects/${encodeGitLabPathSegment(effectiveProjectId)}/repository/tags/${encodeGitLabPathSegment(tagName)}`, {
|
|
7748
|
-
...getFetchConfig(),
|
|
7749
|
-
});
|
|
7750
|
-
await handleGitLabError(response);
|
|
7751
|
-
const data = await response.json();
|
|
7752
|
-
return GitLabTagSchema.parse(data);
|
|
7753
|
-
}
|
|
7754
|
-
/**
|
|
7755
|
-
* Create a new repository tag
|
|
7756
|
-
*
|
|
7757
|
-
* @param projectId The ID or URL-encoded path of the project
|
|
7758
|
-
* @param options Options for creating the tag
|
|
7759
|
-
* @returns Created GitLab tag
|
|
7760
|
-
*/
|
|
7761
|
-
async function createTag(projectId, options) {
|
|
7762
|
-
const effectiveProjectId = getEffectiveProjectId(projectId);
|
|
7763
|
-
const response = await fetch(`${getEffectiveApiUrl()}/projects/${encodeGitLabPathSegment(effectiveProjectId)}/repository/tags`, {
|
|
7764
|
-
...getFetchConfig(),
|
|
7765
|
-
method: "POST",
|
|
7766
|
-
body: JSON.stringify(options),
|
|
7767
|
-
});
|
|
7768
|
-
await handleGitLabError(response);
|
|
7769
|
-
const data = await response.json();
|
|
7770
|
-
return GitLabTagSchema.parse(data);
|
|
7771
|
-
}
|
|
7772
|
-
/**
|
|
7773
|
-
* Delete a repository tag
|
|
7774
|
-
*
|
|
7775
|
-
* @param projectId The ID or URL-encoded path of the project
|
|
7776
|
-
* @param tagName The name of the tag
|
|
7777
|
-
*/
|
|
7778
|
-
async function deleteTag(projectId, tagName) {
|
|
7779
|
-
const effectiveProjectId = getEffectiveProjectId(projectId);
|
|
7780
|
-
const response = await fetch(`${getEffectiveApiUrl()}/projects/${encodeGitLabPathSegment(effectiveProjectId)}/repository/tags/${encodeGitLabPathSegment(tagName)}`, {
|
|
7781
|
-
...getFetchConfig(),
|
|
7782
|
-
method: "DELETE",
|
|
7783
|
-
});
|
|
7784
|
-
await handleGitLabError(response);
|
|
7785
|
-
}
|
|
7786
|
-
/**
|
|
7787
|
-
* Get the signature of a repository tag
|
|
7788
|
-
*
|
|
7789
|
-
* @param projectId The ID or URL-encoded path of the project
|
|
7790
|
-
* @param tagName The name of the tag
|
|
7791
|
-
* @returns Tag signature
|
|
7792
|
-
*/
|
|
7793
|
-
async function getTagSignature(projectId, tagName) {
|
|
7794
|
-
const effectiveProjectId = getEffectiveProjectId(projectId);
|
|
7795
|
-
const response = await fetch(`${getEffectiveApiUrl()}/projects/${encodeGitLabPathSegment(effectiveProjectId)}/repository/tags/${encodeGitLabPathSegment(tagName)}/signature`, {
|
|
7796
|
-
...getFetchConfig(),
|
|
7797
|
-
});
|
|
7798
|
-
await handleGitLabError(response);
|
|
7799
|
-
const data = await response.json();
|
|
7800
|
-
return GitLabTagSignatureSchema.parse(data);
|
|
7801
|
-
}
|
|
7802
7726
|
async function executeGitLabGraphQL(query, variables = {}) {
|
|
7803
7727
|
const apiUrl = new URL(getEffectiveApiUrl());
|
|
7804
7728
|
const restPath = apiUrl.pathname || "";
|
|
@@ -10541,122 +10465,16 @@ async function handleToolCall(params) {
|
|
|
10541
10465
|
content: [{ type: "text", text: assetContent }],
|
|
10542
10466
|
};
|
|
10543
10467
|
}
|
|
10544
|
-
case "list_tags":
|
|
10545
|
-
|
|
10546
|
-
|
|
10547
|
-
|
|
10548
|
-
|
|
10549
|
-
|
|
10550
|
-
|
|
10551
|
-
|
|
10552
|
-
case "
|
|
10553
|
-
|
|
10554
|
-
const tag = await getTag(args.project_id, args.tag_name);
|
|
10555
|
-
return {
|
|
10556
|
-
content: [{ type: "text", text: JSON.stringify(tag) }],
|
|
10557
|
-
};
|
|
10558
|
-
}
|
|
10559
|
-
case "create_tag": {
|
|
10560
|
-
const args = CreateTagSchema.parse(params.arguments);
|
|
10561
|
-
const { project_id, ...options } = args;
|
|
10562
|
-
const tag = await createTag(project_id, options);
|
|
10563
|
-
return {
|
|
10564
|
-
content: [{ type: "text", text: JSON.stringify(tag) }],
|
|
10565
|
-
};
|
|
10566
|
-
}
|
|
10567
|
-
case "delete_tag": {
|
|
10568
|
-
const args = DeleteTagSchema.parse(params.arguments);
|
|
10569
|
-
await deleteTag(args.project_id, args.tag_name);
|
|
10570
|
-
return {
|
|
10571
|
-
content: [
|
|
10572
|
-
{
|
|
10573
|
-
type: "text",
|
|
10574
|
-
text: JSON.stringify({
|
|
10575
|
-
status: "success",
|
|
10576
|
-
message: `Tag '${args.tag_name}' deleted successfully`,
|
|
10577
|
-
}),
|
|
10578
|
-
},
|
|
10579
|
-
],
|
|
10580
|
-
};
|
|
10581
|
-
}
|
|
10582
|
-
case "get_tag_signature": {
|
|
10583
|
-
const args = GetTagSignatureSchema.parse(params.arguments);
|
|
10584
|
-
const signature = await getTagSignature(args.project_id, args.tag_name);
|
|
10585
|
-
return {
|
|
10586
|
-
content: [{ type: "text", text: JSON.stringify(signature) }],
|
|
10587
|
-
};
|
|
10588
|
-
}
|
|
10589
|
-
case "list_protected_tags": {
|
|
10590
|
-
const args = ListProtectedTagsSchema.parse(params.arguments);
|
|
10591
|
-
const projectId = decodeURIComponent(args.project_id);
|
|
10592
|
-
const effectiveProjectId = getEffectiveProjectId(projectId);
|
|
10593
|
-
const url = new URL(`${getEffectiveApiUrl()}/projects/${encodeGitLabPathSegment(effectiveProjectId)}/protected_tags`);
|
|
10594
|
-
if (args.page)
|
|
10595
|
-
url.searchParams.append("page", String(args.page));
|
|
10596
|
-
if (args.per_page)
|
|
10597
|
-
url.searchParams.append("per_page", String(args.per_page));
|
|
10598
|
-
const response = await fetch(url.toString(), {
|
|
10599
|
-
...getFetchConfig(),
|
|
10600
|
-
});
|
|
10601
|
-
await handleGitLabError(response);
|
|
10602
|
-
const data = z.array(GitLabProtectedTagSchema).parse(await response.json());
|
|
10603
|
-
return {
|
|
10604
|
-
content: [{ type: "text", text: JSON.stringify(data) }],
|
|
10605
|
-
};
|
|
10606
|
-
}
|
|
10607
|
-
case "get_protected_tag": {
|
|
10608
|
-
const args = GetProtectedTagSchema.parse(params.arguments);
|
|
10609
|
-
const projectId = decodeURIComponent(args.project_id);
|
|
10610
|
-
const effectiveProjectId = getEffectiveProjectId(projectId);
|
|
10611
|
-
const url = new URL(`${getEffectiveApiUrl()}/projects/${encodeGitLabPathSegment(effectiveProjectId)}/protected_tags/${encodeGitLabPathSegment(args.tag_name)}`);
|
|
10612
|
-
const response = await fetch(url.toString(), {
|
|
10613
|
-
...getFetchConfig(),
|
|
10614
|
-
});
|
|
10615
|
-
await handleGitLabError(response);
|
|
10616
|
-
const data = GitLabProtectedTagSchema.parse(await response.json());
|
|
10617
|
-
return {
|
|
10618
|
-
content: [{ type: "text", text: JSON.stringify(data) }],
|
|
10619
|
-
};
|
|
10620
|
-
}
|
|
10621
|
-
case "protect_tag": {
|
|
10622
|
-
const args = ProtectTagSchema.parse(params.arguments);
|
|
10623
|
-
const projectId = decodeURIComponent(args.project_id);
|
|
10624
|
-
const effectiveProjectId = getEffectiveProjectId(projectId);
|
|
10625
|
-
const url = new URL(`${getEffectiveApiUrl()}/projects/${encodeGitLabPathSegment(effectiveProjectId)}/protected_tags`);
|
|
10626
|
-
const body = { name: args.tag_name };
|
|
10627
|
-
if (args.create_access_level !== undefined) {
|
|
10628
|
-
body.create_access_level = args.create_access_level;
|
|
10629
|
-
}
|
|
10630
|
-
const response = await fetch(url.toString(), {
|
|
10631
|
-
...getFetchConfig(),
|
|
10632
|
-
method: "POST",
|
|
10633
|
-
body: JSON.stringify(body),
|
|
10634
|
-
});
|
|
10635
|
-
await handleGitLabError(response);
|
|
10636
|
-
const data = GitLabProtectedTagSchema.parse(await response.json());
|
|
10637
|
-
return {
|
|
10638
|
-
content: [{ type: "text", text: JSON.stringify(data) }],
|
|
10639
|
-
};
|
|
10640
|
-
}
|
|
10641
|
-
case "unprotect_tag": {
|
|
10642
|
-
const args = UnprotectTagSchema.parse(params.arguments);
|
|
10643
|
-
const projectId = decodeURIComponent(args.project_id);
|
|
10644
|
-
const effectiveProjectId = getEffectiveProjectId(projectId);
|
|
10645
|
-
const url = new URL(`${getEffectiveApiUrl()}/projects/${encodeGitLabPathSegment(effectiveProjectId)}/protected_tags/${encodeGitLabPathSegment(args.tag_name)}`);
|
|
10646
|
-
const response = await fetch(url.toString(), {
|
|
10647
|
-
...getFetchConfig(),
|
|
10648
|
-
method: "DELETE",
|
|
10649
|
-
});
|
|
10650
|
-
await handleGitLabError(response);
|
|
10651
|
-
return {
|
|
10652
|
-
content: [
|
|
10653
|
-
{
|
|
10654
|
-
type: "text",
|
|
10655
|
-
text: JSON.stringify({ status: "unprotected", tag: args.tag_name }),
|
|
10656
|
-
},
|
|
10657
|
-
],
|
|
10658
|
-
};
|
|
10659
|
-
}
|
|
10468
|
+
case "list_tags":
|
|
10469
|
+
case "get_tag":
|
|
10470
|
+
case "create_tag":
|
|
10471
|
+
case "delete_tag":
|
|
10472
|
+
case "get_tag_signature":
|
|
10473
|
+
case "list_protected_tags":
|
|
10474
|
+
case "get_protected_tag":
|
|
10475
|
+
case "protect_tag":
|
|
10476
|
+
case "unprotect_tag":
|
|
10477
|
+
return await handleTagToolCall(params);
|
|
10660
10478
|
case "list_snippets": {
|
|
10661
10479
|
const args = ListSnippetsSchema.parse(params.arguments);
|
|
10662
10480
|
const { project_id, ...options } = args;
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { CreateTagSchema, DeleteTagSchema, GetProtectedTagSchema, GetTagSchema, GetTagSignatureSchema, GitLabProtectedTagSchema, GitLabTagSchema, GitLabTagSignatureSchema, ListProtectedTagsSchema, ListTagsSchema, ProtectTagSchema, UnprotectTagSchema, } from "../schemas.js";
|
|
3
|
+
import { getEffectiveApiUrl, getFetchConfig } from "../server/gitlab-request-context.js";
|
|
4
|
+
import { appendFilterParams } from "../utils/tool-args.js";
|
|
5
|
+
import { encodeGitLabPathSegment } from "../utils/url.js";
|
|
6
|
+
let deps;
|
|
7
|
+
export function configureTagTools(next) {
|
|
8
|
+
deps = next;
|
|
9
|
+
}
|
|
10
|
+
function requireDeps() {
|
|
11
|
+
if (!deps) {
|
|
12
|
+
throw new Error("Tag tools used before configureTagTools()");
|
|
13
|
+
}
|
|
14
|
+
return deps;
|
|
15
|
+
}
|
|
16
|
+
const fetch = (input, init) => requireDeps().getFetch()(input, init);
|
|
17
|
+
function handleGitLabError(response) {
|
|
18
|
+
return requireDeps().handleGitLabError(response);
|
|
19
|
+
}
|
|
20
|
+
function getEffectiveProjectId(projectId) {
|
|
21
|
+
return requireDeps().getEffectiveProjectId(projectId);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* List repository tags
|
|
25
|
+
*
|
|
26
|
+
* @param projectId The ID or URL-encoded path of the project
|
|
27
|
+
* @param options Optional parameters for filtering and pagination
|
|
28
|
+
* @returns Array of GitLab tags
|
|
29
|
+
*/
|
|
30
|
+
async function listTags(projectId, options = {}) {
|
|
31
|
+
const effectiveProjectId = getEffectiveProjectId(projectId);
|
|
32
|
+
const url = new URL(`${getEffectiveApiUrl()}/projects/${encodeGitLabPathSegment(effectiveProjectId)}/repository/tags`);
|
|
33
|
+
appendFilterParams(url.searchParams, options);
|
|
34
|
+
const response = await fetch(url.toString(), {
|
|
35
|
+
...getFetchConfig(),
|
|
36
|
+
});
|
|
37
|
+
await handleGitLabError(response);
|
|
38
|
+
const data = await response.json();
|
|
39
|
+
return GitLabTagSchema.array().parse(data);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Get a repository tag by name
|
|
43
|
+
*
|
|
44
|
+
* @param projectId The ID or URL-encoded path of the project
|
|
45
|
+
* @param tagName The name of the tag
|
|
46
|
+
* @returns GitLab tag
|
|
47
|
+
*/
|
|
48
|
+
async function getTag(projectId, tagName) {
|
|
49
|
+
const effectiveProjectId = getEffectiveProjectId(projectId);
|
|
50
|
+
const response = await fetch(`${getEffectiveApiUrl()}/projects/${encodeGitLabPathSegment(effectiveProjectId)}/repository/tags/${encodeGitLabPathSegment(tagName)}`, {
|
|
51
|
+
...getFetchConfig(),
|
|
52
|
+
});
|
|
53
|
+
await handleGitLabError(response);
|
|
54
|
+
const data = await response.json();
|
|
55
|
+
return GitLabTagSchema.parse(data);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Create a new repository tag
|
|
59
|
+
*
|
|
60
|
+
* @param projectId The ID or URL-encoded path of the project
|
|
61
|
+
* @param options Options for creating the tag
|
|
62
|
+
* @returns Created GitLab tag
|
|
63
|
+
*/
|
|
64
|
+
async function createTag(projectId, options) {
|
|
65
|
+
const effectiveProjectId = getEffectiveProjectId(projectId);
|
|
66
|
+
const response = await fetch(`${getEffectiveApiUrl()}/projects/${encodeGitLabPathSegment(effectiveProjectId)}/repository/tags`, {
|
|
67
|
+
...getFetchConfig(),
|
|
68
|
+
method: "POST",
|
|
69
|
+
body: JSON.stringify(options),
|
|
70
|
+
});
|
|
71
|
+
await handleGitLabError(response);
|
|
72
|
+
const data = await response.json();
|
|
73
|
+
return GitLabTagSchema.parse(data);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Delete a repository tag
|
|
77
|
+
*
|
|
78
|
+
* @param projectId The ID or URL-encoded path of the project
|
|
79
|
+
* @param tagName The name of the tag
|
|
80
|
+
*/
|
|
81
|
+
async function deleteTag(projectId, tagName) {
|
|
82
|
+
const effectiveProjectId = getEffectiveProjectId(projectId);
|
|
83
|
+
const response = await fetch(`${getEffectiveApiUrl()}/projects/${encodeGitLabPathSegment(effectiveProjectId)}/repository/tags/${encodeGitLabPathSegment(tagName)}`, {
|
|
84
|
+
...getFetchConfig(),
|
|
85
|
+
method: "DELETE",
|
|
86
|
+
});
|
|
87
|
+
await handleGitLabError(response);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Get the signature of a repository tag
|
|
91
|
+
*
|
|
92
|
+
* @param projectId The ID or URL-encoded path of the project
|
|
93
|
+
* @param tagName The name of the tag
|
|
94
|
+
* @returns Tag signature
|
|
95
|
+
*/
|
|
96
|
+
async function getTagSignature(projectId, tagName) {
|
|
97
|
+
const effectiveProjectId = getEffectiveProjectId(projectId);
|
|
98
|
+
const response = await fetch(`${getEffectiveApiUrl()}/projects/${encodeGitLabPathSegment(effectiveProjectId)}/repository/tags/${encodeGitLabPathSegment(tagName)}/signature`, {
|
|
99
|
+
...getFetchConfig(),
|
|
100
|
+
});
|
|
101
|
+
await handleGitLabError(response);
|
|
102
|
+
const data = await response.json();
|
|
103
|
+
return GitLabTagSignatureSchema.parse(data);
|
|
104
|
+
}
|
|
105
|
+
export async function handleTagToolCall(params) {
|
|
106
|
+
switch (params.name) {
|
|
107
|
+
case "list_tags": {
|
|
108
|
+
const args = ListTagsSchema.parse(params.arguments);
|
|
109
|
+
const { project_id, ...options } = args;
|
|
110
|
+
const tags = await listTags(project_id, options);
|
|
111
|
+
return {
|
|
112
|
+
content: [{ type: "text", text: JSON.stringify(tags) }],
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
case "get_tag": {
|
|
116
|
+
const args = GetTagSchema.parse(params.arguments);
|
|
117
|
+
const tag = await getTag(args.project_id, args.tag_name);
|
|
118
|
+
return {
|
|
119
|
+
content: [{ type: "text", text: JSON.stringify(tag) }],
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
case "create_tag": {
|
|
123
|
+
const args = CreateTagSchema.parse(params.arguments);
|
|
124
|
+
const { project_id, ...options } = args;
|
|
125
|
+
const tag = await createTag(project_id, options);
|
|
126
|
+
return {
|
|
127
|
+
content: [{ type: "text", text: JSON.stringify(tag) }],
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
case "delete_tag": {
|
|
131
|
+
const args = DeleteTagSchema.parse(params.arguments);
|
|
132
|
+
await deleteTag(args.project_id, args.tag_name);
|
|
133
|
+
return {
|
|
134
|
+
content: [
|
|
135
|
+
{
|
|
136
|
+
type: "text",
|
|
137
|
+
text: JSON.stringify({
|
|
138
|
+
status: "success",
|
|
139
|
+
message: `Tag '${args.tag_name}' deleted successfully`,
|
|
140
|
+
}),
|
|
141
|
+
},
|
|
142
|
+
],
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
case "get_tag_signature": {
|
|
146
|
+
const args = GetTagSignatureSchema.parse(params.arguments);
|
|
147
|
+
const signature = await getTagSignature(args.project_id, args.tag_name);
|
|
148
|
+
return {
|
|
149
|
+
content: [{ type: "text", text: JSON.stringify(signature) }],
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
case "list_protected_tags": {
|
|
153
|
+
const args = ListProtectedTagsSchema.parse(params.arguments);
|
|
154
|
+
const projectId = decodeURIComponent(args.project_id);
|
|
155
|
+
const effectiveProjectId = getEffectiveProjectId(projectId);
|
|
156
|
+
const url = new URL(`${getEffectiveApiUrl()}/projects/${encodeGitLabPathSegment(effectiveProjectId)}/protected_tags`);
|
|
157
|
+
if (args.page)
|
|
158
|
+
url.searchParams.append("page", String(args.page));
|
|
159
|
+
if (args.per_page)
|
|
160
|
+
url.searchParams.append("per_page", String(args.per_page));
|
|
161
|
+
const response = await fetch(url.toString(), {
|
|
162
|
+
...getFetchConfig(),
|
|
163
|
+
});
|
|
164
|
+
await handleGitLabError(response);
|
|
165
|
+
const data = z.array(GitLabProtectedTagSchema).parse(await response.json());
|
|
166
|
+
return {
|
|
167
|
+
content: [{ type: "text", text: JSON.stringify(data) }],
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
case "get_protected_tag": {
|
|
171
|
+
const args = GetProtectedTagSchema.parse(params.arguments);
|
|
172
|
+
const projectId = decodeURIComponent(args.project_id);
|
|
173
|
+
const effectiveProjectId = getEffectiveProjectId(projectId);
|
|
174
|
+
const url = new URL(`${getEffectiveApiUrl()}/projects/${encodeGitLabPathSegment(effectiveProjectId)}/protected_tags/${encodeGitLabPathSegment(args.tag_name)}`);
|
|
175
|
+
const response = await fetch(url.toString(), {
|
|
176
|
+
...getFetchConfig(),
|
|
177
|
+
});
|
|
178
|
+
await handleGitLabError(response);
|
|
179
|
+
const data = GitLabProtectedTagSchema.parse(await response.json());
|
|
180
|
+
return {
|
|
181
|
+
content: [{ type: "text", text: JSON.stringify(data) }],
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
case "protect_tag": {
|
|
185
|
+
const args = ProtectTagSchema.parse(params.arguments);
|
|
186
|
+
const projectId = decodeURIComponent(args.project_id);
|
|
187
|
+
const effectiveProjectId = getEffectiveProjectId(projectId);
|
|
188
|
+
const url = new URL(`${getEffectiveApiUrl()}/projects/${encodeGitLabPathSegment(effectiveProjectId)}/protected_tags`);
|
|
189
|
+
const body = { name: args.tag_name };
|
|
190
|
+
if (args.create_access_level !== undefined) {
|
|
191
|
+
body.create_access_level = args.create_access_level;
|
|
192
|
+
}
|
|
193
|
+
const response = await fetch(url.toString(), {
|
|
194
|
+
...getFetchConfig(),
|
|
195
|
+
method: "POST",
|
|
196
|
+
body: JSON.stringify(body),
|
|
197
|
+
});
|
|
198
|
+
await handleGitLabError(response);
|
|
199
|
+
const data = GitLabProtectedTagSchema.parse(await response.json());
|
|
200
|
+
return {
|
|
201
|
+
content: [{ type: "text", text: JSON.stringify(data) }],
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
case "unprotect_tag": {
|
|
205
|
+
const args = UnprotectTagSchema.parse(params.arguments);
|
|
206
|
+
const projectId = decodeURIComponent(args.project_id);
|
|
207
|
+
const effectiveProjectId = getEffectiveProjectId(projectId);
|
|
208
|
+
const url = new URL(`${getEffectiveApiUrl()}/projects/${encodeGitLabPathSegment(effectiveProjectId)}/protected_tags/${encodeGitLabPathSegment(args.tag_name)}`);
|
|
209
|
+
const response = await fetch(url.toString(), {
|
|
210
|
+
...getFetchConfig(),
|
|
211
|
+
method: "DELETE",
|
|
212
|
+
});
|
|
213
|
+
await handleGitLabError(response);
|
|
214
|
+
return {
|
|
215
|
+
content: [
|
|
216
|
+
{
|
|
217
|
+
type: "text",
|
|
218
|
+
text: JSON.stringify({ status: "unprotected", tag: args.tag_name }),
|
|
219
|
+
},
|
|
220
|
+
],
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
default:
|
|
224
|
+
throw new Error(`Unknown tool: ${params.name}`);
|
|
225
|
+
}
|
|
226
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zereight/mcp-gitlab",
|
|
3
|
-
"version": "2.3.25-next.
|
|
3
|
+
"version": "2.3.25-next.222",
|
|
4
4
|
"mcpName": "io.github.zereight/gitlab-mcp",
|
|
5
5
|
"description": "GitLab MCP server for projects, merge requests, issues, pipelines, wiki, releases, and more",
|
|
6
6
|
"keywords": [
|