@zereight/mcp-gitlab 2.3.19 → 2.3.20-next.198
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 +5 -1
- package/README.md +5 -1
- package/README.pt-BR.md +5 -1
- package/README.zh-CN.md +5 -1
- package/build/index.js +61 -297
- package/build/tools/wiki.js +312 -0
- package/package.json +1 -1
package/README.ko.md
CHANGED
|
@@ -558,6 +558,10 @@ Authorization: Bearer glpat-xxxxxxxxxxxxxxxxxxxx
|
|
|
558
558
|
|
|
559
559
|
설정은 [`MAX_SESSIONS`](./docs/configuration/environment-variables.md#max_sessions), `MAX_REQUESTS_PER_MINUTE`, `SESSION_TIMEOUT_SECONDS`를 참고하세요.
|
|
560
560
|
|
|
561
|
+
#### Streamable HTTP 세션 타임아웃
|
|
562
|
+
|
|
563
|
+
Streamable HTTP 세션도 모든 모드에서 같은 `SESSION_TIMEOUT_SECONDS` 유휴 타임아웃을 사용합니다. `REMOTE_AUTHORIZATION`이나 `GITLAB_MCP_OAUTH` 없이 서버 측 토큰을 쓰는 경우도 포함됩니다. 그 시간 동안 `POST /mcp` 요청이 없는 세션은 종료되고, 다음 요청은 `404`를 받으므로 클라이언트가 다시 initialize합니다. `GET /mcp` 스트림이 열려 있으면 스트림이 닫히거나 다음 `POST /mcp`가 올 때까지 타이머가 멈춥니다. 따라서 스트림을 열어 둔 클라이언트도 마지막 `POST` 이후 `SESSION_TIMEOUT_SECONDS`가 지나면 만료됩니다.
|
|
564
|
+
|
|
561
565
|
### 원격 인증 설정(멀티 유저 지원)
|
|
562
566
|
|
|
563
567
|
`REMOTE_AUTHORIZATION=true`를 사용하면 MCP 서버는 여러 사용자를 지원할 수 있습니다. 각 사용자는 HTTP 헤더로 자신의 GitLab 토큰을 전달합니다. 다음 경우 유용합니다.
|
|
@@ -614,7 +618,7 @@ Private-Token: glpat-xxxxxxxxxxxxxxxxxxxx
|
|
|
614
618
|
|
|
615
619
|
- 원격 인증은 **Streamable HTTP 전송에서만** 동작합니다.
|
|
616
620
|
- 각 세션은 격리됩니다. 한 세션의 토큰은 다른 세션 데이터에 접근할 수 없습니다. 세션이 종료되면 토큰은 자동으로 정리됩니다.
|
|
617
|
-
- **세션 타임아웃:** 인증 토큰은 `SESSION_TIMEOUT_SECONDS`(기본 1시간) 동안 비활성 상태가 지속되면 만료됩니다.
|
|
621
|
+
- **세션 타임아웃:** 인증 토큰은 `SESSION_TIMEOUT_SECONDS`(기본 1시간) 동안 비활성 상태가 지속되면 만료됩니다. 만료되면 세션이 종료되고 다음 요청은 `404`를 받으므로, 클라이언트는 인증 헤더와 함께 다시 initialize합니다.
|
|
618
622
|
- 각 요청은 해당 세션의 타임아웃 타이머를 초기화합니다.
|
|
619
623
|
- **Rate limiting:** `/mcp` 요청은 클라이언트 IP당 `MAX_REQUESTS_PER_MINUTE`로 제한되며, OAuth 또는 원격 인증 사용 시 MCP 세션당으로도 제한됩니다(기본 60). IP당 한도는 고정 60초 윈도우를 사용하고 서버 프로세스별로 집계되며 `GET /mcp`에도 적용됩니다. stateless 모드에서는 세션당 한도를 건너뜁니다. 자세한 내용은 [environment-variables.md](docs/configuration/environment-variables.md#max_requests_per_minute)를 참고하세요.
|
|
620
624
|
- **Capacity limit:** 서버는 최대 `MAX_SESSIONS` 동시 세션을 허용합니다(기본 1000).
|
package/README.md
CHANGED
|
@@ -595,6 +595,10 @@ For callback proxy mode details, see [GitLab MCP OAuth Callback Proxy](./docs/au
|
|
|
595
595
|
|
|
596
596
|
Tune these with [`MAX_SESSIONS`](./docs/configuration/environment-variables.md#max_sessions), `MAX_REQUESTS_PER_MINUTE`, and `SESSION_TIMEOUT_SECONDS`.
|
|
597
597
|
|
|
598
|
+
#### Streamable HTTP session timeout
|
|
599
|
+
|
|
600
|
+
Streamable HTTP sessions use the same `SESSION_TIMEOUT_SECONDS` idle timeout in every mode, including a server-side token without `REMOTE_AUTHORIZATION` or `GITLAB_MCP_OAUTH`: a session with no `POST /mcp` request for that long is closed, and its next request gets `404` so the client re-initializes. An open `GET /mcp` stream pauses the timer until the stream closes or the next `POST /mcp` arrives, so a client with a stream open still expires `SESSION_TIMEOUT_SECONDS` after its last `POST`.
|
|
601
|
+
|
|
598
602
|
### Remote Authorization Setup (Multi-User Support)
|
|
599
603
|
|
|
600
604
|
When using `REMOTE_AUTHORIZATION=true`, the MCP server can support multiple users, each with their own GitLab token passed via HTTP headers. This is useful for:
|
|
@@ -653,7 +657,7 @@ The token is stored per session (identified by `mcp-session-id` header) and reus
|
|
|
653
657
|
- Remote authorization **only works with Streamable HTTP transport**
|
|
654
658
|
- Each session is isolated - tokens from one session cannot access another session's data
|
|
655
659
|
Tokens are automatically cleaned up when sessions close
|
|
656
|
-
- **Session timeout:** Auth tokens expire after `SESSION_TIMEOUT_SECONDS` (default 1 hour) of inactivity. After timeout
|
|
660
|
+
- **Session timeout:** Auth tokens expire after `SESSION_TIMEOUT_SECONDS` (default 1 hour) of inactivity. After timeout the session is closed and its next request gets `404`, so the client re-initializes with its auth headers.
|
|
657
661
|
- Each request resets the timeout timer for that session
|
|
658
662
|
- **Rate limiting:** `/mcp` requests are limited to `MAX_REQUESTS_PER_MINUTE` per client IP, and per MCP session when using OAuth or remote authorization (default 60). The per-IP limit uses a fixed 60-second window, counts per server process, and also covers `GET /mcp`; stateless mode skips the per-session limit. See [environment-variables.md](docs/configuration/environment-variables.md#max_requests_per_minute).
|
|
659
663
|
- **Capacity limit:** Server accepts up to `MAX_SESSIONS` concurrent sessions (default 1000)
|
package/README.pt-BR.md
CHANGED
|
@@ -558,6 +558,10 @@ Para detalhes do modo de proxy de callback, veja [GitLab MCP OAuth Callback Prox
|
|
|
558
558
|
|
|
559
559
|
Ajuste esses limites com [`MAX_SESSIONS`](./docs/configuration/environment-variables.md#max_sessions), `MAX_REQUESTS_PER_MINUTE` e `SESSION_TIMEOUT_SECONDS`.
|
|
560
560
|
|
|
561
|
+
#### Timeout de sessão Streamable HTTP
|
|
562
|
+
|
|
563
|
+
Sessões Streamable HTTP usam o mesmo timeout de inatividade `SESSION_TIMEOUT_SECONDS` em todos os modos, inclusive com um token do lado do servidor sem `REMOTE_AUTHORIZATION` ou `GITLAB_MCP_OAUTH`: uma sessão sem requisição `POST /mcp` durante esse tempo é encerrada, e a próxima requisição recebe `404`, então o cliente inicializa de novo. Um stream `GET /mcp` aberto pausa o timer até o stream fechar ou chegar o próximo `POST /mcp`; assim, um cliente com o stream aberto ainda expira `SESSION_TIMEOUT_SECONDS` após o último `POST`.
|
|
564
|
+
|
|
561
565
|
### Configuração de autorização remota (suporte multiusuário)
|
|
562
566
|
|
|
563
567
|
Com `REMOTE_AUTHORIZATION=true`, o servidor MCP pode atender vários usuários, cada um fornecendo seu próprio token do GitLab por headers HTTP. Isso é útil para:
|
|
@@ -614,7 +618,7 @@ O token é armazenado por sessão (identificada pelo header `mcp-session-id`) e
|
|
|
614
618
|
|
|
615
619
|
- A autorização remota **funciona apenas com o transporte Streamable HTTP**
|
|
616
620
|
- Cada sessão é isolada. O token de uma sessão não pode acessar os dados de outra sessão. Os tokens são limpos automaticamente quando a sessão é encerrada.
|
|
617
|
-
- **Timeout de sessão:** os tokens de autenticação expiram após `SESSION_TIMEOUT_SECONDS` (padrão 1 hora) sem atividade. Após o timeout
|
|
621
|
+
- **Timeout de sessão:** os tokens de autenticação expiram após `SESSION_TIMEOUT_SECONDS` (padrão 1 hora) sem atividade. Após o timeout a sessão é encerrada e a próxima requisição recebe `404`, então o cliente inicializa de novo com os headers de autenticação.
|
|
618
622
|
- Cada requisição reinicia o timer de timeout da sessão.
|
|
619
623
|
- **Rate limiting:** requisições a `/mcp` são limitadas por IP do cliente a `MAX_REQUESTS_PER_MINUTE`; ao usar OAuth ou autorização remota, também são limitadas por sessão MCP (padrão 60). O limite por IP usa uma janela fixa de 60 segundos, conta por processo do servidor e também cobre `GET /mcp`; o modo stateless ignora o limite por sessão. Veja [environment-variables.md](docs/configuration/environment-variables.md#max_requests_per_minute).
|
|
620
624
|
- **Limite de capacidade:** o servidor aceita no máximo `MAX_SESSIONS` sessões simultâneas (padrão 1000).
|
package/README.zh-CN.md
CHANGED
|
@@ -557,6 +557,10 @@ Authorization: Bearer glpat-xxxxxxxxxxxxxxxxxxxx
|
|
|
557
557
|
|
|
558
558
|
可通过 [`MAX_SESSIONS`](./docs/configuration/environment-variables.md#max_sessions)、`MAX_REQUESTS_PER_MINUTE` 和 `SESSION_TIMEOUT_SECONDS` 调整这些限制。
|
|
559
559
|
|
|
560
|
+
#### Streamable HTTP 会话超时
|
|
561
|
+
|
|
562
|
+
Streamable HTTP 会话在所有模式下都使用同一个 `SESSION_TIMEOUT_SECONDS` 空闲超时,包括不启用 `REMOTE_AUTHORIZATION` 或 `GITLAB_MCP_OAUTH`、只用服务端 token 的模式:超过该时长没有 `POST /mcp` 请求的会话会被关闭,之后的请求返回 `404`,客户端会重新 initialize。`GET /mcp` 流打开时计时器暂停,直到流关闭或收到下一个 `POST /mcp`;因此保持流打开的客户端,在最后一次 `POST` 之后经过 `SESSION_TIMEOUT_SECONDS` 仍会过期。
|
|
563
|
+
|
|
560
564
|
### 远程授权设置(多用户支持)
|
|
561
565
|
|
|
562
566
|
使用 `REMOTE_AUTHORIZATION=true` 时,MCP 服务器可以支持多个用户,每个用户通过 HTTP 请求头传入自己的 GitLab token。适用于:
|
|
@@ -613,7 +617,7 @@ token 按会话存储(由 `mcp-session-id` 请求头标识),并在同一
|
|
|
613
617
|
|
|
614
618
|
- 远程授权**仅适用于 Streamable HTTP 传输**
|
|
615
619
|
- 每个会话相互隔离。一个会话的 token 不能访问另一个会话的数据。会话关闭后 token 会自动清理。
|
|
616
|
-
- **会话超时:** 认证 token 在 `SESSION_TIMEOUT_SECONDS`(默认 1
|
|
620
|
+
- **会话超时:** 认证 token 在 `SESSION_TIMEOUT_SECONDS`(默认 1 小时)无活动后过期。超时后会话被关闭,之后的请求返回 `404`,客户端需带上认证请求头重新 initialize。
|
|
617
621
|
- 每个请求都会重置该会话的超时计时器。
|
|
618
622
|
- **Rate limiting:** `/mcp` 请求按客户端 IP 限制为每分钟 `MAX_REQUESTS_PER_MINUTE` 次;使用 OAuth 或远程授权时还按 MCP 会话限制(默认 60)。按 IP 的限制使用固定 60 秒窗口,按服务器进程分别计数,并同样覆盖 `GET /mcp`;stateless 模式会跳过按会话的限制。详见 [environment-variables.md](docs/configuration/environment-variables.md#max_requests_per_minute)。
|
|
619
623
|
- **Capacity limit:** 服务器最多接受 `MAX_SESSIONS` 个并发会话(默认 1000)。
|
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);
|
|
@@ -12133,6 +11870,9 @@ async function startStreamableHTTPServer() {
|
|
|
12133
11870
|
// names such as "constructor" from masquerading as live transports.
|
|
12134
11871
|
const streamableTransports = Object.create(null);
|
|
12135
11872
|
const authTimeouts = {};
|
|
11873
|
+
// Sessions with an open GET /mcp stream. The SDK allows one stream per session and
|
|
11874
|
+
// rejects a second GET with 409; that request must not touch the session's timer.
|
|
11875
|
+
const openGetStreams = new Set();
|
|
12136
11876
|
// Configuration and limits
|
|
12137
11877
|
const MAX_SESSIONS = Number.parseInt(process.env.MAX_SESSIONS || "1000", 10);
|
|
12138
11878
|
const MAX_REQUESTS_PER_MINUTE = Number.parseInt(process.env.MAX_REQUESTS_PER_MINUTE || "60", 10);
|
|
@@ -12385,7 +12125,9 @@ async function startStreamableHTTPServer() {
|
|
|
12385
12125
|
if (authData || transport) {
|
|
12386
12126
|
logger.info(authData
|
|
12387
12127
|
? `Session ${redactSessionIdForLog(sessionId)}: auth token expired after ${SESSION_TIMEOUT_SECONDS}s of inactivity`
|
|
12388
|
-
:
|
|
12128
|
+
: REMOTE_AUTHORIZATION || GITLAB_MCP_OAUTH
|
|
12129
|
+
? `Session ${redactSessionIdForLog(sessionId)}: unauthenticated discovery expired after ${SESSION_TIMEOUT_SECONDS}s`
|
|
12130
|
+
: `Session ${redactSessionIdForLog(sessionId)}: closed after ${SESSION_TIMEOUT_SECONDS}s of inactivity`);
|
|
12389
12131
|
delete authBySession[sessionId];
|
|
12390
12132
|
delete authTimeouts[sessionId];
|
|
12391
12133
|
metrics.expiredSessions++;
|
|
@@ -13146,6 +12888,15 @@ async function startStreamableHTTPServer() {
|
|
|
13146
12888
|
}
|
|
13147
12889
|
}
|
|
13148
12890
|
}
|
|
12891
|
+
// Server-side token mode (no per-session auth): every POST to a live session is
|
|
12892
|
+
// activity, so reset its inactivity timer. Without this, clients that disconnect
|
|
12893
|
+
// without DELETE /mcp hold their slot until MAX_SESSIONS is exhausted.
|
|
12894
|
+
if (!REMOTE_AUTHORIZATION &&
|
|
12895
|
+
!GITLAB_MCP_OAUTH &&
|
|
12896
|
+
sessionId &&
|
|
12897
|
+
streamableTransports[sessionId]) {
|
|
12898
|
+
setAuthTimeout(sessionId);
|
|
12899
|
+
}
|
|
13149
12900
|
// Handle request with proper AsyncLocalStorage context
|
|
13150
12901
|
const handleRequest = async () => {
|
|
13151
12902
|
try {
|
|
@@ -13164,6 +12915,11 @@ async function startStreamableHTTPServer() {
|
|
|
13164
12915
|
metrics.totalSessions++;
|
|
13165
12916
|
metrics.activeSessions++;
|
|
13166
12917
|
logger.warn(`Streamable HTTP session initialized: ${redactSessionIdForLog(newSessionId)}`);
|
|
12918
|
+
// Server-side token mode: no per-session auth, but the session still
|
|
12919
|
+
// expires after SESSION_TIMEOUT_SECONDS without activity.
|
|
12920
|
+
if (!REMOTE_AUTHORIZATION && !GITLAB_MCP_OAUTH) {
|
|
12921
|
+
setAuthTimeout(newSessionId);
|
|
12922
|
+
}
|
|
13167
12923
|
// Store auth for newly created session in remote mode
|
|
13168
12924
|
if (REMOTE_AUTHORIZATION && !authBySession[newSessionId]) {
|
|
13169
12925
|
const authData = parseAuthHeaders(req);
|
|
@@ -13214,6 +12970,8 @@ async function startStreamableHTTPServer() {
|
|
|
13214
12970
|
logger.warn(`Streamable HTTP transport closed for session ${redactSessionIdForLog(sid)}, cleaning up`);
|
|
13215
12971
|
delete streamableTransports[sid];
|
|
13216
12972
|
metrics.activeSessions--;
|
|
12973
|
+
openGetStreams.delete(sid);
|
|
12974
|
+
clearAuthTimeout(sid);
|
|
13217
12975
|
if (REMOTE_AUTHORIZATION || GITLAB_MCP_OAUTH) {
|
|
13218
12976
|
cleanupSessionAuth(sid);
|
|
13219
12977
|
delete sessionRequestCounts[sid];
|
|
@@ -13295,13 +13053,16 @@ async function startStreamableHTTPServer() {
|
|
|
13295
13053
|
return;
|
|
13296
13054
|
}
|
|
13297
13055
|
metrics.requestsProcessed++;
|
|
13298
|
-
const
|
|
13299
|
-
if (
|
|
13300
|
-
|
|
13301
|
-
|
|
13302
|
-
|
|
13303
|
-
|
|
13304
|
-
|
|
13056
|
+
const usesPerSessionAuth = REMOTE_AUTHORIZATION || GITLAB_MCP_OAUTH;
|
|
13057
|
+
if (usesPerSessionAuth && authBySession[sessionId]) {
|
|
13058
|
+
authBySession[sessionId].lastUsed = Date.now();
|
|
13059
|
+
}
|
|
13060
|
+
// Listening on GET /mcp is session activity. Pause inactivity expiry for
|
|
13061
|
+
// the life of the SSE stream so list_changed can still be pushed. A second GET
|
|
13062
|
+
// while a stream is open is rejected by the SDK and leaves the timer alone.
|
|
13063
|
+
const ownsStream = !openGetStreams.has(sessionId);
|
|
13064
|
+
if (ownsStream) {
|
|
13065
|
+
openGetStreams.add(sessionId);
|
|
13305
13066
|
clearAuthTimeout(sessionId);
|
|
13306
13067
|
}
|
|
13307
13068
|
const handleGetRequest = async () => {
|
|
@@ -13319,7 +13080,7 @@ async function startStreamableHTTPServer() {
|
|
|
13319
13080
|
}
|
|
13320
13081
|
};
|
|
13321
13082
|
try {
|
|
13322
|
-
if (
|
|
13083
|
+
if (usesPerSessionAuth && authBySession[sessionId]) {
|
|
13323
13084
|
const authData = authBySession[sessionId];
|
|
13324
13085
|
const ctx = {
|
|
13325
13086
|
sessionId,
|
|
@@ -13337,8 +13098,11 @@ async function startStreamableHTTPServer() {
|
|
|
13337
13098
|
}
|
|
13338
13099
|
}
|
|
13339
13100
|
finally {
|
|
13340
|
-
if (
|
|
13341
|
-
|
|
13101
|
+
if (ownsStream) {
|
|
13102
|
+
openGetStreams.delete(sessionId);
|
|
13103
|
+
if (streamableTransports[sessionId]) {
|
|
13104
|
+
setAuthTimeout(sessionId);
|
|
13105
|
+
}
|
|
13342
13106
|
}
|
|
13343
13107
|
}
|
|
13344
13108
|
});
|
|
@@ -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
|
+
}
|
package/package.json
CHANGED