@zereight/mcp-gitlab 2.3.20-next.197 → 2.3.20-next.199
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/build/index.js +23 -286
- package/build/tools/wiki.js +312 -0
- package/build/utils/list-summary.js +75 -0
- package/package.json +1 -1
package/build/index.js
CHANGED
|
@@ -109,7 +109,6 @@ import { authBySession, BASE_HEADERS, bindSessionProjectScope, buildAuthHeaders,
|
|
|
109
109
|
import { apiUrlUserinfoWarning, commaSplitHint, configuredApiUrlErrors, encodeGitLabPath, encodeGitLabPathSegment, invalidListEntryError, isCleartextRemoteUrl, normalizeGitLabApiUrl, parseConfiguredGitLabApiUrls, } from "./utils/url.js";
|
|
110
110
|
import { estimateMergeCommitCount, filterDiffsByPatterns, openSafeOutputWriteStream, resolveDownloadRoot, readSafeExistingFile, summarizeWebhookEvents, } from "./utils/helpers.js";
|
|
111
111
|
import { graphqlQueryContainsWriteOperation, graphqlQueryContainsDeleteOperation, } from "./utils/graphql-query.js";
|
|
112
|
-
import { resolveNestedWikiUpdateTitle } from "./utils/wiki-title.js";
|
|
113
112
|
import { encodeRepoFilePayloadContent, fileOperationsIncludeDeleteOrMove, toGitLabCommitActions, } from "./utils/gitlab-commit-actions.js";
|
|
114
113
|
import { redactSensitiveGitLabFields } from "./utils/redact-sensitive.js";
|
|
115
114
|
import { formatJobLogSearch, JobLogSearchError, readJobLogTail, searchJobLog, } from "./utils/job-log-search.js";
|
|
@@ -133,19 +132,20 @@ import { zodSchemaFor } from "./utils/schema.js";
|
|
|
133
132
|
import { GitLabClientPool } from "./gitlab-client-pool.js";
|
|
134
133
|
import { advertisesReadOnly, allTools, readOnlyTools, destructiveTools, deleteTools, parseEnabledToolsets, parseIndividualTools, buildFeatureFlagOverrides, isToolInEnabledToolset, findSmallestToolsetForTool, isExplicitOnlyToolsetId, isExplicitToolsetOnlyTool, isToolsetFullyActive, listDiscoverableCategories, TOOLSET_DEFINITIONS, DISCOVERABLE_TOOLSET_IDS, } from "./tools/registry.js";
|
|
135
134
|
import { executeGitLabApiRequestAsync, GitLabApiRequestHttpError, GitLabApiRequestInputError, } from "./tools/gitlab-api-request.js";
|
|
135
|
+
import { configureWikiTools, handleWikiToolCall } from "./tools/wiki.js";
|
|
136
136
|
import { buildUnavailableToolMessage, isSkippedByDiscoverActivation, } from "./tools/discover-activation.js";
|
|
137
137
|
import { selectCallableHiddenToolNames, selectExposedTools } from "./tools/exposed-tools.js";
|
|
138
138
|
import { createListedToolsCache, decorateToolsForList, } from "./tools/listed-tools.js";
|
|
139
139
|
import { isExcludedBySlimProfile, shouldApplySlimToolProfile } from "./tools/tool-profile.js";
|
|
140
140
|
import { shouldCompactToolResult } from "./utils/compact-tool-allowlist.js";
|
|
141
141
|
import { BulkPublishDraftNotesSchema, CancelPipelineJobSchema, ErasePipelineJobSchema, CancelPipelineSchema, CreateBranchSchema, CreateDraftNoteSchema, CreateIssueLinkSchema, CreateIssueNoteSchema, CreateIssueSchema, CreateIssueEmojiReactionSchema, CreateIssueNoteEmojiReactionSchema, ListIssueEmojiReactionsSchema, ListIssueNoteEmojiReactionsSchema, CreateLabelSchema, // Added
|
|
142
|
-
CreateMergeRequestNoteSchema, CreateMergeRequestDiscussionNoteSchema, CreateMergeRequestEmojiReactionSchema, CreateMergeRequestNoteEmojiReactionSchema, ListMergeRequestEmojiReactionsSchema, ListMergeRequestNoteEmojiReactionsSchema, CreateMergeRequestSchema, CreateMergeRequestThreadSchema, CreateNoteSchema, CreateCommitStatusSchema, CreateOrUpdateFileSchema, CreatePipelineSchema, CreateProjectMilestoneSchema, CreateGroupMilestoneSchema, CreateRepositorySchema, CreateGroupSchema,
|
|
142
|
+
CreateMergeRequestNoteSchema, CreateMergeRequestDiscussionNoteSchema, CreateMergeRequestEmojiReactionSchema, CreateMergeRequestNoteEmojiReactionSchema, ListMergeRequestEmojiReactionsSchema, ListMergeRequestNoteEmojiReactionsSchema, CreateMergeRequestSchema, CreateMergeRequestThreadSchema, CreateNoteSchema, CreateCommitStatusSchema, CreateOrUpdateFileSchema, CreatePipelineSchema, CreateProjectMilestoneSchema, CreateGroupMilestoneSchema, CreateRepositorySchema, CreateGroupSchema, DeleteBranchSchema, GetProtectedBranchSchema, ListProtectedBranchesSchema, ProtectBranchSchema, UpdateProtectedBranchSchema, UnprotectBranchSchema, UpdateDefaultBranchSchema, DeleteDraftNoteSchema, DeleteGroupMilestoneSchema, DeleteIssueLinkSchema, DeleteIssueSchema, DeleteIssueEmojiReactionSchema, DeleteIssueNoteEmojiReactionSchema, DeleteLabelSchema, DeleteProjectMilestoneSchema, DeleteMergeRequestNoteSchema, DeleteMergeRequestEmojiReactionSchema, DeleteMergeRequestNoteEmojiReactionSchema, EditProjectMilestoneSchema, EditGroupMilestoneSchema, ForkRepositorySchema, GetBranchDiffsSchema, GetBranchSchema, GetCommitDiffSchema, GetCommitSchema, GetFileBlameSchema, GitLabBlameEntrySchema, GetDraftNoteSchema, GetFileContentsSchema, GetIssueLinkSchema, GetIssueSchema, GetLabelSchema, GetMergeRequestDiffsSchema, GetMergeRequestSchema, GetMilestoneBurndownEventsSchema, GetMilestoneIssuesSchema, GetMilestoneMergeRequestsSchema, GetGroupMilestoneSchema, GetGroupMilestoneIssuesSchema, GetGroupMilestoneMergeRequestsSchema, GetGroupMilestoneBurndownEventsSchema, GetDeploymentSchema, CreateDeploymentSchema, UpdateDeploymentSchema, DeploymentApprovalSchema, ListDeploymentMergeRequestsSchema, GetEnvironmentSchema, UpdateEnvironmentSchema, StopEnvironmentSchema, StopStaleEnvironmentsSchema, DeleteReviewAppEnvironmentsSchema, PipelineTriggerIdSchema, ListPipelineTriggersSchema, CreatePipelineTriggerSchema, UpdatePipelineTriggerSchema, TriggerPipelineSchema, GetNamespaceSchema, GitLabCiLintResultSchema, GetPipelineJobOutputSchema, PipelineJobControlSchema, GetPipelineSchema, GetPipelineVariablesSchema, UpdatePipelineMetadataSchema, DeletePipelineSchema, PipelineReportSchema, WaitForPipelineSchema, WaitForPipelineJobSchema, PlayPipelineJobsSchema, GetProjectMilestoneSchema, GetProjectSchema, GetRepositoryTreeSchema, GetUsersSchema, GetUserSchema, GitLabUserFullSchema, WhoAmISchema, GitLabCurrentUserSchema, GitLabCommitSchema, GitLabCommitStatusSchema, GitLabCompareResultSchema, GitLabContentSchema, GitLabCreateUpdateFileResponseSchema, GitLabDiffSchema,
|
|
143
143
|
// Discussion Schemas
|
|
144
144
|
GitLabDiscussionNoteSchema, // Added
|
|
145
145
|
GitLabDiscussionSchema,
|
|
146
146
|
// Draft Notes Schemas
|
|
147
|
-
GitLabDraftNoteSchema, GitLabForkSchema, GitLabBranchSchema, GitLabProtectedBranchSchema, GitLabProtectedTagSchema, GitLabGroupSchema, GitLabIssueLinkSchema, GitLabIssueSchema, GitLabIssueWithLinkDetailsSchema, GitLabMarkdownUploadSchema, GitLabMergeRequestPipelineSchema, GitLabMergeRequestSchema, GitLabMilestonesSchema, GitLabGroupMilestonesSchema, 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,
|
|
148
|
-
GetMergeRequestFileDiffSchema, ListMergeRequestChangedFilesSchema, ListMergeRequestDiscussionsSchema, ListMergeRequestPipelinesSchema, ListMergeRequestsSchema, ListGroupMergeRequestsSchema, ListMergeRequestVersionsSchema, GetMergeRequestVersionSchema, GitLabMergeRequestVersionSchema, GitLabMergeRequestVersionDetailSchema, ListNamespacesSchema, ListPipelineJobsSchema, ListPipelinesSchema, ListDeploymentsSchema, ListEnvironmentsSchema, ListProjectRunnersSchema, GetRunnerSchema, ListPipelineTriggerJobsSchema, ValidateCiLintSchema, ValidateProjectCiLintSchema, ListCiCatalogResourcesSchema, GetCiCatalogResourceSchema, ListProjectMembersSchema, ListGroupMembersSchema, ListProjectMilestonesSchema, ListGroupMilestonesSchema, ListProjectsSchema,
|
|
147
|
+
GitLabDraftNoteSchema, GitLabForkSchema, GitLabBranchSchema, GitLabProtectedBranchSchema, GitLabProtectedTagSchema, GitLabGroupSchema, GitLabIssueLinkSchema, GitLabIssueSchema, GitLabIssueWithLinkDetailsSchema, GitLabMarkdownUploadSchema, GitLabMergeRequestPipelineSchema, GitLabMergeRequestSchema, GitLabMilestonesSchema, GitLabGroupMilestonesSchema, 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, ListLabelsSchema, ListMergeRequestDiffsSchema, // Added
|
|
148
|
+
GetMergeRequestFileDiffSchema, ListMergeRequestChangedFilesSchema, ListMergeRequestDiscussionsSchema, ListMergeRequestPipelinesSchema, ListMergeRequestsSchema, ListGroupMergeRequestsSchema, ListMergeRequestVersionsSchema, GetMergeRequestVersionSchema, GitLabMergeRequestVersionSchema, GitLabMergeRequestVersionDetailSchema, ListNamespacesSchema, ListPipelineJobsSchema, ListPipelinesSchema, ListDeploymentsSchema, ListEnvironmentsSchema, ListProjectRunnersSchema, GetRunnerSchema, ListPipelineTriggerJobsSchema, ValidateCiLintSchema, ValidateProjectCiLintSchema, ListCiCatalogResourcesSchema, GetCiCatalogResourceSchema, ListProjectMembersSchema, ListGroupMembersSchema, ListProjectMilestonesSchema, ListGroupMilestonesSchema, ListProjectsSchema, MarkdownUploadSchema, MarkdownUploadRemoteSchema, DownloadAttachmentSchema, DownloadJobArtifactsSchema, GetJobArtifactFileSchema, GitLabArtifactEntrySchema, ListJobArtifactsSchema, MergeMergeRequestSchema, ApproveMergeRequestSchema, UnapproveMergeRequestSchema, RebaseMergeRequestSchema, GetMergeRequestApprovalStateSchema, GetMergeRequestConflictsSchema, GitLabMergeRequestApprovalStateSchema, MyIssuesSchema, OrbitQuerySchema, OrbitSchemaSchema, OrbitStatusSchema, OrbitToolsSchema, MarkAllTodosDoneSchema, MarkTodoDoneSchema, PaginatedDiscussionsResponseSchema, PromoteProjectMilestoneSchema, PublishDraftNoteSchema, PlayPipelineJobSchema, PushFilesSchema, RetryPipelineJobSchema, RetryPipelineSchema, SearchCodeSchema, SearchGroupCodeSchema, SearchProjectCodeSchema, SearchRepositoriesSchema, UpdateDraftNoteSchema, UpdateIssueNoteSchema, UpdateIssueSchema, UpdateIssueDescriptionPatchSchema, ReorderIssueSchema, UpdateLabelSchema, UpdateProjectSchema, UpdateMergeRequestNoteSchema, UpdateMergeRequestDiscussionNoteSchema, UpdateMergeRequestSchema, VerifyNamespaceSchema, GitLabEventSchema, ListEventsSchema, GetProjectEventsSchema, ExecuteGraphQLSchema, GitLabReleaseSchema, ListReleasesSchema, GetReleaseSchema, CreateReleaseSchema, UpdateReleaseSchema, DeleteReleaseSchema, CreateReleaseEvidenceSchema, DownloadReleaseAssetSchema, ListTagsSchema, GetTagSchema, CreateTagSchema, DeleteTagSchema, GetTagSignatureSchema, ListProtectedTagsSchema, GetProtectedTagSchema, ProtectTagSchema, UnprotectTagSchema, GitLabTagSchema, GitLabTagSignatureSchema, 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";
|
|
149
149
|
import { createHash, randomUUID, timingSafeEqual } from "node:crypto";
|
|
150
150
|
import { createLogger, flushBufferedLogs, flushStartupLogs } from "./utils/logger.js";
|
|
151
151
|
const logger = createLogger();
|
|
@@ -988,6 +988,14 @@ configureGitLabRequestContext({
|
|
|
988
988
|
getDispatcherForUrl: apiUrl => clientPool.getDispatcherForUrl(apiUrl),
|
|
989
989
|
getOAuthAccessToken: () => OAUTH_ACCESS_TOKEN,
|
|
990
990
|
});
|
|
991
|
+
// The wiki handlers call back into the fetch, error handling, and project scope
|
|
992
|
+
// helpers below; fetch is read at call time because the cookie reload replaces it.
|
|
993
|
+
configureWikiTools({
|
|
994
|
+
getFetch: () => fetch,
|
|
995
|
+
handleGitLabError,
|
|
996
|
+
getEffectiveProjectId,
|
|
997
|
+
rejectIfStrictProjectScope,
|
|
998
|
+
});
|
|
991
999
|
// Create cookie jar with clean Netscape file parsing
|
|
992
1000
|
// Resolve cookie path once using os.homedir() for cross-platform support
|
|
993
1001
|
const resolvedCookiePath = GITLAB_AUTH_COOKIE_PATH
|
|
@@ -5208,187 +5216,6 @@ async function getWebhookEvent(options) {
|
|
|
5208
5216
|
}
|
|
5209
5217
|
return null;
|
|
5210
5218
|
}
|
|
5211
|
-
// Wiki API helper functions
|
|
5212
|
-
/**
|
|
5213
|
-
* List wiki pages in a project
|
|
5214
|
-
*/
|
|
5215
|
-
async function listWikiPages(projectId, options = {}) {
|
|
5216
|
-
projectId = decodeURIComponent(projectId); // Decode project ID
|
|
5217
|
-
const url = new URL(`${getEffectiveApiUrl()}/projects/${encodeGitLabPathSegment(getEffectiveProjectId(projectId))}/wikis`);
|
|
5218
|
-
if (options.page)
|
|
5219
|
-
url.searchParams.append("page", options.page.toString());
|
|
5220
|
-
if (options.per_page)
|
|
5221
|
-
url.searchParams.append("per_page", options.per_page.toString());
|
|
5222
|
-
if (options.with_content)
|
|
5223
|
-
url.searchParams.append("with_content", options.with_content.toString());
|
|
5224
|
-
if (options.render_html)
|
|
5225
|
-
url.searchParams.append("render_html", options.render_html.toString());
|
|
5226
|
-
const response = await fetch(url.toString(), {
|
|
5227
|
-
...getFetchConfig(),
|
|
5228
|
-
});
|
|
5229
|
-
await handleGitLabError(response);
|
|
5230
|
-
const data = await response.json();
|
|
5231
|
-
return GitLabWikiPageSchema.array().parse(data);
|
|
5232
|
-
}
|
|
5233
|
-
/**
|
|
5234
|
-
* Get a specific wiki page
|
|
5235
|
-
*/
|
|
5236
|
-
async function getWikiPage(projectId, slug, renderHtml) {
|
|
5237
|
-
projectId = decodeURIComponent(projectId); // Decode project ID
|
|
5238
|
-
const url = new URL(`${getEffectiveApiUrl()}/projects/${encodeGitLabPathSegment(getEffectiveProjectId(projectId))}/wikis/${encodeGitLabPathSegment(slug)}`);
|
|
5239
|
-
if (renderHtml)
|
|
5240
|
-
url.searchParams.append("render_html", renderHtml.toString());
|
|
5241
|
-
const response = await fetch(url.toString(), { ...getFetchConfig() });
|
|
5242
|
-
await handleGitLabError(response);
|
|
5243
|
-
const data = await response.json();
|
|
5244
|
-
return GitLabWikiPageSchema.parse(data);
|
|
5245
|
-
}
|
|
5246
|
-
/**
|
|
5247
|
-
* Create a new wiki page
|
|
5248
|
-
*/
|
|
5249
|
-
async function createWikiPage(projectId, title, content, format) {
|
|
5250
|
-
projectId = decodeURIComponent(projectId); // Decode project ID
|
|
5251
|
-
const body = { title, content };
|
|
5252
|
-
if (format)
|
|
5253
|
-
body.format = format;
|
|
5254
|
-
const response = await fetch(`${getEffectiveApiUrl()}/projects/${encodeGitLabPathSegment(getEffectiveProjectId(projectId))}/wikis`, {
|
|
5255
|
-
...getFetchConfig(),
|
|
5256
|
-
method: "POST",
|
|
5257
|
-
body: JSON.stringify(body),
|
|
5258
|
-
});
|
|
5259
|
-
await handleGitLabError(response);
|
|
5260
|
-
const data = await response.json();
|
|
5261
|
-
return GitLabWikiPageSchema.parse(data);
|
|
5262
|
-
}
|
|
5263
|
-
/**
|
|
5264
|
-
* Update an existing wiki page
|
|
5265
|
-
*/
|
|
5266
|
-
async function updateWikiPage(projectId, slug, title, content, format) {
|
|
5267
|
-
projectId = decodeURIComponent(projectId); // Decode project ID
|
|
5268
|
-
const body = {};
|
|
5269
|
-
if (title) {
|
|
5270
|
-
if (slug.includes("/") && !title.includes("/")) {
|
|
5271
|
-
const existing = await getWikiPage(projectId, slug);
|
|
5272
|
-
body.title = resolveNestedWikiUpdateTitle(slug, title, existing.title);
|
|
5273
|
-
}
|
|
5274
|
-
else {
|
|
5275
|
-
body.title = title;
|
|
5276
|
-
}
|
|
5277
|
-
}
|
|
5278
|
-
if (content)
|
|
5279
|
-
body.content = content;
|
|
5280
|
-
if (format)
|
|
5281
|
-
body.format = format;
|
|
5282
|
-
const response = await fetch(`${getEffectiveApiUrl()}/projects/${encodeGitLabPathSegment(getEffectiveProjectId(projectId))}/wikis/${encodeGitLabPathSegment(slug)}`, {
|
|
5283
|
-
...getFetchConfig(),
|
|
5284
|
-
method: "PUT",
|
|
5285
|
-
body: JSON.stringify(body),
|
|
5286
|
-
});
|
|
5287
|
-
await handleGitLabError(response);
|
|
5288
|
-
const data = await response.json();
|
|
5289
|
-
return GitLabWikiPageSchema.parse(data);
|
|
5290
|
-
}
|
|
5291
|
-
/**
|
|
5292
|
-
* Delete a wiki page
|
|
5293
|
-
*/
|
|
5294
|
-
async function deleteWikiPage(projectId, slug) {
|
|
5295
|
-
projectId = decodeURIComponent(projectId); // Decode project ID
|
|
5296
|
-
const response = await fetch(`${getEffectiveApiUrl()}/projects/${encodeGitLabPathSegment(getEffectiveProjectId(projectId))}/wikis/${encodeGitLabPathSegment(slug)}`, {
|
|
5297
|
-
...getFetchConfig(),
|
|
5298
|
-
method: "DELETE",
|
|
5299
|
-
});
|
|
5300
|
-
await handleGitLabError(response);
|
|
5301
|
-
}
|
|
5302
|
-
/**
|
|
5303
|
-
* List wiki pages in a GitLab group
|
|
5304
|
-
*/
|
|
5305
|
-
async function listGroupWikiPages(groupId, options = {}) {
|
|
5306
|
-
groupId = decodeURIComponent(groupId); // Decode group ID
|
|
5307
|
-
const url = new URL(`${getEffectiveApiUrl()}/groups/${encodeGitLabPathSegment(groupId)}/wikis`);
|
|
5308
|
-
if (options.page)
|
|
5309
|
-
url.searchParams.append("page", options.page.toString());
|
|
5310
|
-
if (options.per_page)
|
|
5311
|
-
url.searchParams.append("per_page", options.per_page.toString());
|
|
5312
|
-
if (options.with_content)
|
|
5313
|
-
url.searchParams.append("with_content", options.with_content.toString());
|
|
5314
|
-
if (options.render_html)
|
|
5315
|
-
url.searchParams.append("render_html", options.render_html.toString());
|
|
5316
|
-
const response = await fetch(url.toString(), {
|
|
5317
|
-
...getFetchConfig(),
|
|
5318
|
-
});
|
|
5319
|
-
await handleGitLabError(response);
|
|
5320
|
-
const data = await response.json();
|
|
5321
|
-
return GitLabWikiPageSchema.array().parse(data);
|
|
5322
|
-
}
|
|
5323
|
-
/**
|
|
5324
|
-
* Get a specific group wiki page
|
|
5325
|
-
*/
|
|
5326
|
-
async function getGroupWikiPage(groupId, slug, renderHtml) {
|
|
5327
|
-
groupId = decodeURIComponent(groupId); // Decode group ID
|
|
5328
|
-
const url = new URL(`${getEffectiveApiUrl()}/groups/${encodeGitLabPathSegment(groupId)}/wikis/${encodeGitLabPathSegment(slug)}`);
|
|
5329
|
-
if (renderHtml)
|
|
5330
|
-
url.searchParams.append("render_html", renderHtml.toString());
|
|
5331
|
-
const response = await fetch(url.toString(), { ...getFetchConfig() });
|
|
5332
|
-
await handleGitLabError(response);
|
|
5333
|
-
const data = await response.json();
|
|
5334
|
-
return GitLabWikiPageSchema.parse(data);
|
|
5335
|
-
}
|
|
5336
|
-
/**
|
|
5337
|
-
* Create a new group wiki page
|
|
5338
|
-
*/
|
|
5339
|
-
async function createGroupWikiPage(groupId, title, content, format) {
|
|
5340
|
-
groupId = decodeURIComponent(groupId); // Decode group ID
|
|
5341
|
-
const body = { title, content };
|
|
5342
|
-
if (format)
|
|
5343
|
-
body.format = format;
|
|
5344
|
-
const response = await fetch(`${getEffectiveApiUrl()}/groups/${encodeGitLabPathSegment(groupId)}/wikis`, {
|
|
5345
|
-
...getFetchConfig(),
|
|
5346
|
-
method: "POST",
|
|
5347
|
-
body: JSON.stringify(body),
|
|
5348
|
-
});
|
|
5349
|
-
await handleGitLabError(response);
|
|
5350
|
-
const data = await response.json();
|
|
5351
|
-
return GitLabWikiPageSchema.parse(data);
|
|
5352
|
-
}
|
|
5353
|
-
/**
|
|
5354
|
-
* Update an existing group wiki page
|
|
5355
|
-
*/
|
|
5356
|
-
async function updateGroupWikiPage(groupId, slug, title, content, format) {
|
|
5357
|
-
groupId = decodeURIComponent(groupId); // Decode group ID
|
|
5358
|
-
const body = {};
|
|
5359
|
-
if (title) {
|
|
5360
|
-
if (slug.includes("/") && !title.includes("/")) {
|
|
5361
|
-
const existing = await getGroupWikiPage(groupId, slug);
|
|
5362
|
-
body.title = resolveNestedWikiUpdateTitle(slug, title, existing.title);
|
|
5363
|
-
}
|
|
5364
|
-
else {
|
|
5365
|
-
body.title = title;
|
|
5366
|
-
}
|
|
5367
|
-
}
|
|
5368
|
-
if (content)
|
|
5369
|
-
body.content = content;
|
|
5370
|
-
if (format)
|
|
5371
|
-
body.format = format;
|
|
5372
|
-
const response = await fetch(`${getEffectiveApiUrl()}/groups/${encodeGitLabPathSegment(groupId)}/wikis/${encodeGitLabPathSegment(slug)}`, {
|
|
5373
|
-
...getFetchConfig(),
|
|
5374
|
-
method: "PUT",
|
|
5375
|
-
body: JSON.stringify(body),
|
|
5376
|
-
});
|
|
5377
|
-
await handleGitLabError(response);
|
|
5378
|
-
const data = await response.json();
|
|
5379
|
-
return GitLabWikiPageSchema.parse(data);
|
|
5380
|
-
}
|
|
5381
|
-
/**
|
|
5382
|
-
* Delete a group wiki page
|
|
5383
|
-
*/
|
|
5384
|
-
async function deleteGroupWikiPage(groupId, slug) {
|
|
5385
|
-
groupId = decodeURIComponent(groupId); // Decode group ID
|
|
5386
|
-
const response = await fetch(`${getEffectiveApiUrl()}/groups/${encodeGitLabPathSegment(groupId)}/wikis/${encodeGitLabPathSegment(slug)}`, {
|
|
5387
|
-
...getFetchConfig(),
|
|
5388
|
-
method: "DELETE",
|
|
5389
|
-
});
|
|
5390
|
-
await handleGitLabError(response);
|
|
5391
|
-
}
|
|
5392
5219
|
/**
|
|
5393
5220
|
* List pipelines in a GitLab project
|
|
5394
5221
|
*
|
|
@@ -9736,107 +9563,17 @@ async function handleToolCall(params) {
|
|
|
9736
9563
|
content: [{ type: "text", text: JSON.stringify(projects) }],
|
|
9737
9564
|
};
|
|
9738
9565
|
}
|
|
9739
|
-
case "list_wiki_pages":
|
|
9740
|
-
|
|
9741
|
-
|
|
9742
|
-
|
|
9743
|
-
|
|
9744
|
-
|
|
9745
|
-
|
|
9746
|
-
|
|
9747
|
-
|
|
9748
|
-
|
|
9749
|
-
|
|
9750
|
-
}
|
|
9751
|
-
case "get_wiki_page": {
|
|
9752
|
-
const { project_id, slug, render_html } = GetWikiPageSchema.parse(params.arguments);
|
|
9753
|
-
const wikiPage = await getWikiPage(project_id, slug, render_html);
|
|
9754
|
-
return {
|
|
9755
|
-
content: [{ type: "text", text: JSON.stringify(wikiPage) }],
|
|
9756
|
-
};
|
|
9757
|
-
}
|
|
9758
|
-
case "create_wiki_page": {
|
|
9759
|
-
const { project_id, title, content, format } = CreateWikiPageSchema.parse(params.arguments);
|
|
9760
|
-
const wikiPage = await createWikiPage(project_id, title, content, format);
|
|
9761
|
-
return {
|
|
9762
|
-
content: [{ type: "text", text: JSON.stringify(wikiPage) }],
|
|
9763
|
-
};
|
|
9764
|
-
}
|
|
9765
|
-
case "update_wiki_page": {
|
|
9766
|
-
const { project_id, slug, title, content, format } = UpdateWikiPageSchema.parse(params.arguments);
|
|
9767
|
-
const wikiPage = await updateWikiPage(project_id, slug, title, content, format);
|
|
9768
|
-
return {
|
|
9769
|
-
content: [{ type: "text", text: JSON.stringify(wikiPage) }],
|
|
9770
|
-
};
|
|
9771
|
-
}
|
|
9772
|
-
case "delete_wiki_page": {
|
|
9773
|
-
const { project_id, slug } = DeleteWikiPageSchema.parse(params.arguments);
|
|
9774
|
-
await deleteWikiPage(project_id, slug);
|
|
9775
|
-
return {
|
|
9776
|
-
content: [
|
|
9777
|
-
{
|
|
9778
|
-
type: "text",
|
|
9779
|
-
text: JSON.stringify({
|
|
9780
|
-
status: "success",
|
|
9781
|
-
message: "Wiki page deleted successfully",
|
|
9782
|
-
}),
|
|
9783
|
-
},
|
|
9784
|
-
],
|
|
9785
|
-
};
|
|
9786
|
-
}
|
|
9787
|
-
case "list_group_wiki_pages": {
|
|
9788
|
-
rejectIfStrictProjectScope("list_group_wiki_pages");
|
|
9789
|
-
const { group_id, page, per_page, with_content, render_html } = ListGroupWikiPagesSchema.parse(params.arguments);
|
|
9790
|
-
const wikiPages = await listGroupWikiPages(group_id, {
|
|
9791
|
-
page,
|
|
9792
|
-
per_page,
|
|
9793
|
-
with_content,
|
|
9794
|
-
render_html,
|
|
9795
|
-
});
|
|
9796
|
-
return {
|
|
9797
|
-
content: [{ type: "text", text: JSON.stringify(wikiPages) }],
|
|
9798
|
-
};
|
|
9799
|
-
}
|
|
9800
|
-
case "get_group_wiki_page": {
|
|
9801
|
-
rejectIfStrictProjectScope("get_group_wiki_page");
|
|
9802
|
-
const { group_id, slug, render_html } = GetGroupWikiPageSchema.parse(params.arguments);
|
|
9803
|
-
const wikiPage = await getGroupWikiPage(group_id, slug, render_html);
|
|
9804
|
-
return {
|
|
9805
|
-
content: [{ type: "text", text: JSON.stringify(wikiPage) }],
|
|
9806
|
-
};
|
|
9807
|
-
}
|
|
9808
|
-
case "create_group_wiki_page": {
|
|
9809
|
-
rejectIfStrictProjectScope("create_group_wiki_page");
|
|
9810
|
-
const { group_id, title, content, format } = CreateGroupWikiPageSchema.parse(params.arguments);
|
|
9811
|
-
const wikiPage = await createGroupWikiPage(group_id, title, content, format);
|
|
9812
|
-
return {
|
|
9813
|
-
content: [{ type: "text", text: JSON.stringify(wikiPage) }],
|
|
9814
|
-
};
|
|
9815
|
-
}
|
|
9816
|
-
case "update_group_wiki_page": {
|
|
9817
|
-
rejectIfStrictProjectScope("update_group_wiki_page");
|
|
9818
|
-
const { group_id, slug, title, content, format } = UpdateGroupWikiPageSchema.parse(params.arguments);
|
|
9819
|
-
const wikiPage = await updateGroupWikiPage(group_id, slug, title, content, format);
|
|
9820
|
-
return {
|
|
9821
|
-
content: [{ type: "text", text: JSON.stringify(wikiPage) }],
|
|
9822
|
-
};
|
|
9823
|
-
}
|
|
9824
|
-
case "delete_group_wiki_page": {
|
|
9825
|
-
rejectIfStrictProjectScope("delete_group_wiki_page");
|
|
9826
|
-
const { group_id, slug } = DeleteGroupWikiPageSchema.parse(params.arguments);
|
|
9827
|
-
await deleteGroupWikiPage(group_id, slug);
|
|
9828
|
-
return {
|
|
9829
|
-
content: [
|
|
9830
|
-
{
|
|
9831
|
-
type: "text",
|
|
9832
|
-
text: JSON.stringify({
|
|
9833
|
-
status: "success",
|
|
9834
|
-
message: "Group wiki page deleted successfully",
|
|
9835
|
-
}),
|
|
9836
|
-
},
|
|
9837
|
-
],
|
|
9838
|
-
};
|
|
9839
|
-
}
|
|
9566
|
+
case "list_wiki_pages":
|
|
9567
|
+
case "get_wiki_page":
|
|
9568
|
+
case "create_wiki_page":
|
|
9569
|
+
case "update_wiki_page":
|
|
9570
|
+
case "delete_wiki_page":
|
|
9571
|
+
case "list_group_wiki_pages":
|
|
9572
|
+
case "get_group_wiki_page":
|
|
9573
|
+
case "create_group_wiki_page":
|
|
9574
|
+
case "update_group_wiki_page":
|
|
9575
|
+
case "delete_group_wiki_page":
|
|
9576
|
+
return await handleWikiToolCall(params);
|
|
9840
9577
|
case "get_repository_tree": {
|
|
9841
9578
|
const args = GetRepositoryTreeSchema.parse(params.arguments);
|
|
9842
9579
|
const { items, next_page_token } = await getRepositoryTree(args);
|
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
import { CreateGroupWikiPageSchema, CreateWikiPageSchema, DeleteGroupWikiPageSchema, DeleteWikiPageSchema, GetGroupWikiPageSchema, GetWikiPageSchema, GitLabWikiPageSchema, ListGroupWikiPagesSchema, ListWikiPagesSchema, UpdateGroupWikiPageSchema, UpdateWikiPageSchema, } from "../schemas.js";
|
|
2
|
+
import { getEffectiveApiUrl, getFetchConfig } from "../server/gitlab-request-context.js";
|
|
3
|
+
import { encodeGitLabPathSegment } from "../utils/url.js";
|
|
4
|
+
import { resolveNestedWikiUpdateTitle } from "../utils/wiki-title.js";
|
|
5
|
+
let deps;
|
|
6
|
+
export function configureWikiTools(next) {
|
|
7
|
+
deps = next;
|
|
8
|
+
}
|
|
9
|
+
function requireDeps() {
|
|
10
|
+
if (!deps) {
|
|
11
|
+
throw new Error("Wiki tools used before configureWikiTools()");
|
|
12
|
+
}
|
|
13
|
+
return deps;
|
|
14
|
+
}
|
|
15
|
+
const fetch = (input, init) => requireDeps().getFetch()(input, init);
|
|
16
|
+
function handleGitLabError(response) {
|
|
17
|
+
return requireDeps().handleGitLabError(response);
|
|
18
|
+
}
|
|
19
|
+
function getEffectiveProjectId(projectId) {
|
|
20
|
+
return requireDeps().getEffectiveProjectId(projectId);
|
|
21
|
+
}
|
|
22
|
+
function rejectIfStrictProjectScope(toolName) {
|
|
23
|
+
requireDeps().rejectIfStrictProjectScope(toolName);
|
|
24
|
+
}
|
|
25
|
+
// Wiki API helper functions
|
|
26
|
+
/**
|
|
27
|
+
* List wiki pages in a project
|
|
28
|
+
*/
|
|
29
|
+
async function listWikiPages(projectId, options = {}) {
|
|
30
|
+
projectId = decodeURIComponent(projectId); // Decode project ID
|
|
31
|
+
const url = new URL(`${getEffectiveApiUrl()}/projects/${encodeGitLabPathSegment(getEffectiveProjectId(projectId))}/wikis`);
|
|
32
|
+
if (options.page)
|
|
33
|
+
url.searchParams.append("page", options.page.toString());
|
|
34
|
+
if (options.per_page)
|
|
35
|
+
url.searchParams.append("per_page", options.per_page.toString());
|
|
36
|
+
if (options.with_content)
|
|
37
|
+
url.searchParams.append("with_content", options.with_content.toString());
|
|
38
|
+
if (options.render_html)
|
|
39
|
+
url.searchParams.append("render_html", options.render_html.toString());
|
|
40
|
+
const response = await fetch(url.toString(), {
|
|
41
|
+
...getFetchConfig(),
|
|
42
|
+
});
|
|
43
|
+
await handleGitLabError(response);
|
|
44
|
+
const data = await response.json();
|
|
45
|
+
return GitLabWikiPageSchema.array().parse(data);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Get a specific wiki page
|
|
49
|
+
*/
|
|
50
|
+
async function getWikiPage(projectId, slug, renderHtml) {
|
|
51
|
+
projectId = decodeURIComponent(projectId); // Decode project ID
|
|
52
|
+
const url = new URL(`${getEffectiveApiUrl()}/projects/${encodeGitLabPathSegment(getEffectiveProjectId(projectId))}/wikis/${encodeGitLabPathSegment(slug)}`);
|
|
53
|
+
if (renderHtml)
|
|
54
|
+
url.searchParams.append("render_html", renderHtml.toString());
|
|
55
|
+
const response = await fetch(url.toString(), { ...getFetchConfig() });
|
|
56
|
+
await handleGitLabError(response);
|
|
57
|
+
const data = await response.json();
|
|
58
|
+
return GitLabWikiPageSchema.parse(data);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Create a new wiki page
|
|
62
|
+
*/
|
|
63
|
+
async function createWikiPage(projectId, title, content, format) {
|
|
64
|
+
projectId = decodeURIComponent(projectId); // Decode project ID
|
|
65
|
+
const body = { title, content };
|
|
66
|
+
if (format)
|
|
67
|
+
body.format = format;
|
|
68
|
+
const response = await fetch(`${getEffectiveApiUrl()}/projects/${encodeGitLabPathSegment(getEffectiveProjectId(projectId))}/wikis`, {
|
|
69
|
+
...getFetchConfig(),
|
|
70
|
+
method: "POST",
|
|
71
|
+
body: JSON.stringify(body),
|
|
72
|
+
});
|
|
73
|
+
await handleGitLabError(response);
|
|
74
|
+
const data = await response.json();
|
|
75
|
+
return GitLabWikiPageSchema.parse(data);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Update an existing wiki page
|
|
79
|
+
*/
|
|
80
|
+
async function updateWikiPage(projectId, slug, title, content, format) {
|
|
81
|
+
projectId = decodeURIComponent(projectId); // Decode project ID
|
|
82
|
+
const body = {};
|
|
83
|
+
if (title) {
|
|
84
|
+
if (slug.includes("/") && !title.includes("/")) {
|
|
85
|
+
const existing = await getWikiPage(projectId, slug);
|
|
86
|
+
body.title = resolveNestedWikiUpdateTitle(slug, title, existing.title);
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
body.title = title;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
if (content)
|
|
93
|
+
body.content = content;
|
|
94
|
+
if (format)
|
|
95
|
+
body.format = format;
|
|
96
|
+
const response = await fetch(`${getEffectiveApiUrl()}/projects/${encodeGitLabPathSegment(getEffectiveProjectId(projectId))}/wikis/${encodeGitLabPathSegment(slug)}`, {
|
|
97
|
+
...getFetchConfig(),
|
|
98
|
+
method: "PUT",
|
|
99
|
+
body: JSON.stringify(body),
|
|
100
|
+
});
|
|
101
|
+
await handleGitLabError(response);
|
|
102
|
+
const data = await response.json();
|
|
103
|
+
return GitLabWikiPageSchema.parse(data);
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Delete a wiki page
|
|
107
|
+
*/
|
|
108
|
+
async function deleteWikiPage(projectId, slug) {
|
|
109
|
+
projectId = decodeURIComponent(projectId); // Decode project ID
|
|
110
|
+
const response = await fetch(`${getEffectiveApiUrl()}/projects/${encodeGitLabPathSegment(getEffectiveProjectId(projectId))}/wikis/${encodeGitLabPathSegment(slug)}`, {
|
|
111
|
+
...getFetchConfig(),
|
|
112
|
+
method: "DELETE",
|
|
113
|
+
});
|
|
114
|
+
await handleGitLabError(response);
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* List wiki pages in a GitLab group
|
|
118
|
+
*/
|
|
119
|
+
async function listGroupWikiPages(groupId, options = {}) {
|
|
120
|
+
groupId = decodeURIComponent(groupId); // Decode group ID
|
|
121
|
+
const url = new URL(`${getEffectiveApiUrl()}/groups/${encodeGitLabPathSegment(groupId)}/wikis`);
|
|
122
|
+
if (options.page)
|
|
123
|
+
url.searchParams.append("page", options.page.toString());
|
|
124
|
+
if (options.per_page)
|
|
125
|
+
url.searchParams.append("per_page", options.per_page.toString());
|
|
126
|
+
if (options.with_content)
|
|
127
|
+
url.searchParams.append("with_content", options.with_content.toString());
|
|
128
|
+
if (options.render_html)
|
|
129
|
+
url.searchParams.append("render_html", options.render_html.toString());
|
|
130
|
+
const response = await fetch(url.toString(), {
|
|
131
|
+
...getFetchConfig(),
|
|
132
|
+
});
|
|
133
|
+
await handleGitLabError(response);
|
|
134
|
+
const data = await response.json();
|
|
135
|
+
return GitLabWikiPageSchema.array().parse(data);
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Get a specific group wiki page
|
|
139
|
+
*/
|
|
140
|
+
async function getGroupWikiPage(groupId, slug, renderHtml) {
|
|
141
|
+
groupId = decodeURIComponent(groupId); // Decode group ID
|
|
142
|
+
const url = new URL(`${getEffectiveApiUrl()}/groups/${encodeGitLabPathSegment(groupId)}/wikis/${encodeGitLabPathSegment(slug)}`);
|
|
143
|
+
if (renderHtml)
|
|
144
|
+
url.searchParams.append("render_html", renderHtml.toString());
|
|
145
|
+
const response = await fetch(url.toString(), { ...getFetchConfig() });
|
|
146
|
+
await handleGitLabError(response);
|
|
147
|
+
const data = await response.json();
|
|
148
|
+
return GitLabWikiPageSchema.parse(data);
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Create a new group wiki page
|
|
152
|
+
*/
|
|
153
|
+
async function createGroupWikiPage(groupId, title, content, format) {
|
|
154
|
+
groupId = decodeURIComponent(groupId); // Decode group ID
|
|
155
|
+
const body = { title, content };
|
|
156
|
+
if (format)
|
|
157
|
+
body.format = format;
|
|
158
|
+
const response = await fetch(`${getEffectiveApiUrl()}/groups/${encodeGitLabPathSegment(groupId)}/wikis`, {
|
|
159
|
+
...getFetchConfig(),
|
|
160
|
+
method: "POST",
|
|
161
|
+
body: JSON.stringify(body),
|
|
162
|
+
});
|
|
163
|
+
await handleGitLabError(response);
|
|
164
|
+
const data = await response.json();
|
|
165
|
+
return GitLabWikiPageSchema.parse(data);
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Update an existing group wiki page
|
|
169
|
+
*/
|
|
170
|
+
async function updateGroupWikiPage(groupId, slug, title, content, format) {
|
|
171
|
+
groupId = decodeURIComponent(groupId); // Decode group ID
|
|
172
|
+
const body = {};
|
|
173
|
+
if (title) {
|
|
174
|
+
if (slug.includes("/") && !title.includes("/")) {
|
|
175
|
+
const existing = await getGroupWikiPage(groupId, slug);
|
|
176
|
+
body.title = resolveNestedWikiUpdateTitle(slug, title, existing.title);
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
body.title = title;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
if (content)
|
|
183
|
+
body.content = content;
|
|
184
|
+
if (format)
|
|
185
|
+
body.format = format;
|
|
186
|
+
const response = await fetch(`${getEffectiveApiUrl()}/groups/${encodeGitLabPathSegment(groupId)}/wikis/${encodeGitLabPathSegment(slug)}`, {
|
|
187
|
+
...getFetchConfig(),
|
|
188
|
+
method: "PUT",
|
|
189
|
+
body: JSON.stringify(body),
|
|
190
|
+
});
|
|
191
|
+
await handleGitLabError(response);
|
|
192
|
+
const data = await response.json();
|
|
193
|
+
return GitLabWikiPageSchema.parse(data);
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Delete a group wiki page
|
|
197
|
+
*/
|
|
198
|
+
async function deleteGroupWikiPage(groupId, slug) {
|
|
199
|
+
groupId = decodeURIComponent(groupId); // Decode group ID
|
|
200
|
+
const response = await fetch(`${getEffectiveApiUrl()}/groups/${encodeGitLabPathSegment(groupId)}/wikis/${encodeGitLabPathSegment(slug)}`, {
|
|
201
|
+
...getFetchConfig(),
|
|
202
|
+
method: "DELETE",
|
|
203
|
+
});
|
|
204
|
+
await handleGitLabError(response);
|
|
205
|
+
}
|
|
206
|
+
export async function handleWikiToolCall(params) {
|
|
207
|
+
switch (params.name) {
|
|
208
|
+
case "list_wiki_pages": {
|
|
209
|
+
const { project_id, page, per_page, with_content, render_html } = ListWikiPagesSchema.parse(params.arguments);
|
|
210
|
+
const wikiPages = await listWikiPages(project_id, {
|
|
211
|
+
page,
|
|
212
|
+
per_page,
|
|
213
|
+
with_content,
|
|
214
|
+
render_html,
|
|
215
|
+
});
|
|
216
|
+
return {
|
|
217
|
+
content: [{ type: "text", text: JSON.stringify(wikiPages) }],
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
case "get_wiki_page": {
|
|
221
|
+
const { project_id, slug, render_html } = GetWikiPageSchema.parse(params.arguments);
|
|
222
|
+
const wikiPage = await getWikiPage(project_id, slug, render_html);
|
|
223
|
+
return {
|
|
224
|
+
content: [{ type: "text", text: JSON.stringify(wikiPage) }],
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
case "create_wiki_page": {
|
|
228
|
+
const { project_id, title, content, format } = CreateWikiPageSchema.parse(params.arguments);
|
|
229
|
+
const wikiPage = await createWikiPage(project_id, title, content, format);
|
|
230
|
+
return {
|
|
231
|
+
content: [{ type: "text", text: JSON.stringify(wikiPage) }],
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
case "update_wiki_page": {
|
|
235
|
+
const { project_id, slug, title, content, format } = UpdateWikiPageSchema.parse(params.arguments);
|
|
236
|
+
const wikiPage = await updateWikiPage(project_id, slug, title, content, format);
|
|
237
|
+
return {
|
|
238
|
+
content: [{ type: "text", text: JSON.stringify(wikiPage) }],
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
case "delete_wiki_page": {
|
|
242
|
+
const { project_id, slug } = DeleteWikiPageSchema.parse(params.arguments);
|
|
243
|
+
await deleteWikiPage(project_id, slug);
|
|
244
|
+
return {
|
|
245
|
+
content: [
|
|
246
|
+
{
|
|
247
|
+
type: "text",
|
|
248
|
+
text: JSON.stringify({
|
|
249
|
+
status: "success",
|
|
250
|
+
message: "Wiki page deleted successfully",
|
|
251
|
+
}),
|
|
252
|
+
},
|
|
253
|
+
],
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
case "list_group_wiki_pages": {
|
|
257
|
+
rejectIfStrictProjectScope("list_group_wiki_pages");
|
|
258
|
+
const { group_id, page, per_page, with_content, render_html } = ListGroupWikiPagesSchema.parse(params.arguments);
|
|
259
|
+
const wikiPages = await listGroupWikiPages(group_id, {
|
|
260
|
+
page,
|
|
261
|
+
per_page,
|
|
262
|
+
with_content,
|
|
263
|
+
render_html,
|
|
264
|
+
});
|
|
265
|
+
return {
|
|
266
|
+
content: [{ type: "text", text: JSON.stringify(wikiPages) }],
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
case "get_group_wiki_page": {
|
|
270
|
+
rejectIfStrictProjectScope("get_group_wiki_page");
|
|
271
|
+
const { group_id, slug, render_html } = GetGroupWikiPageSchema.parse(params.arguments);
|
|
272
|
+
const wikiPage = await getGroupWikiPage(group_id, slug, render_html);
|
|
273
|
+
return {
|
|
274
|
+
content: [{ type: "text", text: JSON.stringify(wikiPage) }],
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
case "create_group_wiki_page": {
|
|
278
|
+
rejectIfStrictProjectScope("create_group_wiki_page");
|
|
279
|
+
const { group_id, title, content, format } = CreateGroupWikiPageSchema.parse(params.arguments);
|
|
280
|
+
const wikiPage = await createGroupWikiPage(group_id, title, content, format);
|
|
281
|
+
return {
|
|
282
|
+
content: [{ type: "text", text: JSON.stringify(wikiPage) }],
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
case "update_group_wiki_page": {
|
|
286
|
+
rejectIfStrictProjectScope("update_group_wiki_page");
|
|
287
|
+
const { group_id, slug, title, content, format } = UpdateGroupWikiPageSchema.parse(params.arguments);
|
|
288
|
+
const wikiPage = await updateGroupWikiPage(group_id, slug, title, content, format);
|
|
289
|
+
return {
|
|
290
|
+
content: [{ type: "text", text: JSON.stringify(wikiPage) }],
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
case "delete_group_wiki_page": {
|
|
294
|
+
rejectIfStrictProjectScope("delete_group_wiki_page");
|
|
295
|
+
const { group_id, slug } = DeleteGroupWikiPageSchema.parse(params.arguments);
|
|
296
|
+
await deleteGroupWikiPage(group_id, slug);
|
|
297
|
+
return {
|
|
298
|
+
content: [
|
|
299
|
+
{
|
|
300
|
+
type: "text",
|
|
301
|
+
text: JSON.stringify({
|
|
302
|
+
status: "success",
|
|
303
|
+
message: "Group wiki page deleted successfully",
|
|
304
|
+
}),
|
|
305
|
+
},
|
|
306
|
+
],
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
default:
|
|
310
|
+
throw new Error(`Unknown tool: ${params.name}`);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
@@ -67,6 +67,9 @@ const LIST_SUMMARY_DEFAULT_EXCLUDED_TOOLS = new Set([
|
|
|
67
67
|
"list_webhooks", // url, event flags
|
|
68
68
|
"list_pipeline_triggers", // description
|
|
69
69
|
"list_job_artifacts", // path, type, size
|
|
70
|
+
"list_group_iterations", // start_date, due_date
|
|
71
|
+
"list_project_iterations", // start_date, due_date
|
|
72
|
+
"list_group_iteration_cadences", // start_date, duration_in_weeks, iterations_in_advance
|
|
70
73
|
// Small replies whose access fields are the point; summary: true keeps them (TOOL_SUMMARY_FIELDS).
|
|
71
74
|
"list_protected_branches", // *_access_levels, allow_force_push
|
|
72
75
|
"list_protected_tags", // create_access_levels
|
|
@@ -86,6 +89,7 @@ const LIST_SUMMARY_DEFAULT_EXCLUDED_TOOLS = new Set([
|
|
|
86
89
|
"list_group_variables", // environment_scope, variable_type
|
|
87
90
|
"list_merge_request_changed_files", // old_path, new_file/deleted_file/renamed_file
|
|
88
91
|
"list_work_items", // type, webUrl; assignees are strings, not users
|
|
92
|
+
"list_namespaces", // full_path, path, kind
|
|
89
93
|
]);
|
|
90
94
|
/**
|
|
91
95
|
* List tools that keep the full reply under GITLAB_MCP_LIST_SUMMARY_DEFAULT only
|
|
@@ -93,6 +97,77 @@ const LIST_SUMMARY_DEFAULT_EXCLUDED_TOOLS = new Set([
|
|
|
93
97
|
* the summary would drop.
|
|
94
98
|
*/
|
|
95
99
|
const CONTENT_ON_REQUEST_LIST_TOOLS = new Set(["list_wiki_pages", "list_group_wiki_pages"]);
|
|
100
|
+
/**
|
|
101
|
+
* List tools reviewed for GITLAB_MCP_LIST_SUMMARY_DEFAULT whose summary keeps what
|
|
102
|
+
* callers need, with the fields it must keep. Every list tool is in exactly one of
|
|
103
|
+
* this map, LIST_SUMMARY_DEFAULT_EXCLUDED_TOOLS, CONTENT_ON_REQUEST_LIST_TOOLS or
|
|
104
|
+
* NATIVE_SUMMARY_TOOLS: test/utils/list-summary-coverage.test.ts fails on a new
|
|
105
|
+
* list tool that is in none of them, or on a listed field the summary drops.
|
|
106
|
+
*/
|
|
107
|
+
export const LIST_SUMMARY_SAFE_TOOLS = {
|
|
108
|
+
list_issues: ["iid", "title", "state", "labels"],
|
|
109
|
+
list_issue_discussions: ["id", "notes"],
|
|
110
|
+
mr_discussions: ["id", "notes"],
|
|
111
|
+
list_merge_requests: ["iid", "title", "state", "source_branch", "target_branch", "draft"],
|
|
112
|
+
list_group_merge_requests: ["iid", "title", "state", "source_branch", "target_branch", "draft"],
|
|
113
|
+
list_deployment_merge_requests: ["iid", "title", "state", "source_branch", "target_branch"],
|
|
114
|
+
list_merge_request_pipelines: ["id", "status", "ref"],
|
|
115
|
+
list_pipelines: ["id", "status", "ref"],
|
|
116
|
+
list_pipeline_schedule_pipelines: ["id", "status", "ref"],
|
|
117
|
+
list_pipeline_schedules: ["id", "ref"],
|
|
118
|
+
list_pipeline_jobs: ["id", "name", "status"],
|
|
119
|
+
list_commit_statuses: ["id", "name", "status"],
|
|
120
|
+
list_deployments: ["id", "iid", "status", "ref"],
|
|
121
|
+
list_environments: ["id", "name", "state"],
|
|
122
|
+
list_commits: ["id", "short_id", "title"],
|
|
123
|
+
// Explicit (not a spread of TOOL_SUMMARY_FIELDS) so the coverage test guards that list.
|
|
124
|
+
list_branches: [
|
|
125
|
+
"name",
|
|
126
|
+
"protected",
|
|
127
|
+
"default",
|
|
128
|
+
"merged",
|
|
129
|
+
"can_push",
|
|
130
|
+
"developers_can_push",
|
|
131
|
+
"developers_can_merge",
|
|
132
|
+
],
|
|
133
|
+
list_tags: ["name"],
|
|
134
|
+
list_releases: ["name", "tag_name"],
|
|
135
|
+
list_milestones: ["id", "iid", "title", "state"],
|
|
136
|
+
list_group_milestones: ["id", "iid", "title", "state"],
|
|
137
|
+
list_labels: ["id", "name"],
|
|
138
|
+
list_projects: ["id", "path_with_namespace"],
|
|
139
|
+
list_group_projects: ["id", "path_with_namespace"],
|
|
140
|
+
list_snippets: ["id", "title", "web_url"],
|
|
141
|
+
list_project_runners: ["id", "status"],
|
|
142
|
+
list_merge_request_emoji_reactions: ["id", "name"],
|
|
143
|
+
list_merge_request_note_emoji_reactions: ["id", "name"],
|
|
144
|
+
list_issue_emoji_reactions: ["id", "name"],
|
|
145
|
+
list_issue_note_emoji_reactions: ["id", "name"],
|
|
146
|
+
list_work_item_emoji_reactions: ["id", "name"],
|
|
147
|
+
list_work_item_note_emoji_reactions: ["id", "name"],
|
|
148
|
+
};
|
|
149
|
+
/** Which of the lists above a summary-capable tool is in (test helper; no runtime effect). */
|
|
150
|
+
export function listSummaryClassifications(toolName) {
|
|
151
|
+
const found = [];
|
|
152
|
+
if (NATIVE_SUMMARY_TOOLS.has(toolName))
|
|
153
|
+
found.push("native");
|
|
154
|
+
if (LIST_SUMMARY_DEFAULT_EXCLUDED_TOOLS.has(toolName))
|
|
155
|
+
found.push("excluded");
|
|
156
|
+
if (CONTENT_ON_REQUEST_LIST_TOOLS.has(toolName))
|
|
157
|
+
found.push("content-on-request");
|
|
158
|
+
if (Object.hasOwn(LIST_SUMMARY_SAFE_TOOLS, toolName))
|
|
159
|
+
found.push("summary-safe");
|
|
160
|
+
return found.length > 0 ? found : ["unclassified"];
|
|
161
|
+
}
|
|
162
|
+
/** Every tool name the lists above mention (to catch stale entries). */
|
|
163
|
+
export function listSummaryClassifiedToolNames() {
|
|
164
|
+
return [
|
|
165
|
+
...NATIVE_SUMMARY_TOOLS,
|
|
166
|
+
...LIST_SUMMARY_DEFAULT_EXCLUDED_TOOLS,
|
|
167
|
+
...CONTENT_ON_REQUEST_LIST_TOOLS,
|
|
168
|
+
...Object.keys(LIST_SUMMARY_SAFE_TOOLS),
|
|
169
|
+
];
|
|
170
|
+
}
|
|
96
171
|
const CONTENT_REQUEST_ARGUMENTS = ["with_content", "render_html"];
|
|
97
172
|
/** Mirrors the boolean coercion of the tool schemas: true, 1, "true", "1". */
|
|
98
173
|
function isTruthyFlag(value) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zereight/mcp-gitlab",
|
|
3
|
-
"version": "2.3.20-next.
|
|
3
|
+
"version": "2.3.20-next.199",
|
|
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": [
|