Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 39 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -295,12 +295,45 @@ Check logs for error messages:

## Architecture

Built with modern MCP patterns:
- `McpServer` from `@modelcontextprotocol/sdk/server/mcp.js`
- `registerTool()` API with Zod schemas
- Stdio transport for local/LibreChat use
- Monorepo: `packages/core` (native fetch client), `packages/stdio` (MCP server entry)
- Type-safe with TypeScript 5.3+
### Actors

| Actor | Role |
|-------|------|
| **MCP Client** (Claude Desktop, LibreChat, etc.) | Sends tool-call requests over stdio; receives structured JSON responses |
| **bookstack-mcp server** (`packages/stdio`) | Validates inputs with Zod, dispatches to the BookStack API client, formats responses |
| **BookStack API client** (`packages/core`) | Authenticates with the BookStack instance, makes HTTP requests, enhances responses |
| **BookStack instance** | Stores and serves documentation content via its REST API |
| **Operator** | Configures environment variables (`BOOKSTACK_BASE_URL`, tokens, `BOOKSTACK_ENABLE_WRITE`) |

### Data flow

```
MCP Client (Claude Desktop / LibreChat / Smithery)
β”‚ stdio: tool list request / tool call
β–Ό
packages/stdio β€” McpServer
β”‚ Zod input validation β†’ registered tool handler
β–Ό
packages/core β€” BookStackClient (native fetch)
β”‚ HTTPS + Token auth β†’ BookStack REST API
β–Ό
BookStack instance
β”‚ JSON response
β–Ό
BookStackClient β€” response enhancement (URLs, previews, dates, word counts)
β–Ό
packages/stdio β€” JSON serialised as MCP tool result
β–Ό
MCP Client
```

### Key design decisions

- **Native fetch** β€” no axios; HTTP errors surface as `error.status` / `error.response`
- **Stdio transport** β€” single universal transport for local, LibreChat, and Claude Desktop use
- **Zod schemas** β€” all MCP tool inputs validated before the API is called
- **Write-gate** β€” write tools are only registered when `BOOKSTACK_ENABLE_WRITE=true`
- **Monorepo** β€” `packages/core` has no runtime dependencies; `packages/stdio` depends on core and the MCP SDK

## Dependency Management

Expand Down