@archbee/mcp 2.1.0 → 2.2.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,33 @@ 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
+ deleteVariableSchema,
22
+ getAllDocsSchema,
23
+ getDocSchema,
24
+ listContentSnippetsSchema,
25
+ listTemplatesSchema,
26
+ listVariablesSchema,
27
+ searchQuerySchema,
28
+ searchTitleSchema,
29
+ updateContentSnippetSchema,
30
+ updateDocSchema,
31
+ updateDocSpaceSchema,
32
+ updateVariableSchema,
33
+ } from './tool-schemas'
8
34
 
9
35
  interface McpApiParams {
10
36
  tool: string
@@ -19,8 +45,15 @@ interface McpApiParams {
19
45
  description?: string
20
46
  previewImgURL?: string
21
47
  hidden?: boolean
48
+ icon?: string
22
49
  recursive?: boolean
23
50
  name?: string
51
+ templateId?: string
52
+ snippetId?: string
53
+ variableId?: string
54
+ variableType?: 'variable' | 'glossary'
55
+ variableContent?: string
56
+ spaceTargetMap?: Record<string, string>
24
57
  categoryName?: string
25
58
  categoryId?: string
26
59
  docSpaceGroupId?: string
@@ -39,340 +72,191 @@ const TEAM_API_KEY_PREFIX = 'abteam_'
39
72
  const usesTeamApiKey = (): boolean =>
40
73
  (process.env.API_KEY || '').startsWith(TEAM_API_KEY_PREFIX)
41
74
 
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
75
  // Create an MCP server
55
76
  const server = new McpServer({
56
77
  name: 'Archbee MCP',
57
- version: '2.1.0',
78
+ version: '2.2.0',
58
79
  })
59
80
 
60
81
  server.tool(
61
82
  'get_all_docs',
62
83
  '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
- }
84
+ getAllDocsSchema,
85
+ async (args) => callMcpApi({ tool: 'get-all-docs', ...args })
71
86
  )
72
87
 
73
88
  server.tool(
74
89
  'get_doc',
75
90
  '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
- }
91
+ getDocSchema,
92
+ async (args) => callMcpApi({ tool: 'get-doc', ...args })
92
93
  )
93
94
 
94
95
  server.tool(
95
96
  'search_query',
96
97
  '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
- }
98
+ searchQuerySchema,
99
+ async (args) => callMcpApi({ tool: 'search-query', ...args })
111
100
  )
112
101
 
113
102
  server.tool(
114
103
  'search_title',
115
104
  '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
- }
105
+ searchTitleSchema,
106
+ async (args) => callMcpApi({ tool: 'search-title', ...args })
128
107
  )
129
108
 
130
109
  // 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.
110
+ // team key it comes from the docSpaceId argument, which the team-level tools
111
+ // below do not take because they act on the team, not on a space.
133
112
 
134
113
  server.tool(
135
114
  'create_doc',
136
115
  '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
- },
116
+ createDocSchema,
167
117
  async (args) => callWriteApi({ tool: 'create-doc', ...args })
168
118
  )
169
119
 
170
120
  server.tool(
171
121
  'update_doc',
172
122
  '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
- },
123
+ updateDocSchema,
205
124
  async (args) => callWriteApi({ tool: 'update-doc', ...args })
206
125
  )
207
126
 
208
127
  server.tool(
209
128
  'delete_doc',
210
129
  '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
- },
130
+ deleteDocSchema,
221
131
  async (args) => callWriteApi({ tool: 'delete-doc', ...args })
222
132
  )
223
133
 
224
134
  server.tool(
225
135
  'create_doc_space',
226
136
  '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
- },
137
+ createDocSpaceSchema,
242
138
  async (args) => callWriteApi({ tool: 'create-doc-space', ...args })
243
139
  )
244
140
 
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
141
  server.tool(
286
142
  '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
- },
143
+ '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.',
144
+ updateDocSpaceSchema,
308
145
  async (args) => callWriteApi({ tool: 'update-doc-space', ...args })
309
146
  )
310
147
 
311
148
  server.tool(
312
149
  'delete_doc_space',
313
150
  '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 },
151
+ deleteDocSpaceSchema,
315
152
  async (args) => callWriteApi({ tool: 'delete-doc-space', ...args })
316
153
  )
317
154
 
318
155
  server.tool(
319
156
  'create_space_group',
320
157
  '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
- },
158
+ createSpaceGroupSchema,
338
159
  async (args) => callWriteApi({ tool: 'create-space-group', ...args })
339
160
  )
340
161
 
341
162
  server.tool(
342
163
  'delete_space_group',
343
164
  '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
- },
165
+ deleteSpaceGroupSchema,
347
166
  async (args) => callWriteApi({ tool: 'delete-space-group', ...args })
348
167
  )
349
168
 
350
169
  server.tool(
351
170
  'create_category',
352
171
  '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
- },
172
+ createCategorySchema,
363
173
  async (args) => callWriteApi({ tool: 'create-category', ...args })
364
174
  )
365
175
 
366
176
  server.tool(
367
177
  'delete_category',
368
178
  '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
- },
179
+ deleteCategorySchema,
373
180
  async (args) => callWriteApi({ tool: 'delete-category', ...args })
374
181
  )
375
182
 
183
+ server.tool(
184
+ 'list_templates',
185
+ '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.',
186
+ listTemplatesSchema,
187
+ async () => callMcpApi({ tool: 'list-templates' })
188
+ )
189
+
190
+ server.tool(
191
+ 'create_template',
192
+ '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.',
193
+ createTemplateSchema,
194
+ async (args) => callWriteApi({ tool: 'create-template', ...args })
195
+ )
196
+
197
+ server.tool(
198
+ 'apply_template',
199
+ '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.',
200
+ applyTemplateSchema,
201
+ async (args) => callWriteApi({ tool: 'apply-template', ...args })
202
+ )
203
+
204
+ server.tool(
205
+ 'list_content_snippets',
206
+ '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.',
207
+ listContentSnippetsSchema,
208
+ async () => callMcpApi({ tool: 'list-content-snippets' })
209
+ )
210
+
211
+ server.tool(
212
+ 'create_content_snippet',
213
+ 'Create a reusable content snippet in the Archbee organization, from Markdown or MDX content. Requires a Scaling or Enterprise subscription.',
214
+ createContentSnippetSchema,
215
+ async (args) => callWriteApi({ tool: 'create-content-snippet', ...args })
216
+ )
217
+
218
+ server.tool(
219
+ 'update_content_snippet',
220
+ '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.',
221
+ updateContentSnippetSchema,
222
+ async (args) => callWriteApi({ tool: 'update-content-snippet', ...args })
223
+ )
224
+
225
+ server.tool(
226
+ 'delete_content_snippet',
227
+ '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.',
228
+ deleteContentSnippetSchema,
229
+ async (args) => callWriteApi({ tool: 'delete-content-snippet', ...args })
230
+ )
231
+
232
+ server.tool(
233
+ 'list_variables',
234
+ '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.',
235
+ listVariablesSchema,
236
+ async (args) => callMcpApi({ tool: 'list-variables', ...args })
237
+ )
238
+
239
+ server.tool(
240
+ 'create_variable',
241
+ '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. Requires a Scaling or Enterprise subscription.',
242
+ createVariableSchema,
243
+ async (args) => callWriteApi({ tool: 'create-variable', ...args })
244
+ )
245
+
246
+ server.tool(
247
+ 'update_variable',
248
+ '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.',
249
+ updateVariableSchema,
250
+ async (args) => callWriteApi({ tool: 'update-variable', ...args })
251
+ )
252
+
253
+ server.tool(
254
+ 'delete_variable',
255
+ '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.',
256
+ deleteVariableSchema,
257
+ async (args) => callWriteApi({ tool: 'delete-variable', ...args })
258
+ )
259
+
376
260
  // Origin of the Archbee API the key belongs to, same variable the CLI takes.
377
261
  // app.archbee.com/api is being phased out, so the default is api.archbee.com.
378
262
  const apiMcpUrl = (): string | null => {