@archbee/mcp 1.1.23 → 2.0.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/README.md CHANGED
@@ -1,28 +1,72 @@
1
1
  # Archbee MCP Server
2
2
 
3
- This is a Model Context Protocol (MCP) server for interacting with the [Archbee API](https://docs.archbee.com/get-document). This server provides tools to read, search and list Archbee documents from your space using Large Language Models.
3
+ A Model Context Protocol (MCP) server for the [Archbee API](https://docs.archbee.com/get-document). It lets an LLM client read, search, create, update and delete the documentation in your Archbee space.
4
+
5
+ Every tool acts on the space configured below, so `docSpaceId` never has to be passed in.
4
6
 
5
7
  ### Tools
6
8
 
7
- 1. get-doc
9
+ Read:
10
+
11
+ 1. `get_doc`
8
12
  - Gets content of a document
9
13
  - Input:
10
- - id (string): Archbee id
11
- - Returns: Content as markdown
12
- 2. get-all-docs
13
- - Gets content of all documents in space
14
- - Returns: documents, as DocResponse\[]
15
- 3. search-query
16
- - Search docs by input query
17
- - if query is empty, return all docs
14
+ - `docId` (string): Archbee document id
15
+ - Returns: content as markdown
16
+ 2. `get_all_docs`
17
+ - Gets content of all documents in the space
18
+ - Returns: documents, as `DocResponse[]`
19
+ 3. `search_query`
20
+ - Searches docs by content; an empty query returns all docs
18
21
  - Input:
19
- - query (string): text as part of documents to search
20
- - Returns: documents containing query, as DocResponse\[]
21
- 4. search-title
22
- - Search docs by input title
22
+ - `query` (string): text to look for inside documents
23
+ - Returns: documents containing the query, as `DocResponse[]`
24
+ 4. `search_title`
25
+ - Searches docs by title
23
26
  - Input:
24
- - query (string): text as part of titles to search
25
- - Returns: documents with title containing query, as DocResponse\[]
27
+ - `query` (string): text to look for in titles
28
+ - Returns: documents with a matching title, as `DocResponse[]`
29
+
30
+ Write — these need the space id configuration below:
31
+
32
+ 5. `create_doc`
33
+ - Creates a document from Markdown or MDX content
34
+ - Input:
35
+ - `content` (string): body as Markdown or MDX text
36
+ - `format` (`markdown` | `mdx`, optional): use `mdx` for JSX-style components such as `<hint>` or `<Tabs>`; directive-style (`:::hint{type="info"}`) works in both. Defaults to `markdown`
37
+ - also optional: `title`, `parentDocId`, `slug`, `description`, `previewImgURL`, `hidden`
38
+ 6. `update_doc`
39
+ - Updates a document; only the fields you send are changed
40
+ - Input:
41
+ - `docId` (string): document to update
42
+ - optional: `content`, `format`, `title`, `parentDocId`, `slug`, `description`, `previewImgURL`, `hidden`
43
+ 7. `delete_doc`
44
+ - Permanently deletes a document, its uploaded files and images. Cannot be undone
45
+ - Input:
46
+ - `docId` (string): document to delete
47
+ - `recursive` (boolean, optional): required to delete a document that has nested children, which deletes them too
48
+ 8. `create_doc_space`
49
+ - Creates a doc space in the team
50
+ - Input:
51
+ - `name` (string): name of the new space
52
+ - optional: `isReviewSystemEnabled`, `isBranchingSystemEnabled`, `docSpaceGroupId`
53
+ 9. `update_doc_space`
54
+ - Updates settings of the configured space; only the parts you send are changed
55
+ - Input, all optional:
56
+ - `hostnamePart` (`{ hostname, hostnamePath }`): custom hostname configuration
57
+ - `spaceLinks` (`{ label, docSpaceId }[]`): links to other spaces; the list should start with the current space
58
+ - `publicAccessControlPart`: public access control and authentication configuration
59
+ 10. `delete_doc_space`
60
+ - Permanently deletes the configured space and every document in it. Cannot be undone, and the `API_KEY` dies with it
61
+ 11. `create_space_group`
62
+ - Creates a space group. Requires a team admin
63
+ - Input:
64
+ - `name` (string): name of the new group
65
+ - optional: `isAiEnabled`, `isReviewSystemEnabled`, `isBranchingSystemEnabled`
66
+ 12. `delete_space_group`
67
+ - Deletes an empty space group. Requires a team admin
68
+ - Input:
69
+ - `docSpaceGroupId` (string): group to delete
26
70
 
27
71
  ## Setup
28
72
 
@@ -30,6 +74,8 @@ Add this server to your `claude_desktop_config.json` or `.cursor/mcp.json`
30
74
 
31
75
  ### Environment Variables - base link
32
76
 
77
+ Read-only. Use this for a public space.
78
+
33
79
  - `API_BASE`: Link to your Archbee portal
34
80
 
35
81
  Space must be public, with no access control (no password, jwt etc)
@@ -39,8 +85,8 @@ Just copy-paste the link to the archbee space.
39
85
  {
40
86
  "mcpServers": {
41
87
  "archbee": {
42
- "command": "npx",
43
- "args": ["-y", "@archbee/mcp"],
88
+ "command": "pnpm",
89
+ "args": ["dlx", "@archbee/mcp"],
44
90
  "env": {
45
91
  "API_BASE": "https://your-docs.io/"
46
92
  }
@@ -51,20 +97,23 @@ Just copy-paste the link to the archbee space.
51
97
 
52
98
  ### Environment Variables - space id
53
99
 
54
- Alternatively, you can set space id, which can also be used for internal spaces.
100
+ Required for the write tools, and also works for reading internal spaces.
55
101
 
56
102
  You can get an API token from Space Settings in Archbee app.
57
- Your space must be published with that apiKey.
58
103
 
59
- - `SPACE_ID`: Space id starting with `PUBLISHED-`
104
+ - `SPACE_ID`: Space id, taken from the space URL in the app
60
105
  - `API_KEY`: Your Archbee API token for that Space
61
106
 
107
+ Use the live space id here. A `PUBLISHED-` or `PREVIEW-` snapshot id reads fine, but the API refuses every write through a snapshot credential.
108
+
109
+ An API key belongs to one space, so this server writes to that space only. To give an assistant write access across every space in the team, connect it to the hosted Archbee MCP endpoint instead and authorize it with your Archbee account — that connector is team-scoped and takes a `docSpaceId` per call.
110
+
62
111
  ```json
63
112
  {
64
113
  "mcpServers": {
65
114
  "archbee": {
66
- "command": "npx",
67
- "args": ["-y", "@archbee/mcp"],
115
+ "command": "pnpm",
116
+ "args": ["dlx", "@archbee/mcp"],
68
117
  "env": {
69
118
  "SPACE_ID": "<id-of-space>",
70
119
  "API_KEY": "<api-key-of-space>"
package/dist/index.js CHANGED
@@ -6,8 +6,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  const mcp_js_1 = require("@modelcontextprotocol/sdk/server/mcp.js");
8
8
  const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
9
- const zod_1 = require("zod");
10
9
  const axios_1 = __importDefault(require("axios"));
10
+ const zod_1 = require("zod");
11
+ const MDX_FORMAT_DESCRIPTION = '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.';
11
12
  // Create an MCP server
12
13
  const server = new mcp_js_1.McpServer({
13
14
  name: 'Archbee MCP',
@@ -40,6 +41,154 @@ server.tool('search_title', { query: zod_1.z.string() }, async ({ query }) => {
40
41
  };
41
42
  return callMcpApi(params);
42
43
  });
44
+ // Write tools. The target space always comes from SPACE_ID — callMcpApi puts it
45
+ // on every request — so no tool takes a docSpaceId argument.
46
+ server.tool('create_doc', 'Create a new document in the Archbee doc space from Markdown or MDX content.', {
47
+ content: zod_1.z
48
+ .string()
49
+ .describe('Body of the document to create, as Markdown or MDX text. JSON document content is not accepted.'),
50
+ format: zod_1.z
51
+ .enum(['markdown', 'mdx'])
52
+ .optional()
53
+ .describe(MDX_FORMAT_DESCRIPTION),
54
+ title: zod_1.z.string().optional().describe('Title of the document.'),
55
+ parentDocId: zod_1.z
56
+ .string()
57
+ .optional()
58
+ .describe('ID of the parent document to nest this document under.'),
59
+ slug: zod_1.z.string().optional().describe('URL slug for the document.'),
60
+ description: zod_1.z
61
+ .string()
62
+ .optional()
63
+ .describe('Short description / summary of the document.'),
64
+ previewImgURL: zod_1.z
65
+ .string()
66
+ .optional()
67
+ .describe('URL of the preview / social image for the document.'),
68
+ hidden: zod_1.z
69
+ .boolean()
70
+ .optional()
71
+ .describe('When true, the document is hidden from navigation.'),
72
+ }, async (args) => callWriteApi({ tool: 'create-doc', ...args }));
73
+ server.tool('update_doc', 'Update an existing Archbee document. Only the provided fields are changed.', {
74
+ docId: zod_1.z.string().describe('ID of the document to update.'),
75
+ content: zod_1.z
76
+ .string()
77
+ .optional()
78
+ .describe('New body for the document, as Markdown or MDX text. JSON document content is not accepted.'),
79
+ format: zod_1.z
80
+ .enum(['markdown', 'mdx'])
81
+ .optional()
82
+ .describe(MDX_FORMAT_DESCRIPTION),
83
+ title: zod_1.z.string().optional().describe('New title of the document.'),
84
+ parentDocId: zod_1.z
85
+ .string()
86
+ .optional()
87
+ .describe('ID of the parent document to move this document under.'),
88
+ slug: zod_1.z.string().optional().describe('New URL slug for the document.'),
89
+ description: zod_1.z
90
+ .string()
91
+ .optional()
92
+ .describe('New short description / summary of the document.'),
93
+ previewImgURL: zod_1.z
94
+ .string()
95
+ .optional()
96
+ .describe('New preview / social image URL for the document.'),
97
+ hidden: zod_1.z
98
+ .boolean()
99
+ .optional()
100
+ .describe('When true, the document is hidden from navigation.'),
101
+ }, async (args) => callWriteApi({ tool: 'update-doc', ...args }));
102
+ server.tool('delete_doc', '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.', {
103
+ docId: zod_1.z.string().describe('ID of the document to delete.'),
104
+ recursive: zod_1.z
105
+ .boolean()
106
+ .optional()
107
+ .describe('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.'),
108
+ }, async (args) => callWriteApi({ tool: 'delete-doc', ...args }));
109
+ server.tool('create_doc_space', 'Create a new doc space (documentation space) in the current Archbee team.', {
110
+ name: zod_1.z.string().describe('Name of the new doc space.'),
111
+ isReviewSystemEnabled: zod_1.z
112
+ .boolean()
113
+ .optional()
114
+ .describe('Enable the review/approval workflow for the space.'),
115
+ isBranchingSystemEnabled: zod_1.z
116
+ .boolean()
117
+ .optional()
118
+ .describe('Enable the branching (git-style) workflow for the space.'),
119
+ docSpaceGroupId: zod_1.z
120
+ .string()
121
+ .optional()
122
+ .describe('ID of the collection/group to place the new space in.'),
123
+ }, async (args) => callWriteApi({ tool: 'create-doc-space', ...args }));
124
+ // Mirrors PublicAPIUpdateDocSpaceRequestSchema in @archbee/data-access, which
125
+ // this standalone package cannot import. The API re-validates with the real
126
+ // schema, so this only has to describe the shape well enough for the model;
127
+ // publicAccessControlPart passes unknown keys through so newer access-control
128
+ // fields keep working without a release here.
129
+ const emailListSchema = zod_1.z.array(zod_1.z.object({ email: zod_1.z.string() }));
130
+ const publicAccessControlPartSchema = zod_1.z
131
+ .object({
132
+ publicProtectionTypes: zod_1.z
133
+ .array(zod_1.z.enum([
134
+ 'None',
135
+ 'Password',
136
+ 'Guest accounts',
137
+ 'Private Accounts',
138
+ 'Private Link',
139
+ 'Magic Link',
140
+ 'JWT',
141
+ 'SAML',
142
+ 'OIDC',
143
+ ]))
144
+ .optional(),
145
+ publicPassword: zod_1.z.string().optional(),
146
+ publicGuestAccounts: zod_1.z
147
+ .array(zod_1.z.object({ email: zod_1.z.string(), password: zod_1.z.string() }))
148
+ .optional(),
149
+ publicMagicLinkAccounts: emailListSchema.optional(),
150
+ publicPrivateAccounts: emailListSchema.optional(),
151
+ jwtValidationType: zod_1.z.string().optional(),
152
+ jwtKeyUrl: zod_1.z.string().optional(),
153
+ jwtSecret: zod_1.z.string().optional(),
154
+ jwtRedirectURL: zod_1.z.string().optional(),
155
+ samlMetadata: zod_1.z.string().optional(),
156
+ samlEntityId: zod_1.z.string().optional(),
157
+ conditionalRuleId: zod_1.z.string().optional(),
158
+ })
159
+ .passthrough();
160
+ server.tool('update_doc_space', 'Update settings of the Archbee doc space (hostname, space links, public access control). Only the provided parts are changed.', {
161
+ hostnamePart: zod_1.z
162
+ .object({ hostname: zod_1.z.string(), hostnamePath: zod_1.z.string() })
163
+ .optional()
164
+ .describe('Custom hostname configuration for the space.'),
165
+ spaceLinks: zod_1.z
166
+ .array(zod_1.z.object({ label: zod_1.z.string(), docSpaceId: zod_1.z.string() }))
167
+ .optional()
168
+ .describe('Links to other spaces. The list should start with the current space.'),
169
+ publicAccessControlPart: publicAccessControlPartSchema
170
+ .optional()
171
+ .describe('Public access control and authentication configuration.'),
172
+ }, async (args) => callWriteApi({ tool: 'update-doc-space', ...args }));
173
+ server.tool('delete_doc_space', 'Permanently delete the configured Archbee doc space together with every document inside it. This is destructive and cannot be undone. The space that gets deleted is the one SPACE_ID points at, so API_KEY is destroyed along with it and no further tool call will work. Ask the user to confirm before calling this tool.', {}, async () => callWriteApi({ tool: 'delete-doc-space' }));
174
+ server.tool('create_space_group', 'Create a new space group (collection of doc spaces) in the current Archbee team. Requires a team admin.', {
175
+ name: zod_1.z.string().describe('Name of the new space group.'),
176
+ isAiEnabled: zod_1.z
177
+ .boolean()
178
+ .optional()
179
+ .describe('Enable AI features for the space group.'),
180
+ isReviewSystemEnabled: zod_1.z
181
+ .boolean()
182
+ .optional()
183
+ .describe('Enable the review/approval workflow for the space group.'),
184
+ isBranchingSystemEnabled: zod_1.z
185
+ .boolean()
186
+ .optional()
187
+ .describe('Enable the branching (git-style) workflow for the space group.'),
188
+ }, async (args) => callWriteApi({ tool: 'create-space-group', ...args }));
189
+ server.tool('delete_space_group', '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.', {
190
+ docSpaceGroupId: zod_1.z.string().describe('ID of the space group to delete.'),
191
+ }, async (args) => callWriteApi({ tool: 'delete-space-group', ...args }));
43
192
  const processUrl = (urlInput) => {
44
193
  try {
45
194
  const url = new URL(urlInput);
@@ -48,7 +197,7 @@ const processUrl = (urlInput) => {
48
197
  : url.pathname + '/mcp';
49
198
  return url.toString();
50
199
  }
51
- catch (error) {
200
+ catch {
52
201
  return null;
53
202
  }
54
203
  };
@@ -58,10 +207,14 @@ const callMcpApi = async (params) => {
58
207
  if (!urlInput && !docSpaceIdInput) {
59
208
  return {
60
209
  content: [{ type: 'text', text: 'API base URL or docSpaceId not set.' }],
210
+ isError: true,
61
211
  };
62
212
  }
63
213
  if (!process.env.API_KEY && !urlInput) {
64
- return { content: [{ type: 'text', text: 'API key not set.' }] };
214
+ return {
215
+ content: [{ type: 'text', text: 'API key not set.' }],
216
+ isError: true,
217
+ };
65
218
  }
66
219
  const urlMcp = urlInput
67
220
  ? processUrl(urlInput)
@@ -69,10 +222,11 @@ const callMcpApi = async (params) => {
69
222
  if (urlMcp === null) {
70
223
  return {
71
224
  content: [{ type: 'text', text: 'Invalid API base URL format.' }],
225
+ isError: true,
72
226
  };
73
227
  }
74
228
  try {
75
- let dataText = '';
229
+ let dataText;
76
230
  if (docSpaceIdInput) {
77
231
  params.docSpaceId = docSpaceIdInput;
78
232
  const rawAuth = `${docSpaceIdInput}~${process.env.API_KEY}`;
@@ -82,12 +236,14 @@ const callMcpApi = async (params) => {
82
236
  Authorization: `Bearer ${base64Auth}`,
83
237
  'Content-Type': 'application/json',
84
238
  },
239
+ timeout: 30000,
85
240
  });
86
241
  dataText = JSON.stringify(response.data);
87
242
  }
88
243
  else {
89
244
  const response = await axios_1.default.get(urlMcp, {
90
245
  params,
246
+ timeout: 30000,
91
247
  });
92
248
  dataText = JSON.stringify(response.data);
93
249
  }
@@ -96,20 +252,99 @@ const callMcpApi = async (params) => {
96
252
  };
97
253
  }
98
254
  catch (error) {
255
+ const errorMessage = formatError(error);
256
+ console.error(`MCP API error: ${errorMessage}`);
257
+ return {
258
+ content: [{ type: 'text', text: errorMessage }],
259
+ isError: true,
260
+ };
261
+ }
262
+ };
263
+ // Writes only go through the SPACE_ID + API_KEY path: the API_BASE mode is an
264
+ // unauthenticated GET against a public portal, and the API refuses every write
265
+ // made with a PUBLISHED-/PREVIEW- snapshot credential. Both cases fail here with
266
+ // an explanation rather than as an opaque rejection from the server.
267
+ const callWriteApi = async (params) => {
268
+ const docSpaceIdInput = process.env.SPACE_ID || '';
269
+ if (!docSpaceIdInput || !process.env.API_KEY) {
99
270
  return {
100
271
  content: [
101
272
  {
102
273
  type: 'text',
103
- text: `Error in mcp: ${error} ${urlMcp} ${params}`,
274
+ text: 'Write tools need both SPACE_ID and API_KEY to be set. The API_BASE configuration is read-only.',
104
275
  },
105
276
  ],
277
+ isError: true,
106
278
  };
107
279
  }
280
+ if (docSpaceIdInput.startsWith('PUBLISHED-') ||
281
+ docSpaceIdInput.startsWith('PREVIEW-')) {
282
+ return {
283
+ content: [
284
+ {
285
+ type: 'text',
286
+ text: 'SPACE_ID points at a published/preview snapshot, which cannot be written to. Set it to the live space id from the space URL in the Archbee app.',
287
+ },
288
+ ],
289
+ isError: true,
290
+ };
291
+ }
292
+ return callMcpApi(params);
293
+ };
294
+ const formatError = (error) => {
295
+ if (axios_1.default.isAxiosError(error)) {
296
+ if (error.code === 'ECONNABORTED') {
297
+ return 'Request timeout - the server took too long to respond.';
298
+ }
299
+ if (error.code === 'ENOTFOUND' || error.code === 'ECONNREFUSED') {
300
+ return 'Connection failed - unable to reach the API server.';
301
+ }
302
+ if (error.response) {
303
+ const status = error.response.status;
304
+ if (status === 401 || status === 403) {
305
+ return 'Authentication failed - check your API key.';
306
+ }
307
+ if (status === 404) {
308
+ return 'Resource not found - check the document ID.';
309
+ }
310
+ if (status >= 500) {
311
+ return 'Server error - please try again later.';
312
+ }
313
+ return `API error (${status}): ${error.response.statusText}`;
314
+ }
315
+ return `Network error: ${error.message}`;
316
+ }
317
+ if (error instanceof Error) {
318
+ return error.message;
319
+ }
320
+ return 'An unexpected error occurred.';
108
321
  };
109
322
  const main = async () => {
110
- // Start receiving messages on stdin and sending messages on stdout
111
323
  const transport = new stdio_js_1.StdioServerTransport();
112
- await server.connect(transport);
324
+ // Handle graceful shutdown
325
+ const shutdown = async () => {
326
+ console.error('Shutting down MCP server...');
327
+ try {
328
+ await server.close();
329
+ }
330
+ catch {
331
+ // Ignore close errors during shutdown
332
+ }
333
+ process.exit(0);
334
+ };
335
+ process.on('SIGINT', shutdown);
336
+ process.on('SIGTERM', shutdown);
337
+ try {
338
+ await server.connect(transport);
339
+ console.error('Archbee MCP server started successfully');
340
+ }
341
+ catch (error) {
342
+ console.error('Failed to start MCP server:', error instanceof Error ? error.message : error);
343
+ process.exit(1);
344
+ }
113
345
  };
114
- main();
346
+ main().catch((error) => {
347
+ console.error('Fatal error:', error instanceof Error ? error.message : error);
348
+ process.exit(1);
349
+ });
115
350
  //# sourceMappingUR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CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CACX,6BAA6B,EAC7B,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAC/C,CAAA;QACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC;AACH,CAAC,CAAA;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAA;IAC7E,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,16 +1,22 @@
1
1
  {
2
2
  "name": "@archbee/mcp",
3
- "version": "1.1.23",
3
+ "version": "2.0.0",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
+ "files": [
7
+ "dist",
8
+ "src",
9
+ "README.md"
10
+ ],
6
11
  "bin": {
7
12
  "archbee-mcp": "./dist/index.js"
8
13
  },
9
14
  "scripts": {
10
15
  "compile": "rm -rf ./dist && tsc",
11
- "serve": "PORT=5001 npm run compile && PORT=5001 node ./dist/index.js",
16
+ "serve": "PORT=5001 pnpm run compile && PORT=5001 node ./dist/index.js",
12
17
  "start": "PORT=5001 node ./dist/index.js",
13
- "publish": "npm publish --access public"
18
+ "release:dry": "pnpm run compile && npm publish --access public --dry-run",
19
+ "release": "pnpm run compile && npm publish --access public"
14
20
  },
15
21
  "keywords": [
16
22
  "mcp",
@@ -24,8 +30,10 @@
24
30
  ],
25
31
  "dependencies": {
26
32
  "@modelcontextprotocol/sdk": "^1.12.0",
27
- "archbee-mcp": "^1.0.2",
28
33
  "axios": "^1.9.0",
29
34
  "zod": "^3.25.30"
35
+ },
36
+ "devDependencies": {
37
+ "@types/node": "24.13.3"
30
38
  }
31
39
  }
package/src/index.ts CHANGED
@@ -2,10 +2,36 @@
2
2
 
3
3
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'
4
4
  import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'
5
+ import { type CallToolResult } from '@modelcontextprotocol/sdk/types'
6
+ import axios from 'axios'
5
7
  import { z } from 'zod'
6
8
 
7
- import { CallToolResult } from '@modelcontextprotocol/sdk/types'
8
- import axios from 'axios'
9
+ interface McpApiParams {
10
+ tool: string
11
+ docId?: string
12
+ query?: string
13
+ docSpaceId?: string
14
+ content?: string
15
+ format?: 'markdown' | 'mdx'
16
+ title?: string
17
+ parentDocId?: string
18
+ slug?: string
19
+ description?: string
20
+ previewImgURL?: string
21
+ hidden?: boolean
22
+ recursive?: boolean
23
+ name?: string
24
+ docSpaceGroupId?: string
25
+ isAiEnabled?: boolean
26
+ isReviewSystemEnabled?: boolean
27
+ isBranchingSystemEnabled?: boolean
28
+ hostnamePart?: { hostname: string; hostnamePath: string }
29
+ spaceLinks?: { label: string; docSpaceId: string }[]
30
+ publicAccessControlPart?: Record<string, unknown>
31
+ }
32
+
33
+ const MDX_FORMAT_DESCRIPTION =
34
+ '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.'
9
35
 
10
36
  // Create an MCP server
11
37
  const server = new McpServer({
@@ -44,6 +70,217 @@ server.tool('search_title', { query: z.string() }, async ({ query }) => {
44
70
  return callMcpApi(params)
45
71
  })
46
72
 
73
+ // Write tools. The target space always comes from SPACE_ID — callMcpApi puts it
74
+ // on every request — so no tool takes a docSpaceId argument.
75
+
76
+ server.tool(
77
+ 'create_doc',
78
+ 'Create a new document in the Archbee doc space from Markdown or MDX content.',
79
+ {
80
+ content: z
81
+ .string()
82
+ .describe(
83
+ 'Body of the document to create, as Markdown or MDX text. JSON document content is not accepted.'
84
+ ),
85
+ format: z
86
+ .enum(['markdown', 'mdx'])
87
+ .optional()
88
+ .describe(MDX_FORMAT_DESCRIPTION),
89
+ title: z.string().optional().describe('Title of the document.'),
90
+ parentDocId: z
91
+ .string()
92
+ .optional()
93
+ .describe('ID of the parent document to nest this document under.'),
94
+ slug: z.string().optional().describe('URL slug for the document.'),
95
+ description: z
96
+ .string()
97
+ .optional()
98
+ .describe('Short description / summary of the document.'),
99
+ previewImgURL: z
100
+ .string()
101
+ .optional()
102
+ .describe('URL of the preview / social image for the document.'),
103
+ hidden: z
104
+ .boolean()
105
+ .optional()
106
+ .describe('When true, the document is hidden from navigation.'),
107
+ },
108
+ async (args) => callWriteApi({ tool: 'create-doc', ...args })
109
+ )
110
+
111
+ server.tool(
112
+ 'update_doc',
113
+ 'Update an existing Archbee document. Only the provided fields are changed.',
114
+ {
115
+ docId: z.string().describe('ID of the document to update.'),
116
+ content: z
117
+ .string()
118
+ .optional()
119
+ .describe(
120
+ 'New body for the document, as Markdown or MDX text. JSON document content is not accepted.'
121
+ ),
122
+ format: z
123
+ .enum(['markdown', 'mdx'])
124
+ .optional()
125
+ .describe(MDX_FORMAT_DESCRIPTION),
126
+ title: z.string().optional().describe('New title of the document.'),
127
+ parentDocId: z
128
+ .string()
129
+ .optional()
130
+ .describe('ID of the parent document to move this document under.'),
131
+ slug: z.string().optional().describe('New URL slug for the document.'),
132
+ description: z
133
+ .string()
134
+ .optional()
135
+ .describe('New short description / summary of the document.'),
136
+ previewImgURL: z
137
+ .string()
138
+ .optional()
139
+ .describe('New preview / social image URL for the document.'),
140
+ hidden: z
141
+ .boolean()
142
+ .optional()
143
+ .describe('When true, the document is hidden from navigation.'),
144
+ },
145
+ async (args) => callWriteApi({ tool: 'update-doc', ...args })
146
+ )
147
+
148
+ server.tool(
149
+ 'delete_doc',
150
+ '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.',
151
+ {
152
+ docId: z.string().describe('ID of the document to delete.'),
153
+ recursive: z
154
+ .boolean()
155
+ .optional()
156
+ .describe(
157
+ '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.'
158
+ ),
159
+ },
160
+ async (args) => callWriteApi({ tool: 'delete-doc', ...args })
161
+ )
162
+
163
+ server.tool(
164
+ 'create_doc_space',
165
+ 'Create a new doc space (documentation space) in the current Archbee team.',
166
+ {
167
+ name: z.string().describe('Name of the new doc space.'),
168
+ isReviewSystemEnabled: z
169
+ .boolean()
170
+ .optional()
171
+ .describe('Enable the review/approval workflow for the space.'),
172
+ isBranchingSystemEnabled: z
173
+ .boolean()
174
+ .optional()
175
+ .describe('Enable the branching (git-style) workflow for the space.'),
176
+ docSpaceGroupId: z
177
+ .string()
178
+ .optional()
179
+ .describe('ID of the collection/group to place the new space in.'),
180
+ },
181
+ async (args) => callWriteApi({ tool: 'create-doc-space', ...args })
182
+ )
183
+
184
+ // Mirrors PublicAPIUpdateDocSpaceRequestSchema in @archbee/data-access, which
185
+ // this standalone package cannot import. The API re-validates with the real
186
+ // schema, so this only has to describe the shape well enough for the model;
187
+ // publicAccessControlPart passes unknown keys through so newer access-control
188
+ // fields keep working without a release here.
189
+ const emailListSchema = z.array(z.object({ email: z.string() }))
190
+
191
+ const publicAccessControlPartSchema = z
192
+ .object({
193
+ publicProtectionTypes: z
194
+ .array(
195
+ z.enum([
196
+ 'None',
197
+ 'Password',
198
+ 'Guest accounts',
199
+ 'Private Accounts',
200
+ 'Private Link',
201
+ 'Magic Link',
202
+ 'JWT',
203
+ 'SAML',
204
+ 'OIDC',
205
+ ])
206
+ )
207
+ .optional(),
208
+ publicPassword: z.string().optional(),
209
+ publicGuestAccounts: z
210
+ .array(z.object({ email: z.string(), password: z.string() }))
211
+ .optional(),
212
+ publicMagicLinkAccounts: emailListSchema.optional(),
213
+ publicPrivateAccounts: emailListSchema.optional(),
214
+ jwtValidationType: z.string().optional(),
215
+ jwtKeyUrl: z.string().optional(),
216
+ jwtSecret: z.string().optional(),
217
+ jwtRedirectURL: z.string().optional(),
218
+ samlMetadata: z.string().optional(),
219
+ samlEntityId: z.string().optional(),
220
+ conditionalRuleId: z.string().optional(),
221
+ })
222
+ .passthrough()
223
+
224
+ server.tool(
225
+ 'update_doc_space',
226
+ 'Update settings of the Archbee doc space (hostname, space links, public access control). Only the provided parts are changed.',
227
+ {
228
+ hostnamePart: z
229
+ .object({ hostname: z.string(), hostnamePath: z.string() })
230
+ .optional()
231
+ .describe('Custom hostname configuration for the space.'),
232
+ spaceLinks: z
233
+ .array(z.object({ label: z.string(), docSpaceId: z.string() }))
234
+ .optional()
235
+ .describe(
236
+ 'Links to other spaces. The list should start with the current space.'
237
+ ),
238
+ publicAccessControlPart: publicAccessControlPartSchema
239
+ .optional()
240
+ .describe('Public access control and authentication configuration.'),
241
+ },
242
+ async (args) => callWriteApi({ tool: 'update-doc-space', ...args })
243
+ )
244
+
245
+ server.tool(
246
+ 'delete_doc_space',
247
+ 'Permanently delete the configured Archbee doc space together with every document inside it. This is destructive and cannot be undone. The space that gets deleted is the one SPACE_ID points at, so API_KEY is destroyed along with it and no further tool call will work. Ask the user to confirm before calling this tool.',
248
+ {},
249
+ async () => callWriteApi({ tool: 'delete-doc-space' })
250
+ )
251
+
252
+ server.tool(
253
+ 'create_space_group',
254
+ 'Create a new space group (collection of doc spaces) in the current Archbee team. Requires a team admin.',
255
+ {
256
+ name: z.string().describe('Name of the new space group.'),
257
+ isAiEnabled: z
258
+ .boolean()
259
+ .optional()
260
+ .describe('Enable AI features for the space group.'),
261
+ isReviewSystemEnabled: z
262
+ .boolean()
263
+ .optional()
264
+ .describe('Enable the review/approval workflow for the space group.'),
265
+ isBranchingSystemEnabled: z
266
+ .boolean()
267
+ .optional()
268
+ .describe(
269
+ 'Enable the branching (git-style) workflow for the space group.'
270
+ ),
271
+ },
272
+ async (args) => callWriteApi({ tool: 'create-space-group', ...args })
273
+ )
274
+
275
+ server.tool(
276
+ 'delete_space_group',
277
+ '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.',
278
+ {
279
+ docSpaceGroupId: z.string().describe('ID of the space group to delete.'),
280
+ },
281
+ async (args) => callWriteApi({ tool: 'delete-space-group', ...args })
282
+ )
283
+
47
284
  const processUrl = (urlInput: string): string | null => {
48
285
  try {
49
286
  const url = new URL(urlInput)
@@ -53,25 +290,27 @@ const processUrl = (urlInput: string): string | null => {
53
290
  : url.pathname + '/mcp'
54
291
 
55
292
  return url.toString()
56
- } catch (error) {
293
+ } catch {
57
294
  return null
58
295
  }
59
296
  }
60
297
 
61
- const callMcpApi = async (
62
- params: Record<string, any>
63
- ): Promise<CallToolResult> => {
298
+ const callMcpApi = async (params: McpApiParams): Promise<CallToolResult> => {
64
299
  const urlInput = process.env.API_BASE || ''
65
300
  const docSpaceIdInput = process.env.SPACE_ID || ''
66
301
 
67
302
  if (!urlInput && !docSpaceIdInput) {
68
303
  return {
69
304
  content: [{ type: 'text', text: 'API base URL or docSpaceId not set.' }],
305
+ isError: true,
70
306
  }
71
307
  }
72
308
 
73
309
  if (!process.env.API_KEY && !urlInput) {
74
- return { content: [{ type: 'text', text: 'API key not set.' }] }
310
+ return {
311
+ content: [{ type: 'text', text: 'API key not set.' }],
312
+ isError: true,
313
+ }
75
314
  }
76
315
 
77
316
  const urlMcp = urlInput
@@ -81,11 +320,12 @@ const callMcpApi = async (
81
320
  if (urlMcp === null) {
82
321
  return {
83
322
  content: [{ type: 'text', text: 'Invalid API base URL format.' }],
323
+ isError: true,
84
324
  }
85
325
  }
86
326
 
87
327
  try {
88
- let dataText: string = ''
328
+ let dataText: string
89
329
 
90
330
  if (docSpaceIdInput) {
91
331
  params.docSpaceId = docSpaceIdInput
@@ -97,11 +337,13 @@ const callMcpApi = async (
97
337
  Authorization: `Bearer ${base64Auth}`,
98
338
  'Content-Type': 'application/json',
99
339
  },
340
+ timeout: 30000,
100
341
  })
101
342
  dataText = JSON.stringify(response.data)
102
343
  } else {
103
344
  const response = await axios.get(urlMcp, {
104
345
  params,
346
+ timeout: 30000,
105
347
  })
106
348
  dataText = JSON.stringify(response.data)
107
349
  }
@@ -110,21 +352,111 @@ const callMcpApi = async (
110
352
  content: [{ type: 'text', text: dataText }],
111
353
  }
112
354
  } catch (error) {
355
+ const errorMessage = formatError(error)
356
+ console.error(`MCP API error: ${errorMessage}`)
357
+ return {
358
+ content: [{ type: 'text', text: errorMessage }],
359
+ isError: true,
360
+ }
361
+ }
362
+ }
363
+
364
+ // Writes only go through the SPACE_ID + API_KEY path: the API_BASE mode is an
365
+ // unauthenticated GET against a public portal, and the API refuses every write
366
+ // made with a PUBLISHED-/PREVIEW- snapshot credential. Both cases fail here with
367
+ // an explanation rather than as an opaque rejection from the server.
368
+ const callWriteApi = async (params: McpApiParams): Promise<CallToolResult> => {
369
+ const docSpaceIdInput = process.env.SPACE_ID || ''
370
+
371
+ if (!docSpaceIdInput || !process.env.API_KEY) {
372
+ return {
373
+ content: [
374
+ {
375
+ type: 'text',
376
+ text: 'Write tools need both SPACE_ID and API_KEY to be set. The API_BASE configuration is read-only.',
377
+ },
378
+ ],
379
+ isError: true,
380
+ }
381
+ }
382
+
383
+ if (
384
+ docSpaceIdInput.startsWith('PUBLISHED-') ||
385
+ docSpaceIdInput.startsWith('PREVIEW-')
386
+ ) {
113
387
  return {
114
388
  content: [
115
389
  {
116
390
  type: 'text',
117
- text: `Error in mcp: ${error} ${urlMcp} ${params}`,
391
+ text: 'SPACE_ID points at a published/preview snapshot, which cannot be written to. Set it to the live space id from the space URL in the Archbee app.',
118
392
  },
119
393
  ],
394
+ isError: true,
395
+ }
396
+ }
397
+
398
+ return callMcpApi(params)
399
+ }
400
+
401
+ const formatError = (error: unknown): string => {
402
+ if (axios.isAxiosError(error)) {
403
+ if (error.code === 'ECONNABORTED') {
404
+ return 'Request timeout - the server took too long to respond.'
405
+ }
406
+ if (error.code === 'ENOTFOUND' || error.code === 'ECONNREFUSED') {
407
+ return 'Connection failed - unable to reach the API server.'
120
408
  }
409
+ if (error.response) {
410
+ const status = error.response.status
411
+ if (status === 401 || status === 403) {
412
+ return 'Authentication failed - check your API key.'
413
+ }
414
+ if (status === 404) {
415
+ return 'Resource not found - check the document ID.'
416
+ }
417
+ if (status >= 500) {
418
+ return 'Server error - please try again later.'
419
+ }
420
+ return `API error (${status}): ${error.response.statusText}`
421
+ }
422
+ return `Network error: ${error.message}`
423
+ }
424
+ if (error instanceof Error) {
425
+ return error.message
121
426
  }
427
+ return 'An unexpected error occurred.'
122
428
  }
123
429
 
124
430
  const main = async () => {
125
- // Start receiving messages on stdin and sending messages on stdout
126
431
  const transport = new StdioServerTransport()
127
- await server.connect(transport)
432
+
433
+ // Handle graceful shutdown
434
+ const shutdown = async () => {
435
+ console.error('Shutting down MCP server...')
436
+ try {
437
+ await server.close()
438
+ } catch {
439
+ // Ignore close errors during shutdown
440
+ }
441
+ process.exit(0)
442
+ }
443
+
444
+ process.on('SIGINT', shutdown)
445
+ process.on('SIGTERM', shutdown)
446
+
447
+ try {
448
+ await server.connect(transport)
449
+ console.error('Archbee MCP server started successfully')
450
+ } catch (error) {
451
+ console.error(
452
+ 'Failed to start MCP server:',
453
+ error instanceof Error ? error.message : error
454
+ )
455
+ process.exit(1)
456
+ }
128
457
  }
129
458
 
130
- main()
459
+ main().catch((error) => {
460
+ console.error('Fatal error:', error instanceof Error ? error.message : error)
461
+ process.exit(1)
462
+ })
package/tsconfig.json DELETED
@@ -1,15 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "esModuleInterop": true,
4
- "module": "commonjs",
5
- "noImplicitReturns": true,
6
- "outDir": "dist",
7
- "sourceMap": true,
8
- "strict": true,
9
- "target": "es2019",
10
- "skipLibCheck": true,
11
- "skipDefaultLibCheck": true
12
- },
13
- "compileOnSave": true,
14
- "include": ["src"]
15
- }