bookstack-mcp 5.4.0 → 5.4.1

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
@@ -15,6 +15,8 @@ A [Model Context Protocol](https://modelcontextprotocol.io) (MCP) server that gi
15
15
  npx bookstack-mcp
16
16
  ```
17
17
 
18
+ Field notes: [Why my BookStack MCP server starts read-only](https://hackyourworld.com/bookstack-mcp-server-read-only-by-default/) covers the shared-token rate-limit failure, process-wide cache, response-size measurements, and permission boundaries that shaped the current design.
19
+
18
20
  ## Features
19
21
 
20
22
  - 20 read-only tools + 20 write tools for complete BookStack API coverage
package/dist/index.js CHANGED
@@ -875,6 +875,9 @@ async function startHttp(config) {
875
875
  res.writeHead(status, { "Content-Type": "application/json" });
876
876
  res.end(JSON.stringify(body));
877
877
  };
878
+ // A session id is bearer-equivalent: anyone holding it can drive the session. Log only
879
+ // a prefix — enough to correlate a session's life across lines, not enough to replay.
880
+ const shortSid = (sid) => `${sid.slice(0, 8)}...`;
878
881
  const httpServer = createHttpServer(async (req, res) => {
879
882
  try {
880
883
  const hostError = validateHost(req);
@@ -919,7 +922,22 @@ async function startHttp(config) {
919
922
  }
920
923
  transport = sessions.get(sessionId);
921
924
  }
922
- else if (!sessionId && req.method === "POST" && isInitializeRequest(parsedBody)) {
925
+ else if (sessionId) {
926
+ // The session was terminated (idle sweep, or a restart — sessions are held in
927
+ // process memory only). MCP's Streamable HTTP spec, Session Management §3:
928
+ // the server "MUST respond to requests containing that session ID with HTTP
929
+ // 404 Not Found", and §4 makes 404 the one signal that tells a client to
930
+ // re-initialize. Answering 400 here leaves the client no defined recovery, so
931
+ // the connector stays down until a human reconnects it.
932
+ console.error(`[mcp] ${req.method} session ${shortSid(sessionId)} not found -> 404 (client should re-initialize); live=${sessions.size()}`);
933
+ sendJson(res, 404, {
934
+ jsonrpc: "2.0",
935
+ error: { code: -32001, message: "Session not found" },
936
+ id: null
937
+ });
938
+ return;
939
+ }
940
+ else if (req.method === "POST" && isInitializeRequest(parsedBody)) {
923
941
  if (sessions.atCapacity()) {
924
942
  sendJson(res, 503, {
925
943
  jsonrpc: "2.0",
@@ -936,12 +954,15 @@ async function startHttp(config) {
936
954
  sessionIdGenerator: () => randomUUID(),
937
955
  onsessioninitialized: (sid) => {
938
956
  sessions.register(sid, transport, config.oauth && auth ? auth : undefined);
957
+ console.error(`[mcp] session ${shortSid(sid)} initialized; live=${sessions.size()}`);
939
958
  }
940
959
  });
941
960
  transport.onclose = () => {
942
961
  const sid = transport.sessionId;
943
- if (sid)
962
+ if (sid) {
944
963
  sessions.delete(sid);
964
+ console.error(`[mcp] session ${shortSid(sid)} closed; live=${sessions.size()}`);
965
+ }
945
966
  };
946
967
  const server = buildServer(sessionConfig);
947
968
  await server.connect(transport);
@@ -369,6 +369,17 @@ export async function handleOAuthRoutes(req, res, cfg) {
369
369
  }),
370
370
  });
371
371
  const refreshJson = await refreshRes.json().catch(() => null);
372
+ if (refreshRes.ok) {
373
+ // Never log the body here: on success it carries the access and refresh tokens.
374
+ console.error("[oauth] /token refresh_token: OK");
375
+ }
376
+ else {
377
+ // A failed refresh is what a user experiences as the connector going away, so it
378
+ // has to be visible. Only Entra's error code and description are logged; a failure
379
+ // response carries no token material.
380
+ console.error(`[oauth] /token refresh_token: FAILED status=${refreshRes.status} ` +
381
+ `error=${refreshJson?.error ?? "unknown"} desc=${(refreshJson?.error_description ?? "").slice(0, 300)}`);
382
+ }
372
383
  sendJson(res, refreshRes.ok ? 200 : 400, refreshJson ?? { error: "invalid_grant" });
373
384
  return true;
374
385
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bookstack-mcp",
3
- "version": "5.4.0",
3
+ "version": "5.4.1",
4
4
  "description": "MCP server for BookStack wiki — search, read, create, and manage documentation via AI assistants",
5
5
  "type": "module",
6
6
  "bin": {