@archbee/mcp 2.1.0 → 2.3.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.
package/src/index.ts CHANGED
@@ -4,7 +4,34 @@ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'
4
4
  import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'
5
5
  import { type CallToolResult } from '@modelcontextprotocol/sdk/types.js'
6
6
  import axios from 'axios'
7
- import { z } from 'zod'
7
+ import {
8
+ applyTemplateSchema,
9
+ createCategorySchema,
10
+ createContentSnippetSchema,
11
+ createDocSchema,
12
+ createDocSpaceSchema,
13
+ createSpaceGroupSchema,
14
+ createTemplateSchema,
15
+ createVariableSchema,
16
+ deleteCategorySchema,
17
+ deleteContentSnippetSchema,
18
+ deleteDocSchema,
19
+ deleteDocSpaceSchema,
20
+ deleteSpaceGroupSchema,
21
+ deleteTemplateSchema,
22
+ deleteVariableSchema,
23
+ getAllDocsSchema,
24
+ getDocSchema,
25
+ listContentSnippetsSchema,
26
+ listTemplatesSchema,
27
+ listVariablesSchema,
28
+ searchQuerySchema,
29
+ searchTitleSchema,
30
+ updateContentSnippetSchema,
31
+ updateDocSchema,
32
+ updateDocSpaceSchema,
33
+ updateVariableSchema,
34
+ } from './tool-schemas'
8
35
 
9
36
  interface McpApiParams {
10
37
  tool: string
@@ -19,8 +46,15 @@ interface McpApiParams {
19
46
  description?: string
20
47
  previewImgURL?: string
21
48
  hidden?: boolean
49
+ icon?: string
22
50
  recursive?: boolean
23
51
  name?: string
52
+ templateId?: string
53
+ snippetId?: string
54
+ variableId?: string
55
+ variableType?: 'variable' | 'glossary'
56
+ variableContent?: string
57
+ spaceTargetMap?: Record<string, string>
24
58
  categoryName?: string
25
59
  categoryId?: string
26
60
  docSpaceGroupId?: string
@@ -39,340 +73,198 @@ const TEAM_API_KEY_PREFIX = 'abteam_'
39
73
  const usesTeamApiKey = (): boolean =>
40
74
  (process.env.API_KEY || '').startsWith(TEAM_API_KEY_PREFIX)
41
75
 
42
- const docSpaceIdArg = {
43
- docSpaceId: z
44
- .string()
45
- .optional()
46
- .describe(
47
- 'Space to act on. Required when API_KEY is a team key (starts with `abteam_`), which can reach every space in the team. Ignored with a space API key, since that key already names its space.'
48
- ),
49
- }
50
-
51
- const MDX_FORMAT_DESCRIPTION =
52
- 'Format of `content`. Use `mdx` when the content contains JSX-style Archbee components such as `<hint>`, `<CtaButton />` or `<Tabs>` — with plain markdown those degrade to raw html blocks. Directive-style components (`:::hint{type="info"}`) work in both formats. Defaults to markdown when omitted.'
53
-
54
76
  // Create an MCP server
55
77
  const server = new McpServer({
56
78
  name: 'Archbee MCP',
57
- version: '2.1.0',
79
+ version: '2.3.0',
58
80
  })
59
81
 
60
82
  server.tool(
61
83
  'get_all_docs',
62
84
  'Read every document in the Archbee doc space, with its content, and each document carries the name of the space it belongs to (docSpaceName). Returns the whole space, so prefer search_query or search_title when looking for something specific.',
63
- { ...docSpaceIdArg },
64
- async ({ docSpaceId }) => {
65
- const params = {
66
- tool: 'get-all-docs',
67
- docSpaceId,
68
- }
69
- return callMcpApi(params)
70
- }
85
+ getAllDocsSchema,
86
+ async (args) => callMcpApi({ tool: 'get-all-docs', ...args })
71
87
  )
72
88
 
73
89
  server.tool(
74
90
  'get_doc',
75
91
  'Read one Archbee document by id and return its content as markdown, alongside the id and name of the space it lives in.',
76
- {
77
- docId: z
78
- .string()
79
- .describe(
80
- 'ID of the document to read, as returned by search_query, search_title or get_all_docs.'
81
- ),
82
- ...docSpaceIdArg,
83
- },
84
- async ({ docId, docSpaceId }) => {
85
- const params = {
86
- tool: 'get-doc',
87
- docId,
88
- docSpaceId,
89
- }
90
- return callMcpApi(params)
91
- }
92
+ getDocSchema,
93
+ async (args) => callMcpApi({ tool: 'get-doc', ...args })
92
94
  )
93
95
 
94
96
  server.tool(
95
97
  'search_query',
96
98
  'Search the Archbee doc space by document content and return the matching documents. This is the tool to use for answering a question from the documentation. An empty query returns every document.',
97
- {
98
- query: z
99
- .string()
100
- .describe('Text to look for inside the content of the documents.'),
101
- ...docSpaceIdArg,
102
- },
103
- async ({ query, docSpaceId }) => {
104
- const params = {
105
- tool: 'search-query',
106
- query,
107
- docSpaceId,
108
- }
109
- return callMcpApi(params)
110
- }
99
+ searchQuerySchema,
100
+ async (args) => callMcpApi({ tool: 'search-query', ...args })
111
101
  )
112
102
 
113
103
  server.tool(
114
104
  'search_title',
115
105
  'Search the Archbee doc space by document title. Use this when looking for a page by name; use search_query to search inside document content.',
116
- {
117
- query: z.string().describe('Text to look for in the document titles.'),
118
- ...docSpaceIdArg,
119
- },
120
- async ({ query, docSpaceId }) => {
121
- const params = {
122
- tool: 'search-title',
123
- query,
124
- docSpaceId,
125
- }
126
- return callMcpApi(params)
127
- }
106
+ searchTitleSchema,
107
+ async (args) => callMcpApi({ tool: 'search-title', ...args })
128
108
  )
129
109
 
130
110
  // Write tools. With a space key the target space comes from SPACE_ID; with a
131
- // team key it comes from the docSpaceId argument, which the three team-level
132
- // tools below do not take because they act on the team, not on a space.
111
+ // team key it comes from the docSpaceId argument, which the team-level tools
112
+ // below do not take because they act on the team, not on a space.
133
113
 
134
114
  server.tool(
135
115
  'create_doc',
136
116
  'Create a new document in the Archbee doc space from Markdown or MDX content.',
137
- {
138
- content: z
139
- .string()
140
- .describe(
141
- 'Body of the document to create, as Markdown or MDX text. JSON document content is not accepted.'
142
- ),
143
- format: z
144
- .enum(['markdown', 'mdx'])
145
- .optional()
146
- .describe(MDX_FORMAT_DESCRIPTION),
147
- title: z.string().optional().describe('Title of the document.'),
148
- parentDocId: z
149
- .string()
150
- .optional()
151
- .describe('ID of the parent document to nest this document under.'),
152
- slug: z.string().optional().describe('URL slug for the document.'),
153
- description: z
154
- .string()
155
- .optional()
156
- .describe('Short description / summary of the document.'),
157
- previewImgURL: z
158
- .string()
159
- .optional()
160
- .describe('URL of the preview / social image for the document.'),
161
- hidden: z
162
- .boolean()
163
- .optional()
164
- .describe('When true, the document is hidden from navigation.'),
165
- ...docSpaceIdArg,
166
- },
117
+ createDocSchema,
167
118
  async (args) => callWriteApi({ tool: 'create-doc', ...args })
168
119
  )
169
120
 
170
121
  server.tool(
171
122
  'update_doc',
172
123
  'Update an existing Archbee document. Only the provided fields are changed.',
173
- {
174
- docId: z.string().describe('ID of the document to update.'),
175
- content: z
176
- .string()
177
- .optional()
178
- .describe(
179
- 'New body for the document, as Markdown or MDX text. JSON document content is not accepted.'
180
- ),
181
- format: z
182
- .enum(['markdown', 'mdx'])
183
- .optional()
184
- .describe(MDX_FORMAT_DESCRIPTION),
185
- title: z.string().optional().describe('New title of the document.'),
186
- parentDocId: z
187
- .string()
188
- .optional()
189
- .describe('ID of the parent document to move this document under.'),
190
- slug: z.string().optional().describe('New URL slug for the document.'),
191
- description: z
192
- .string()
193
- .optional()
194
- .describe('New short description / summary of the document.'),
195
- previewImgURL: z
196
- .string()
197
- .optional()
198
- .describe('New preview / social image URL for the document.'),
199
- hidden: z
200
- .boolean()
201
- .optional()
202
- .describe('When true, the document is hidden from navigation.'),
203
- ...docSpaceIdArg,
204
- },
124
+ updateDocSchema,
205
125
  async (args) => callWriteApi({ tool: 'update-doc', ...args })
206
126
  )
207
127
 
208
128
  server.tool(
209
129
  'delete_doc',
210
130
  'Permanently delete an Archbee document. This is destructive and cannot be undone: the document is removed together with every file and image uploaded to it, and any documents nested underneath it are deleted as well. Ask the user to confirm before calling this tool.',
211
- {
212
- docId: z.string().describe('ID of the document to delete.'),
213
- recursive: z
214
- .boolean()
215
- .optional()
216
- .describe(
217
- 'Required (set to true) to delete a document that has nested child documents, which deletes those children too. When the document has children and this is not set, the call is rejected and the response lists the child documents that would be affected.'
218
- ),
219
- ...docSpaceIdArg,
220
- },
131
+ deleteDocSchema,
221
132
  async (args) => callWriteApi({ tool: 'delete-doc', ...args })
222
133
  )
223
134
 
224
135
  server.tool(
225
136
  'create_doc_space',
226
137
  'Create a new doc space (documentation space) in the current Archbee team.',
227
- {
228
- name: z.string().describe('Name of the new doc space.'),
229
- isReviewSystemEnabled: z
230
- .boolean()
231
- .optional()
232
- .describe('Enable the review/approval workflow for the space.'),
233
- isBranchingSystemEnabled: z
234
- .boolean()
235
- .optional()
236
- .describe('Enable the branching (git-style) workflow for the space.'),
237
- docSpaceGroupId: z
238
- .string()
239
- .optional()
240
- .describe('ID of the collection/group to place the new space in.'),
241
- },
138
+ createDocSpaceSchema,
242
139
  async (args) => callWriteApi({ tool: 'create-doc-space', ...args })
243
140
  )
244
141
 
245
- // Mirrors PublicAPIUpdateDocSpaceRequestSchema in @archbee/data-access, which
246
- // this standalone package cannot import. The API re-validates with the real
247
- // schema, so this only has to describe the shape well enough for the model;
248
- // publicAccessControlPart passes unknown keys through so newer access-control
249
- // fields keep working without a release here.
250
- const emailListSchema = z.array(z.object({ email: z.string() }))
251
-
252
- const publicAccessControlPartSchema = z
253
- .object({
254
- publicProtectionTypes: z
255
- .array(
256
- z.enum([
257
- 'None',
258
- 'Password',
259
- 'Guest accounts',
260
- 'Private Accounts',
261
- 'Private Link',
262
- 'Magic Link',
263
- 'JWT',
264
- 'SAML',
265
- 'OIDC',
266
- ])
267
- )
268
- .optional(),
269
- publicPassword: z.string().optional(),
270
- publicGuestAccounts: z
271
- .array(z.object({ email: z.string(), password: z.string() }))
272
- .optional(),
273
- publicMagicLinkAccounts: emailListSchema.optional(),
274
- publicPrivateAccounts: emailListSchema.optional(),
275
- jwtValidationType: z.string().optional(),
276
- jwtKeyUrl: z.string().optional(),
277
- jwtSecret: z.string().optional(),
278
- jwtRedirectURL: z.string().optional(),
279
- samlMetadata: z.string().optional(),
280
- samlEntityId: z.string().optional(),
281
- conditionalRuleId: z.string().optional(),
282
- })
283
- .passthrough()
284
-
285
142
  server.tool(
286
143
  'update_doc_space',
287
- 'Update an Archbee doc space: rename it, or change its hostname, space links or public access control. Only the provided parts are changed, and at least one must be provided. The response echoes the space name, and get_all_docs / get_doc report it too, so a rename can be verified.',
288
- {
289
- name: z
290
- .string()
291
- .optional()
292
- .describe('New display name for the space (renames it).'),
293
- hostnamePart: z
294
- .object({ hostname: z.string(), hostnamePath: z.string() })
295
- .optional()
296
- .describe('Custom hostname configuration for the space.'),
297
- spaceLinks: z
298
- .array(z.object({ label: z.string(), docSpaceId: z.string() }))
299
- .optional()
300
- .describe(
301
- 'Links to other spaces. The list should start with the current space.'
302
- ),
303
- publicAccessControlPart: publicAccessControlPartSchema
304
- .optional()
305
- .describe('Public access control and authentication configuration.'),
306
- ...docSpaceIdArg,
307
- },
144
+ 'Update an Archbee doc space: rename it, or change its icon, hostname, space links or public access control. Only the provided parts are changed, and at least one must be provided. The response echoes the space name and icon, and get_all_docs / get_doc report the name too, so a rename can be verified.',
145
+ updateDocSpaceSchema,
308
146
  async (args) => callWriteApi({ tool: 'update-doc-space', ...args })
309
147
  )
310
148
 
311
149
  server.tool(
312
150
  'delete_doc_space',
313
151
  'Permanently delete an Archbee doc space together with every document inside it. This is destructive and cannot be undone. With a space API key the space deleted is the one SPACE_ID points at, so that key dies with it and no further tool call will work; with a team key it is the space named by docSpaceId. Ask the user to confirm before calling this tool.',
314
- { ...docSpaceIdArg },
152
+ deleteDocSpaceSchema,
315
153
  async (args) => callWriteApi({ tool: 'delete-doc-space', ...args })
316
154
  )
317
155
 
318
156
  server.tool(
319
157
  'create_space_group',
320
158
  'Create a new space group (collection of doc spaces) in the current Archbee team. Requires a team admin.',
321
- {
322
- name: z.string().describe('Name of the new space group.'),
323
- isAiEnabled: z
324
- .boolean()
325
- .optional()
326
- .describe('Enable AI features for the space group.'),
327
- isReviewSystemEnabled: z
328
- .boolean()
329
- .optional()
330
- .describe('Enable the review/approval workflow for the space group.'),
331
- isBranchingSystemEnabled: z
332
- .boolean()
333
- .optional()
334
- .describe(
335
- 'Enable the branching (git-style) workflow for the space group.'
336
- ),
337
- },
159
+ createSpaceGroupSchema,
338
160
  async (args) => callWriteApi({ tool: 'create-space-group', ...args })
339
161
  )
340
162
 
341
163
  server.tool(
342
164
  'delete_space_group',
343
165
  'Delete a space group (collection of doc spaces) from the current Archbee team. Requires a team admin. The group must already be empty: move or delete every doc space it still contains first, otherwise the call is rejected.',
344
- {
345
- docSpaceGroupId: z.string().describe('ID of the space group to delete.'),
346
- },
166
+ deleteSpaceGroupSchema,
347
167
  async (args) => callWriteApi({ tool: 'delete-space-group', ...args })
348
168
  )
349
169
 
350
170
  server.tool(
351
171
  'create_category',
352
172
  'Create a category (a folder in the space navigation) in an Archbee doc space. A category holds documents but has no content of its own. To put a document inside it, pass the returned categoryId as `parentDocId` on create_doc or update_doc.',
353
- {
354
- categoryName: z.string().describe('Name of the category to create.'),
355
- parentDocId: z
356
- .string()
357
- .optional()
358
- .describe(
359
- 'ID of the document or category to nest this category under. Omit to create it at the top level of the space.'
360
- ),
361
- ...docSpaceIdArg,
362
- },
173
+ createCategorySchema,
363
174
  async (args) => callWriteApi({ tool: 'create-category', ...args })
364
175
  )
365
176
 
366
177
  server.tool(
367
178
  'delete_category',
368
179
  'Delete a category from an Archbee doc space. The category must already be empty: move or delete the documents inside it first, otherwise the call is rejected. Deleting a category never deletes documents.',
369
- {
370
- categoryId: z.string().describe('ID of the category to delete.'),
371
- ...docSpaceIdArg,
372
- },
180
+ deleteCategorySchema,
373
181
  async (args) => callWriteApi({ tool: 'delete-category', ...args })
374
182
  )
375
183
 
184
+ server.tool(
185
+ 'list_templates',
186
+ 'List the document templates saved in the Archbee organization (Reusables → Templates), each with its id, name and content as markdown. Use apply_template to create a document from one.',
187
+ listTemplatesSchema,
188
+ async () => callMcpApi({ tool: 'list-templates' })
189
+ )
190
+
191
+ server.tool(
192
+ 'create_template',
193
+ 'Save a new document template in the Archbee organization, from Markdown or MDX content. A template is a starting point for new documents; it is not itself a published page. If a template with the same name already exists, the existing one is returned (alreadyExists: true) instead of a duplicate being created — its content is kept, so a different body needs a new name.',
194
+ createTemplateSchema,
195
+ async (args) => callWriteApi({ tool: 'create-template', ...args })
196
+ )
197
+
198
+ server.tool(
199
+ 'delete_template',
200
+ "Delete a document template from the Archbee organization. The template is moved to the organization's Archives space (Archived Docs in the app), where a person can restore it. Ask the user to confirm before calling this tool.",
201
+ deleteTemplateSchema,
202
+ async (args) => callWriteApi({ tool: 'delete-template', ...args })
203
+ )
204
+
205
+ server.tool(
206
+ 'apply_template',
207
+ 'Create a new Archbee document from a saved template. The template content is copied verbatim, including blocks markdown cannot express (API endpoints, diagrams). The template itself is unchanged.',
208
+ applyTemplateSchema,
209
+ async (args) => callWriteApi({ tool: 'apply-template', ...args })
210
+ )
211
+
212
+ server.tool(
213
+ 'list_content_snippets',
214
+ 'List the reusable content snippets saved in the Archbee organization (Reusables → Content snippets), each with its id, name and content as markdown. A snippet is a block of content embedded into many documents and edited in one place.',
215
+ listContentSnippetsSchema,
216
+ async () => callMcpApi({ tool: 'list-content-snippets' })
217
+ )
218
+
219
+ server.tool(
220
+ 'create_content_snippet',
221
+ 'Create a reusable content snippet in the Archbee organization, from Markdown or MDX content. Requires a Scaling or Enterprise subscription. If a snippet with the same name already exists, the existing one is returned (alreadyExists: true) instead of a duplicate being created — its content is kept, use update_content_snippet to change it.',
222
+ createContentSnippetSchema,
223
+ async (args) => callWriteApi({ tool: 'create-content-snippet', ...args })
224
+ )
225
+
226
+ server.tool(
227
+ 'update_content_snippet',
228
+ 'Update a reusable content snippet: rename it, replace its content, or both. The change reaches every document the snippet is embedded in. At least one of name or content must be provided.',
229
+ updateContentSnippetSchema,
230
+ async (args) => callWriteApi({ tool: 'update-content-snippet', ...args })
231
+ )
232
+
233
+ server.tool(
234
+ 'delete_content_snippet',
235
+ 'Permanently delete a reusable content snippet from the Archbee organization. Documents that embed it lose that content. This cannot be undone — ask the user to confirm before calling this tool.',
236
+ deleteContentSnippetSchema,
237
+ async (args) => callWriteApi({ tool: 'delete-content-snippet', ...args })
238
+ )
239
+
240
+ server.tool(
241
+ 'list_variables',
242
+ 'List the content variables and glossary terms saved in the Archbee organization (Reusables → Variables / Glossary), each with its id, name, value and per-space or per-language overrides.',
243
+ listVariablesSchema,
244
+ async (args) => callMcpApi({ tool: 'list-variables', ...args })
245
+ )
246
+
247
+ server.tool(
248
+ 'create_variable',
249
+ 'Create a content variable (or a glossary term) in the Archbee organization. A variable is referenced by name inside document content and resolved at render time. For a glossary term, readers see variableContent as the term and description as its definition (required) — the name is only the reference key. Requires a Scaling or Enterprise subscription.',
250
+ createVariableSchema,
251
+ async (args) => callWriteApi({ tool: 'create-variable', ...args })
252
+ )
253
+
254
+ server.tool(
255
+ 'update_variable',
256
+ 'Update a content variable or glossary term. Only the provided fields change, and at least one must be provided. The new value reaches every document that references it.',
257
+ updateVariableSchema,
258
+ async (args) => callWriteApi({ tool: 'update-variable', ...args })
259
+ )
260
+
261
+ server.tool(
262
+ 'delete_variable',
263
+ 'Permanently delete a content variable or glossary term from the Archbee organization. Documents that reference it by name stop resolving. Ask the user to confirm before calling this tool.',
264
+ deleteVariableSchema,
265
+ async (args) => callWriteApi({ tool: 'delete-variable', ...args })
266
+ )
267
+
376
268
  // Origin of the Archbee API the key belongs to, same variable the CLI takes.
377
269
  // app.archbee.com/api is being phased out, so the default is api.archbee.com.
378
270
  const apiMcpUrl = (): string | null => {