castor-mcp 0.6.0

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.
Files changed (84) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +77 -0
  3. package/build/api-catalog.d.ts +27 -0
  4. package/build/api-catalog.js +76 -0
  5. package/build/api-catalog.js.map +1 -0
  6. package/build/confluence-client.d.ts +33 -0
  7. package/build/confluence-client.js +65 -0
  8. package/build/confluence-client.js.map +1 -0
  9. package/build/index.d.ts +2 -0
  10. package/build/index.js +137 -0
  11. package/build/index.js.map +1 -0
  12. package/build/resource-definitions.d.ts +10 -0
  13. package/build/resource-definitions.js +75 -0
  14. package/build/resource-definitions.js.map +1 -0
  15. package/build/tool-definitions.d.ts +19 -0
  16. package/build/tool-definitions.js +1811 -0
  17. package/build/tool-definitions.js.map +1 -0
  18. package/build/tools/admin-users-groups.d.ts +114 -0
  19. package/build/tools/admin-users-groups.js +150 -0
  20. package/build/tools/admin-users-groups.js.map +1 -0
  21. package/build/tools/admin.d.ts +12 -0
  22. package/build/tools/admin.js +30 -0
  23. package/build/tools/admin.js.map +1 -0
  24. package/build/tools/args.d.ts +2 -0
  25. package/build/tools/args.js +12 -0
  26. package/build/tools/args.js.map +1 -0
  27. package/build/tools/attachments.d.ts +138 -0
  28. package/build/tools/attachments.js +170 -0
  29. package/build/tools/attachments.js.map +1 -0
  30. package/build/tools/backup-restore.d.ts +144 -0
  31. package/build/tools/backup-restore.js +223 -0
  32. package/build/tools/backup-restore.js.map +1 -0
  33. package/build/tools/bulk-pages.d.ts +103 -0
  34. package/build/tools/bulk-pages.js +111 -0
  35. package/build/tools/bulk-pages.js.map +1 -0
  36. package/build/tools/color-schemes.d.ts +72 -0
  37. package/build/tools/color-schemes.js +121 -0
  38. package/build/tools/color-schemes.js.map +1 -0
  39. package/build/tools/content-structure.d.ts +164 -0
  40. package/build/tools/content-structure.js +220 -0
  41. package/build/tools/content-structure.js.map +1 -0
  42. package/build/tools/content.d.ts +194 -0
  43. package/build/tools/content.js +246 -0
  44. package/build/tools/content.js.map +1 -0
  45. package/build/tools/errors.d.ts +3 -0
  46. package/build/tools/errors.js +55 -0
  47. package/build/tools/errors.js.map +1 -0
  48. package/build/tools/index-management.d.ts +30 -0
  49. package/build/tools/index-management.js +64 -0
  50. package/build/tools/index-management.js.map +1 -0
  51. package/build/tools/labels.d.ts +108 -0
  52. package/build/tools/labels.js +160 -0
  53. package/build/tools/labels.js.map +1 -0
  54. package/build/tools/permissions.d.ts +554 -0
  55. package/build/tools/permissions.js +194 -0
  56. package/build/tools/permissions.js.map +1 -0
  57. package/build/tools/spaces-admin.d.ts +225 -0
  58. package/build/tools/spaces-admin.js +288 -0
  59. package/build/tools/spaces-admin.js.map +1 -0
  60. package/build/tools/spaces-pages.d.ts +103 -0
  61. package/build/tools/spaces-pages.js +150 -0
  62. package/build/tools/spaces-pages.js.map +1 -0
  63. package/build/tools/system.d.ts +42 -0
  64. package/build/tools/system.js +101 -0
  65. package/build/tools/system.js.map +1 -0
  66. package/build/tools/users-groups.d.ts +216 -0
  67. package/build/tools/users-groups.js +274 -0
  68. package/build/tools/users-groups.js.map +1 -0
  69. package/build/tools/webhooks.d.ts +105 -0
  70. package/build/tools/webhooks.js +124 -0
  71. package/build/tools/webhooks.js.map +1 -0
  72. package/build/version.d.ts +7 -0
  73. package/build/version.js +17 -0
  74. package/build/version.js.map +1 -0
  75. package/docs/api-catalog.yaml +2388 -0
  76. package/package.json +59 -0
  77. package/skills/content.md +85 -0
  78. package/skills/instance-maintenance.md +59 -0
  79. package/skills/permissions.md +47 -0
  80. package/skills/spaces-admin.md +59 -0
  81. package/skills/spaces-pages.md +24 -0
  82. package/skills/system.md +34 -0
  83. package/skills/users-groups.md +55 -0
  84. package/skills/webhooks.md +25 -0
@@ -0,0 +1,246 @@
1
+ import { z } from "zod";
2
+ import { withConfluenceErrorHandling } from "./errors.js";
3
+ import { jsonDetailBlock, MAX_LIST_RESULTS } from "./spaces-pages.js";
4
+ export function projectContentSummary(raw) {
5
+ return {
6
+ id: raw.id,
7
+ title: raw.title,
8
+ type: raw.type,
9
+ status: raw.status,
10
+ spaceKey: raw.space?.key ?? null,
11
+ };
12
+ }
13
+ export const ListContentArgsSchema = z.object({
14
+ spaceKey: z.string().optional(),
15
+ type: z.string().optional().describe('e.g. "page", "blogpost".'),
16
+ title: z.string().optional(),
17
+ status: z.string().optional().describe('e.g. "current", "trashed", "draft".'),
18
+ limit: z.number().int().positive().max(MAX_LIST_RESULTS).optional(),
19
+ });
20
+ export async function listContent(client, args) {
21
+ return withConfluenceErrorHandling(async () => {
22
+ // Confluence's default GET /content response omits `space` unless explicitly expanded —
23
+ // confirmed live (2026-08-20): without this, every projected item's spaceKey came back null
24
+ // even when a real space owned the content.
25
+ const response = await client.get("/rest/api/content", {
26
+ spaceKey: args.spaceKey,
27
+ type: args.type,
28
+ title: args.title,
29
+ status: args.status,
30
+ limit: args.limit,
31
+ expand: "space",
32
+ });
33
+ const items = (response.data.results ?? []).slice(0, MAX_LIST_RESULTS).map(projectContentSummary);
34
+ return {
35
+ content: [
36
+ { type: "text", text: `✅ ${items.length} content item(s) visible` },
37
+ jsonDetailBlock(items),
38
+ ],
39
+ };
40
+ });
41
+ }
42
+ export const DeletePageArgsSchema = z.object({
43
+ pageId: z.string().min(1),
44
+ status: z
45
+ .string()
46
+ .optional()
47
+ .describe('Pass "trashed" (matching the page\'s current status) to permanently purge an already-' +
48
+ 'trashed page. Omit to trash a current page — passing "current" here does nothing.'),
49
+ });
50
+ export async function deletePage(client, args) {
51
+ return withConfluenceErrorHandling(async () => {
52
+ await client.delete(`/rest/api/content/${encodeURIComponent(args.pageId)}`, { status: args.status });
53
+ return { content: [{ type: "text", text: `✅ Page ${args.pageId} deleted` }] };
54
+ });
55
+ }
56
+ export const GetPageHistoryArgsSchema = z.object({ pageId: z.string().min(1) });
57
+ // The swagger schema's ReferenceVersion is a thin lazy-loaded wrapper ({idProperties, expanded}) —
58
+ // confirmed live (2026-08-20) that the real, non-expanded response nests the useful fields
59
+ // (`by`, `when`, `number`) directly, not under `idProperties`. Read defensively either way.
60
+ function projectVersionRef(raw) {
61
+ const by = raw?.by?.displayName ?? raw?.idProperties?.by?.displayName ?? null;
62
+ const when = raw?.when ?? raw?.idProperties?.when ?? null;
63
+ const number = raw?.number ?? raw?.idProperties?.number ?? null;
64
+ return { by, when, number };
65
+ }
66
+ export async function getPageHistory(client, args) {
67
+ return withConfluenceErrorHandling(async () => {
68
+ const response = await client.get(`/rest/api/content/${encodeURIComponent(args.pageId)}/history`);
69
+ const raw = response.data;
70
+ const lastUpdated = projectVersionRef(raw.lastUpdated);
71
+ const projected = {
72
+ latest: raw.latest ?? null,
73
+ createdByDisplayName: raw.createdBy?.displayName ?? null,
74
+ createdDate: raw.createdDate ?? null,
75
+ lastUpdatedByDisplayName: lastUpdated.by,
76
+ lastUpdatedWhen: lastUpdated.when,
77
+ lastUpdatedVersionNumber: lastUpdated.number,
78
+ };
79
+ return {
80
+ content: [
81
+ { type: "text", text: `✅ History for page ${args.pageId} retrieved` },
82
+ jsonDetailBlock(projected),
83
+ ],
84
+ };
85
+ });
86
+ }
87
+ const MacroArgsBase = { pageId: z.string().min(1), version: z.number().int().positive() };
88
+ export const GetPageMacroBodyByHashArgsSchema = z.object({ ...MacroArgsBase, hash: z.string().min(1) });
89
+ function projectMacroInstance(raw) {
90
+ return { name: raw.name ?? null, body: raw.body ?? null, parameters: raw.parameters ?? {} };
91
+ }
92
+ export async function getPageMacroBodyByHash(client, args) {
93
+ return withConfluenceErrorHandling(async () => {
94
+ const response = await client.get(`/rest/api/content/${encodeURIComponent(args.pageId)}/history/${args.version}/macro/hash/${encodeURIComponent(args.hash)}`);
95
+ const macro = projectMacroInstance(response.data);
96
+ return {
97
+ content: [
98
+ { type: "text", text: `✅ Macro body retrieved (hash ${args.hash})` },
99
+ jsonDetailBlock(macro),
100
+ ],
101
+ };
102
+ });
103
+ }
104
+ export const GetPageMacroBodyByIdArgsSchema = z.object({ ...MacroArgsBase, macroId: z.string().min(1) });
105
+ export async function getPageMacroBodyById(client, args) {
106
+ return withConfluenceErrorHandling(async () => {
107
+ const response = await client.get(`/rest/api/content/${encodeURIComponent(args.pageId)}/history/${args.version}/macro/id/${encodeURIComponent(args.macroId)}`);
108
+ const macro = projectMacroInstance(response.data);
109
+ return {
110
+ content: [
111
+ { type: "text", text: `✅ Macro body retrieved (macroId ${args.macroId})` },
112
+ jsonDetailBlock(macro),
113
+ ],
114
+ };
115
+ });
116
+ }
117
+ function projectContentProperty(raw) {
118
+ return { id: raw.id, key: raw.key, value: raw.value, version: raw.version?.number ?? null };
119
+ }
120
+ export const ListPagePropertiesArgsSchema = z.object({ pageId: z.string().min(1) });
121
+ export async function listPageProperties(client, args) {
122
+ return withConfluenceErrorHandling(async () => {
123
+ const response = await client.get(`/rest/api/content/${encodeURIComponent(args.pageId)}/property`);
124
+ const properties = (response.data.results ?? []).map(projectContentProperty);
125
+ return {
126
+ content: [
127
+ { type: "text", text: `✅ ${properties.length} propert(y/ies) on page ${args.pageId}` },
128
+ jsonDetailBlock(properties),
129
+ ],
130
+ };
131
+ });
132
+ }
133
+ export const GetPagePropertyArgsSchema = z.object({ pageId: z.string().min(1), key: z.string().min(1) });
134
+ export async function getPageProperty(client, args) {
135
+ return withConfluenceErrorHandling(async () => {
136
+ const response = await client.get(`/rest/api/content/${encodeURIComponent(args.pageId)}/property/${encodeURIComponent(args.key)}`);
137
+ const property = projectContentProperty(response.data);
138
+ return {
139
+ content: [
140
+ { type: "text", text: `✅ Property "${args.key}" on page ${args.pageId} retrieved` },
141
+ jsonDetailBlock(property),
142
+ ],
143
+ };
144
+ });
145
+ }
146
+ export const CreatePagePropertyArgsSchema = z.object({
147
+ pageId: z.string().min(1),
148
+ key: z.string().min(1),
149
+ value: z.unknown().describe("Any JSON-serializable value."),
150
+ });
151
+ export async function createPageProperty(client, args) {
152
+ return withConfluenceErrorHandling(async () => {
153
+ const response = await client.post(`/rest/api/content/${encodeURIComponent(args.pageId)}/property`, {
154
+ key: args.key,
155
+ value: args.value,
156
+ });
157
+ const property = projectContentProperty(response.data);
158
+ return {
159
+ content: [
160
+ { type: "text", text: `✅ Property "${args.key}" created on page ${args.pageId}` },
161
+ jsonDetailBlock(property),
162
+ ],
163
+ };
164
+ });
165
+ }
166
+ export const UpdatePagePropertyArgsSchema = z.object({
167
+ pageId: z.string().min(1),
168
+ key: z.string().min(1),
169
+ value: z.unknown(),
170
+ currentVersion: z.number().int().positive().describe("From list_page_properties/get_page_property's version field."),
171
+ });
172
+ export async function updatePageProperty(client, args) {
173
+ return withConfluenceErrorHandling(async () => {
174
+ const response = await client.put(`/rest/api/content/${encodeURIComponent(args.pageId)}/property/${encodeURIComponent(args.key)}`, { key: args.key, value: args.value, version: { number: args.currentVersion + 1 } });
175
+ const property = projectContentProperty(response.data);
176
+ return {
177
+ content: [
178
+ { type: "text", text: `✅ Property "${args.key}" updated to v${property.version} on page ${args.pageId}` },
179
+ jsonDetailBlock(property),
180
+ ],
181
+ };
182
+ });
183
+ }
184
+ export const DeletePagePropertyArgsSchema = z.object({ pageId: z.string().min(1), key: z.string().min(1) });
185
+ export async function deletePageProperty(client, args) {
186
+ return withConfluenceErrorHandling(async () => {
187
+ await client.delete(`/rest/api/content/${encodeURIComponent(args.pageId)}/property/${encodeURIComponent(args.key)}`);
188
+ return { content: [{ type: "text", text: `✅ Property "${args.key}" deleted from page ${args.pageId}` }] };
189
+ });
190
+ }
191
+ export const DeletePageVersionArgsSchema = z.object({
192
+ pageId: z.string().min(1),
193
+ versionNumber: z.number().int().positive(),
194
+ });
195
+ export async function deletePageVersion(client, args) {
196
+ return withConfluenceErrorHandling(async () => {
197
+ await client.delete(`/rest/api/content/${encodeURIComponent(args.pageId)}/version/${args.versionNumber}`);
198
+ return { content: [{ type: "text", text: `✅ Version ${args.versionNumber} of page ${args.pageId} deleted` }] };
199
+ });
200
+ }
201
+ export const ScanContentArgsSchema = z.object({
202
+ spaceKey: z.string().optional(),
203
+ type: z.string().optional(),
204
+ cursor: z.string().optional().describe("From a previous scan_content call's nextCursor."),
205
+ limit: z.number().int().positive().max(MAX_LIST_RESULTS).optional(),
206
+ });
207
+ export async function scanContent(client, args) {
208
+ return withConfluenceErrorHandling(async () => {
209
+ const response = await client.get("/rest/api/content/scan", {
210
+ spaceKey: args.spaceKey,
211
+ type: args.type,
212
+ cursor: args.cursor,
213
+ limit: args.limit,
214
+ expand: "space",
215
+ });
216
+ const items = (response.data.results ?? []).slice(0, MAX_LIST_RESULTS).map(projectContentSummary);
217
+ const nextCursor = response.data.nextCursor ?? null;
218
+ return {
219
+ content: [
220
+ { type: "text", text: `✅ ${items.length} content item(s) scanned${nextCursor ? " (more available)" : ""}` },
221
+ jsonDetailBlock({ items, nextCursor }),
222
+ ],
223
+ };
224
+ });
225
+ }
226
+ export const ConvertContentBodyArgsSchema = z.object({
227
+ value: z.string().min(1),
228
+ from: z.string().describe('Source representation, e.g. "storage", "wiki", "view".'),
229
+ to: z.string().describe('Target representation, e.g. "view", "storage", "export_view".'),
230
+ });
231
+ export async function convertContentBody(client, args) {
232
+ return withConfluenceErrorHandling(async () => {
233
+ const response = await client.post(`/rest/api/contentbody/convert/${encodeURIComponent(args.to)}`, {
234
+ value: args.value,
235
+ representation: args.from,
236
+ });
237
+ const body = { value: response.data.value, representation: response.data.representation };
238
+ return {
239
+ content: [
240
+ { type: "text", text: `✅ Converted body from ${args.from} to ${args.to}` },
241
+ jsonDetailBlock(body),
242
+ ],
243
+ };
244
+ });
245
+ }
246
+ //# sourceMappingURL=content.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content.js","sourceRoot":"","sources":["../../src/tools/content.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAc,eAAe,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAU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,wDAAwD,CAAC;IACnF,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,+DAA+D,CAAC;CACzF,CAAC,CAAC;AAGH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,MAAwB,EACxB,IAA4B;IAE5B,OAAO,2BAA2B,CAAC,KAAK,IAAI,EAAE;QAC5C,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,iCAAiC,kBAAkB,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE;YACjG,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,cAAc,EAAE,IAAI,CAAC,IAAI;SAC1B,CAAC,CAAC;QACH,MAAM,IAAI,GAAG,EAAE,KAAK,EAAE,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,cAAc,EAAE,QAAQ,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC;QAC1F,OAAO;YACL,OAAO,EAAE;gBACP,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,yBAAyB,IAAI,CAAC,IAAI,OAAO,IAAI,CAAC,EAAE,EAAE,EAAE;gBAC1E,eAAe,CAAC,IAAI,CAAC;aACtB;SACF,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { McpError } from "@modelcontextprotocol/sdk/types.js";
2
+ export declare function mapConfluenceError(error: unknown): McpError;
3
+ export declare function withConfluenceErrorHandling<T>(fn: () => Promise<T>): Promise<T>;
@@ -0,0 +1,55 @@
1
+ import axios from "axios";
2
+ import { ErrorCode, McpError } from "@modelcontextprotocol/sdk/types.js";
3
+ const MAX_ERROR_BODY_LENGTH = 500;
4
+ const TRUNCATION_MARKER = "... (truncated)";
5
+ function truncate(text, maxLength) {
6
+ if (text.length <= maxLength)
7
+ return text;
8
+ return text.slice(0, maxLength) + TRUNCATION_MARKER;
9
+ }
10
+ /** Confluence's validation error shape: `{ message: string, statusCode?: number }`. */
11
+ function extractValidationMessage(data) {
12
+ if (!data || typeof data !== "object")
13
+ return null;
14
+ const body = data;
15
+ return typeof body.message === "string" && body.message.length > 0 ? body.message : null;
16
+ }
17
+ export function mapConfluenceError(error) {
18
+ if (axios.isAxiosError(error) && error.response) {
19
+ const status = error.response.status;
20
+ const validationMessage = extractValidationMessage(error.response.data);
21
+ if (status === 401) {
22
+ return new McpError(ErrorCode.InvalidRequest, "Confluence rejected the request (401 Unauthorized) — check your CONFLUENCE_USER_TOKEN/CONFLUENCE_ADMIN_TOKEN.");
23
+ }
24
+ if (status === 403) {
25
+ return new McpError(ErrorCode.InvalidRequest, "Confluence denied permission (403 Forbidden) for this operation under the acting token's permissions.");
26
+ }
27
+ if (status === 404) {
28
+ return new McpError(ErrorCode.InvalidRequest, "Confluence could not find the requested resource (404 Not Found).");
29
+ }
30
+ if (status === 400) {
31
+ return new McpError(ErrorCode.InvalidRequest, validationMessage
32
+ ? `Confluence rejected the request (400 Bad Request): ${validationMessage}`
33
+ : "Confluence rejected the request (400 Bad Request) — no further validation detail was provided.");
34
+ }
35
+ if (status === 409) {
36
+ return new McpError(ErrorCode.InvalidRequest, `Confluence rejected the request (409 Conflict) — likely a page version mismatch; ` +
37
+ `call get_page again for the current version before retrying update_page.` +
38
+ (validationMessage ? ` Detail: ${validationMessage}` : ""));
39
+ }
40
+ if (status === 429) {
41
+ return new McpError(ErrorCode.InternalError, "Confluence rate-limited the request (429 Too Many Requests) — this is retryable; back off and try again.");
42
+ }
43
+ return new McpError(ErrorCode.InternalError, `Confluence API error ${status}: ${truncate(JSON.stringify(error.response.data), MAX_ERROR_BODY_LENGTH)}`);
44
+ }
45
+ return new McpError(ErrorCode.InternalError, error instanceof Error ? error.message : String(error));
46
+ }
47
+ export async function withConfluenceErrorHandling(fn) {
48
+ try {
49
+ return await fn();
50
+ }
51
+ catch (error) {
52
+ throw mapConfluenceError(error);
53
+ }
54
+ }
55
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"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AAM,EAAE,EAAE,CAAC;IACpB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,kBAAkB,CAAC,KAAK,CAAC,CAAC;IAClC,CAAC;AACH,CAAC"}
@@ -0,0 +1,30 @@
1
+ import { z } from "zod";
2
+ import { ConfluenceClient } from "../confluence-client.js";
3
+ import { ToolResult } from "./spaces-pages.js";
4
+ export declare const GetReindexStatusArgsSchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
5
+ export type GetReindexStatusArgs = z.infer<typeof GetReindexStatusArgsSchema>;
6
+ export declare function getReindexStatus(client: ConfluenceClient, _args: GetReindexStatusArgs): Promise<ToolResult>;
7
+ export declare const TriggerReindexArgsSchema: z.ZodObject<{
8
+ confirm: z.ZodBoolean;
9
+ spaceKey: z.ZodOptional<z.ZodString>;
10
+ }, "strip", z.ZodTypeAny, {
11
+ confirm: boolean;
12
+ spaceKey?: string | undefined;
13
+ }, {
14
+ confirm: boolean;
15
+ spaceKey?: string | undefined;
16
+ }>;
17
+ export type TriggerReindexArgs = z.infer<typeof TriggerReindexArgsSchema>;
18
+ export declare function triggerReindex(client: ConfluenceClient, args: TriggerReindexArgs): Promise<ToolResult>;
19
+ export declare const ResetReindexJobArgsSchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
20
+ export type ResetReindexJobArgs = z.infer<typeof ResetReindexJobArgsSchema>;
21
+ export declare function resetReindexJob(client: ConfluenceClient, _args: ResetReindexJobArgs): Promise<ToolResult>;
22
+ export declare const UnindexAllContentArgsSchema: z.ZodObject<{
23
+ confirm: z.ZodBoolean;
24
+ }, "strip", z.ZodTypeAny, {
25
+ confirm: boolean;
26
+ }, {
27
+ confirm: boolean;
28
+ }>;
29
+ export type UnindexAllContentArgs = z.infer<typeof UnindexAllContentArgsSchema>;
30
+ export declare function unindexAllContent(client: ConfluenceClient, args: UnindexAllContentArgs): Promise<ToolResult>;
@@ -0,0 +1,64 @@
1
+ import { z } from "zod";
2
+ import { ErrorCode, McpError } from "@modelcontextprotocol/sdk/types.js";
3
+ import { withConfluenceErrorHandling } from "./errors.js";
4
+ import { jsonDetailBlock } from "./spaces-pages.js";
5
+ export const GetReindexStatusArgsSchema = z.object({});
6
+ export async function getReindexStatus(client, _args) {
7
+ return withConfluenceErrorHandling(async () => {
8
+ const response = await client.get("/rest/api/index/reindex");
9
+ return {
10
+ content: [
11
+ { type: "text", text: "✅ Reindex status retrieved" },
12
+ jsonDetailBlock(response.data),
13
+ ],
14
+ };
15
+ });
16
+ }
17
+ export const TriggerReindexArgsSchema = z.object({
18
+ confirm: z.boolean().describe("Must be true — rebuilding the search index is resource-intensive and disruptive while running."),
19
+ spaceKey: z.string().optional().describe("Omit to reindex the entire instance."),
20
+ });
21
+ export async function triggerReindex(client, args) {
22
+ if (!args.confirm) {
23
+ throw new McpError(ErrorCode.InvalidParams, "trigger_reindex requires confirm: true — this rebuilds the search index, which is resource-intensive and disrupts search while running.");
24
+ }
25
+ return withConfluenceErrorHandling(async () => {
26
+ const response = await client.post(`/rest/api/index/reindex${args.spaceKey ? `?spaceKey=${encodeURIComponent(args.spaceKey)}` : ""}`);
27
+ return {
28
+ content: [
29
+ { type: "text", text: `✅ Reindex triggered${args.spaceKey ? ` for space ${args.spaceKey}` : " for the entire instance"}` },
30
+ jsonDetailBlock(response.data),
31
+ ],
32
+ };
33
+ });
34
+ }
35
+ export const ResetReindexJobArgsSchema = z.object({});
36
+ export async function resetReindexJob(client, _args) {
37
+ return withConfluenceErrorHandling(async () => {
38
+ const response = await client.put("/rest/api/index/resetjob");
39
+ return {
40
+ content: [
41
+ { type: "text", text: "✅ Reindex job status reset" },
42
+ jsonDetailBlock(response.data),
43
+ ],
44
+ };
45
+ });
46
+ }
47
+ export const UnindexAllContentArgsSchema = z.object({
48
+ confirm: z.boolean().describe("Must be true — this removes ALL content from the search index; search returns nothing until a reindex completes."),
49
+ });
50
+ export async function unindexAllContent(client, args) {
51
+ if (!args.confirm) {
52
+ throw new McpError(ErrorCode.InvalidParams, "unindex_all_content requires confirm: true — this removes ALL content from the search index until a reindex completes.");
53
+ }
54
+ return withConfluenceErrorHandling(async () => {
55
+ const response = await client.post("/rest/api/index/unindex");
56
+ return {
57
+ content: [
58
+ { type: "text", text: "✅ All content removed from the search index — trigger_reindex to restore search" },
59
+ jsonDetailBlock(response.data),
60
+ ],
61
+ };
62
+ });
63
+ }
64
+ //# sourceMappingURL=index-management.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-management.js","sourceRoot":"","sources":["../../src/tools/index-management.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CAAC;AAEzE,OAAO,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAc,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEhE,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAGvD,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,MAAwB,EAAE,KAA2B;IAC1F,OAAO,2BAA2B,CAAC,KAAK,IAAI,EAAE;QAC5C,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC;QAC7D,OAAO;YACL,OAAO,EAAE;gBACP,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,4BAA4B,EAAE;gBACpD,eAAe,CAAC,QAAQ,CAAC,IAAI,CAAC;aAC/B;SACF,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/C,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,CAAC,gGAAgG,CAAC;IAC/H,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAA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CAAC;AAED,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC,MAAM,CAAC;IAClD,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,CAAC,kHAAkH,CAAC;CAClJ,CAAC,CAAC;AAGH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,MAAwB,EAAE,IAA2B;IAC3F,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;QAClB,MAAM,IAAI,QAAQ,CAAC,SAAS,CAAC,aAAa,EAAE,wHAAwH,CAAC,CAAC;IACxK,CAAC;IACD,OAAO,2BAA2B,CAAC,KAAK,IAAI,EAAE;QAC5C,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;QAC9D,OAAO;YACL,OAAO,EAAE;gBACP,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,iFAAiF,EAAE;gBACzG,eAAe,CAAC,QAAQ,CAAC,IAAI,CAAC;aAC/B;SACF,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,108 @@
1
+ import { z } from "zod";
2
+ import { ConfluenceClient } from "../confluence-client.js";
3
+ import { ToolResult } from "./spaces-pages.js";
4
+ export declare const ListPageLabelsArgsSchema: z.ZodObject<{
5
+ pageId: z.ZodString;
6
+ }, "strip", z.ZodTypeAny, {
7
+ pageId: string;
8
+ }, {
9
+ pageId: string;
10
+ }>;
11
+ export type ListPageLabelsArgs = z.infer<typeof ListPageLabelsArgsSchema>;
12
+ export declare function listPageLabels(client: ConfluenceClient, args: ListPageLabelsArgs): Promise<ToolResult>;
13
+ export declare const AddPageLabelsArgsSchema: z.ZodObject<{
14
+ pageId: z.ZodString;
15
+ names: z.ZodArray<z.ZodString, "many">;
16
+ }, "strip", z.ZodTypeAny, {
17
+ pageId: string;
18
+ names: string[];
19
+ }, {
20
+ pageId: string;
21
+ names: string[];
22
+ }>;
23
+ export type AddPageLabelsArgs = z.infer<typeof AddPageLabelsArgsSchema>;
24
+ export declare function addPageLabels(client: ConfluenceClient, args: AddPageLabelsArgs): Promise<ToolResult>;
25
+ export declare const DeletePageLabelArgsSchema: z.ZodObject<{
26
+ pageId: z.ZodString;
27
+ label: z.ZodString;
28
+ }, "strip", z.ZodTypeAny, {
29
+ pageId: string;
30
+ label: string;
31
+ }, {
32
+ pageId: string;
33
+ label: string;
34
+ }>;
35
+ export type DeletePageLabelArgs = z.infer<typeof DeletePageLabelArgsSchema>;
36
+ export declare function deletePageLabel(client: ConfluenceClient, args: DeletePageLabelArgs): Promise<ToolResult>;
37
+ export declare const GetRelatedLabelsArgsSchema: z.ZodObject<{
38
+ labelName: z.ZodString;
39
+ }, "strip", z.ZodTypeAny, {
40
+ labelName: string;
41
+ }, {
42
+ labelName: string;
43
+ }>;
44
+ export type GetRelatedLabelsArgs = z.infer<typeof GetRelatedLabelsArgsSchema>;
45
+ export declare function getRelatedLabels(client: ConfluenceClient, args: GetRelatedLabelsArgs): Promise<ToolResult>;
46
+ export declare const SearchLabelsArgsSchema: z.ZodObject<{
47
+ spaceKey: z.ZodOptional<z.ZodString>;
48
+ owner: z.ZodOptional<z.ZodString>;
49
+ namespace: z.ZodOptional<z.ZodString>;
50
+ labelName: z.ZodOptional<z.ZodString>;
51
+ }, "strip", z.ZodTypeAny, {
52
+ spaceKey?: string | undefined;
53
+ labelName?: string | undefined;
54
+ owner?: string | undefined;
55
+ namespace?: string | undefined;
56
+ }, {
57
+ spaceKey?: string | undefined;
58
+ labelName?: string | undefined;
59
+ owner?: string | undefined;
60
+ namespace?: string | undefined;
61
+ }>;
62
+ export type SearchLabelsArgs = z.infer<typeof SearchLabelsArgsSchema>;
63
+ export declare function searchLabels(client: ConfluenceClient, args: SearchLabelsArgs): Promise<ToolResult>;
64
+ export declare const GetPopularLabelsArgsSchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
65
+ export type GetPopularLabelsArgs = z.infer<typeof GetPopularLabelsArgsSchema>;
66
+ export declare function getPopularLabels(client: ConfluenceClient, _args: GetPopularLabelsArgs): Promise<ToolResult>;
67
+ export declare const GetRecentLabelsArgsSchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
68
+ export type GetRecentLabelsArgs = z.infer<typeof GetRecentLabelsArgsSchema>;
69
+ export declare function getRecentLabels(client: ConfluenceClient, _args: GetRecentLabelsArgs): Promise<ToolResult>;
70
+ export declare const ListSpaceLabelsArgsSchema: z.ZodObject<{
71
+ spaceKey: z.ZodString;
72
+ }, "strip", z.ZodTypeAny, {
73
+ spaceKey: string;
74
+ }, {
75
+ spaceKey: string;
76
+ }>;
77
+ export type ListSpaceLabelsArgs = z.infer<typeof ListSpaceLabelsArgsSchema>;
78
+ export declare function listSpaceLabels(client: ConfluenceClient, args: ListSpaceLabelsArgs): Promise<ToolResult>;
79
+ export declare const GetSpaceRelatedLabelsArgsSchema: z.ZodObject<{
80
+ spaceKey: z.ZodString;
81
+ labelName: z.ZodString;
82
+ }, "strip", z.ZodTypeAny, {
83
+ spaceKey: string;
84
+ labelName: string;
85
+ }, {
86
+ spaceKey: string;
87
+ labelName: string;
88
+ }>;
89
+ export type GetSpaceRelatedLabelsArgs = z.infer<typeof GetSpaceRelatedLabelsArgsSchema>;
90
+ export declare function getSpaceRelatedLabels(client: ConfluenceClient, args: GetSpaceRelatedLabelsArgs): Promise<ToolResult>;
91
+ export declare const GetSpacePopularLabelsArgsSchema: z.ZodObject<{
92
+ spaceKey: z.ZodString;
93
+ }, "strip", z.ZodTypeAny, {
94
+ spaceKey: string;
95
+ }, {
96
+ spaceKey: string;
97
+ }>;
98
+ export type GetSpacePopularLabelsArgs = z.infer<typeof GetSpacePopularLabelsArgsSchema>;
99
+ export declare function getSpacePopularLabels(client: ConfluenceClient, args: GetSpacePopularLabelsArgs): Promise<ToolResult>;
100
+ export declare const GetSpaceRecentLabelsArgsSchema: z.ZodObject<{
101
+ spaceKey: z.ZodString;
102
+ }, "strip", z.ZodTypeAny, {
103
+ spaceKey: string;
104
+ }, {
105
+ spaceKey: string;
106
+ }>;
107
+ export type GetSpaceRecentLabelsArgs = z.infer<typeof GetSpaceRecentLabelsArgsSchema>;
108
+ export declare function getSpaceRecentLabels(client: ConfluenceClient, args: GetSpaceRecentLabelsArgs): Promise<ToolResult>;