bookstack-mcp 3.3.0 → 3.3.2
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 +52 -3
- package/dist/bookstack-client.js +34 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -135,16 +135,65 @@ When binding to `0.0.0.0` (e.g. inside a container reachable from other services
|
|
|
135
135
|
|
|
136
136
|
Restart LibreChat after config changes.
|
|
137
137
|
|
|
138
|
-
### Claude Code (
|
|
138
|
+
### Claude Code (CLI)
|
|
139
139
|
|
|
140
|
-
|
|
140
|
+
The recommended path is the `ttpears/claude-plugins` marketplace, which ships this repo's plugin manifest (`.claude-plugin/plugin.json`):
|
|
141
141
|
|
|
142
142
|
```
|
|
143
143
|
/plugin marketplace add ttpears/claude-plugins
|
|
144
144
|
/plugin install bookstack-mcp@ttpears-plugins
|
|
145
145
|
```
|
|
146
146
|
|
|
147
|
-
Then set the `BOOKSTACK_*` environment variables in your shell so the plugin's MCP server can authenticate
|
|
147
|
+
Then set the `BOOKSTACK_*` environment variables in your shell so the plugin's MCP server can authenticate:
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
export BOOKSTACK_BASE_URL=https://your-bookstack.com
|
|
151
|
+
export BOOKSTACK_TOKEN_ID=your-token-id
|
|
152
|
+
export BOOKSTACK_TOKEN_SECRET=your-token-secret
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
#### Manual install (alternative)
|
|
156
|
+
|
|
157
|
+
If you'd rather not use the marketplace, register the server directly with `claude mcp add`. Repeat `--env` for each variable, put all flags **before** the server name, and use `--` to mark the start of the command Claude Code will spawn:
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
claude mcp add bookstack \
|
|
161
|
+
--transport stdio \
|
|
162
|
+
--scope user \
|
|
163
|
+
--env BOOKSTACK_BASE_URL=https://your-bookstack.com \
|
|
164
|
+
--env BOOKSTACK_TOKEN_ID=your-token-id \
|
|
165
|
+
--env BOOKSTACK_TOKEN_SECRET=your-token-secret \
|
|
166
|
+
-- npx -y bookstack-mcp
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
Scope picks where the entry is written:
|
|
170
|
+
|
|
171
|
+
| Scope | Where it lives | Shared via git | Use it when |
|
|
172
|
+
|-------|----------------|----------------|-------------|
|
|
173
|
+
| `local` (default) | `~/.claude.json`, scoped to the current project | No | Trying it out in one repo |
|
|
174
|
+
| `user` | `~/.claude.json`, available in every project | No | You want bookstack everywhere |
|
|
175
|
+
| `project` | `.mcp.json` at the repo root | Yes | The whole team should get it |
|
|
176
|
+
|
|
177
|
+
The resulting config entry looks like this (in `.mcp.json` for project scope, or `~/.claude.json` otherwise):
|
|
178
|
+
|
|
179
|
+
```json
|
|
180
|
+
{
|
|
181
|
+
"mcpServers": {
|
|
182
|
+
"bookstack": {
|
|
183
|
+
"type": "stdio",
|
|
184
|
+
"command": "npx",
|
|
185
|
+
"args": ["-y", "bookstack-mcp"],
|
|
186
|
+
"env": {
|
|
187
|
+
"BOOKSTACK_BASE_URL": "https://your-bookstack.com",
|
|
188
|
+
"BOOKSTACK_TOKEN_ID": "your-token-id",
|
|
189
|
+
"BOOKSTACK_TOKEN_SECRET": "your-token-secret"
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
> **Tip for committed `.mcp.json`:** Claude Code expands `${VAR}` and `${VAR:-default}` references in `.mcp.json` from the surrounding shell. Use that to keep secrets out of git: set `"BOOKSTACK_TOKEN_SECRET": "${BOOKSTACK_TOKEN_SECRET}"` in the file and have each developer export the variable in their shell.
|
|
148
197
|
|
|
149
198
|
## MCP Resources
|
|
150
199
|
|
package/dist/bookstack-client.js
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
import axios from 'axios';
|
|
2
2
|
import https from 'https';
|
|
3
|
+
const MAX_RETRIES_429 = 5;
|
|
4
|
+
function parseRetryAfter(value) {
|
|
5
|
+
if (typeof value !== 'string' || !value)
|
|
6
|
+
return null;
|
|
7
|
+
const seconds = Number(value);
|
|
8
|
+
if (Number.isFinite(seconds))
|
|
9
|
+
return Math.max(0, seconds * 1000);
|
|
10
|
+
const dateMs = Date.parse(value);
|
|
11
|
+
if (Number.isFinite(dateMs))
|
|
12
|
+
return Math.max(0, dateMs - Date.now());
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
3
15
|
export class BookStackClient {
|
|
4
16
|
client;
|
|
5
17
|
enableWrite;
|
|
@@ -18,6 +30,20 @@ export class BookStackClient {
|
|
|
18
30
|
? new https.Agent({ rejectUnauthorized: false })
|
|
19
31
|
: undefined
|
|
20
32
|
});
|
|
33
|
+
this.client.interceptors.response.use(undefined, async (error) => {
|
|
34
|
+
const cfg = error.config;
|
|
35
|
+
if (!cfg || error.response?.status !== 429)
|
|
36
|
+
throw error;
|
|
37
|
+
cfg.__retry429 = (cfg.__retry429 ?? 0) + 1;
|
|
38
|
+
if (cfg.__retry429 > MAX_RETRIES_429)
|
|
39
|
+
throw error;
|
|
40
|
+
const retryAfter = parseRetryAfter(error.response.headers?.['retry-after']);
|
|
41
|
+
const backoff = Math.min(30000, 1000 * 2 ** (cfg.__retry429 - 1));
|
|
42
|
+
const delay = retryAfter ?? backoff;
|
|
43
|
+
console.error(`BookStack rate limited (429); retry ${cfg.__retry429}/${MAX_RETRIES_429} in ${delay}ms`);
|
|
44
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
45
|
+
return this.client.request(cfg);
|
|
46
|
+
});
|
|
21
47
|
}
|
|
22
48
|
applyFilters(params, filter) {
|
|
23
49
|
if (!filter)
|
|
@@ -92,8 +118,11 @@ export class BookStackClient {
|
|
|
92
118
|
const slice = fullContent.substring(offset, offset + limit);
|
|
93
119
|
const nextOffset = offset + slice.length;
|
|
94
120
|
const truncated = nextOffset < totalChars;
|
|
95
|
-
// Strip duplicate large fields from the base page object
|
|
96
|
-
|
|
121
|
+
// Strip duplicate large fields from the base page object. raw_html is the
|
|
122
|
+
// unprocessed editor source BookStack returns alongside html/markdown/text;
|
|
123
|
+
// leaving it in would bypass the limit/offset pagination and can blow past
|
|
124
|
+
// MCP token caps for large pages.
|
|
125
|
+
const { html: _h, markdown: _m, text: _t, raw_html: _r, ...pageMeta } = page;
|
|
97
126
|
return {
|
|
98
127
|
...pageMeta,
|
|
99
128
|
url,
|
|
@@ -265,9 +294,9 @@ export class BookStackClient {
|
|
|
265
294
|
const preview = page.text
|
|
266
295
|
? `${page.text.substring(0, 200)}${page.text.length > 200 ? '...' : ''}`
|
|
267
296
|
: 'No content preview available';
|
|
268
|
-
// List responses from BookStack don't include html/markdown/text, but strip
|
|
269
|
-
// and never embed full content here — use get_page for that.
|
|
270
|
-
const { html: _h, markdown: _m, text: _t, ...pageMeta } = page;
|
|
297
|
+
// List responses from BookStack don't include html/markdown/text/raw_html, but strip
|
|
298
|
+
// defensively and never embed full content here — use get_page for that.
|
|
299
|
+
const { html: _h, markdown: _m, text: _t, raw_html: _r, ...pageMeta } = page;
|
|
271
300
|
return {
|
|
272
301
|
...pageMeta,
|
|
273
302
|
url,
|