|
@@ -17,13 +17,15 @@ This MCP server enables AI assistants to interact with WikiJS instances by provi
|
|
|
```bash
|
|
```bash
|
|
|
# NOTE: the binary is named wikijs-mcp-edit, not after the package name:
|
|
# NOTE: the binary is named wikijs-mcp-edit, not after the package name:
|
|
|
npx -p @cahaseler/wikijs-mcp wikijs-mcp-edit
|
|
npx -p @cahaseler/wikijs-mcp wikijs-mcp-edit
|
|
|
|
|
+# pnpm equivalent (pnpx is a deprecated alias of pnpm dlx):
|
|
|
|
|
+pnpm dlx @cahaseler/wikijs-mcp wikijs-mcp-edit
|
|
|
```
|
|
```
|
|
|
This always runs the *latest published* version from npm. For the current feature branch (see git remote), build from source instead.
|
|
This always runs the *latest published* version from npm. For the current feature branch (see git remote), build from source instead.
|
|
|
|
|
|
|
|
### From source
|
|
### From source
|
|
|
```bash
|
|
```bash
|
|
|
-git clone <your-clone-url>
|
|
|
|
|
-cd wikijs-mcp
|
|
|
|
|
|
|
+git clone ssh://git@gogs.netdome.biz:10022/netdome/wikijs-mcp-server-cahaseler.git
|
|
|
|
|
+cd wikijs-mcp-server-cahaseler
|
|
|
pnpm install # or: npm install
|
|
pnpm install # or: npm install
|
|
|
pnpm run build # or: npm run build
|
|
pnpm run build # or: npm run build
|
|
|
```
|
|
```
|
|
@@ -132,6 +134,59 @@ Add to your Claude Desktop configuration:
|
|
|
| `WIKIJS_API_KEY` | WikiJS API key | Yes | - |
|
|
| `WIKIJS_API_KEY` | WikiJS API key | Yes | - |
|
|
|
| `WIKIJS_ENABLE_EDIT` | Enable page editing functionality | No | false |
|
|
| `WIKIJS_ENABLE_EDIT` | Enable page editing functionality | No | false |
|
|
|
| `WIKIJS_DEFAULT_LOCALE` | Locale used when building page URLs | No | en |
|
|
| `WIKIJS_DEFAULT_LOCALE` | Locale used when building page URLs | No | en |
|
|
|
|
|
+| `WIKIJS_MCP_TRANSPORT` | `stdio` (client spawns the server) or `http` (Streamable HTTP listener; see below) | No | stdio |
|
|
|
|
|
+| `WIKIJS_MCP_HOST` | Bind address for the HTTP listener | **Yes when `WIKIJS_MCP_TRANSPORT=http`** — there is no default on purpose | - |
|
|
|
|
|
+| `WIKIJS_MCP_PORT` | Port for the HTTP listener | No | 3001 |
|
|
|
|
|
+| `WIKIJS_MCP_BEARER_TOKEN` | Bearer token protecting the HTTP listener | **Yes for non-loopback binds** (see below) | - |
|
|
|
|
|
+
|
|
|
|
|
+## Streamable HTTP transport (container / server mode)
|
|
|
|
|
+
|
|
|
|
|
+Use stdio only when your MCP client spawns the server process itself. To run
|
|
|
|
|
+the server next to Wiki.js in a container (client connects over the network),
|
|
|
|
|
+use the Streamable HTTP transport (MCP spec compliant, stateful sessions):
|
|
|
|
|
+
|
|
|
|
|
+```bash
|
|
|
|
|
+WIKIJS_URL=http://wiki:3000 WIKIJS_API_KEY=your-key \
|
|
|
|
|
+WIKIJS_MCP_TRANSPORT=http WIKIJS_MCP_HOST=0.0.0.0 WIKIJS_MCP_PORT=3001 \
|
|
|
|
|
+WIKIJS_MCP_BEARER_TOKEN=choose-a-long-random-token \
|
|
|
|
|
+node build/index.js
|
|
|
|
|
+```
|
|
|
|
|
+
|
|
|
|
|
+Startup logs the exact listener: `WikiJS MCP server listening on http://0.0.0.0:3001/mcp`.
|
|
|
|
|
+
|
|
|
|
|
+Endpoints: `POST/GET/DELETE /mcp` (MCP Streamable HTTP), `GET /health`
|
|
|
|
|
+(liveness probe, no auth). HTTP clients connect to `http://<host>:<port>/mcp`
|
|
|
|
|
+and must send `Authorization: Bearer <token>` on every request.
|
|
|
|
|
+
|
|
|
|
|
+**Startup validation — the server refuses to start otherwise:**
|
|
|
|
|
+- `WIKIJS_MCP_TRANSPORT=http` without `WIKIJS_MCP_HOST` → exit
|
|
|
|
|
+- Non-loopback `WIKIJS_MCP_HOST` (e.g. `0.0.0.0`) without `WIKIJS_MCP_BEARER_TOKEN` → exit
|
|
|
|
|
+
|
|
|
|
|
+A token is optional **only** for loopback binds (`127.0.0.1`, `localhost`, `::1`).
|
|
|
|
|
+
|
|
|
|
|
+OpenCode remote-MCP config (`opencode.json`):
|
|
|
|
|
+
|
|
|
|
|
+```json
|
|
|
|
|
+{
|
|
|
|
|
+ "mcp": {
|
|
|
|
|
+ "wikijs": {
|
|
|
|
|
+ "type": "remote",
|
|
|
|
|
+ "url": "http://wikijs-mcp:3001/mcp",
|
|
|
|
|
+ "oauth": false,
|
|
|
|
|
+ "headers": {
|
|
|
|
|
+ "Authorization": "Bearer choose-a-long-random-token"
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+```
|
|
|
|
|
+
|
|
|
|
|
+(`oauth: false` disables OpenCode's automatic OAuth discovery — the bearer
|
|
|
|
|
+token is passed explicitly via `headers` instead; secrets can also reference
|
|
|
|
|
+environment variables, e.g. `"Bearer {env:WIKIJS_MCP_BEARER_TOKEN}"`.)
|
|
|
|
|
+
|
|
|
|
|
+The CLI flag `--transport stdio|http` overrides `WIKIJS_MCP_TRANSPORT`
|
|
|
|
|
+(subject to the same host/token validation).
|
|
|
|
|
|
|
|
## Available Tools
|
|
## Available Tools
|
|
|
|
|
|
|
@@ -184,8 +239,8 @@ Once configured, the following tools will be available (10 read / 6 write):
|
|
|
|
|
|
|
|
1. Clone the repository:
|
|
1. Clone the repository:
|
|
|
```bash
|
|
```bash
|
|
|
-git clone https://github.com/cahaseler/wikijs-mcp.git
|
|
|
|
|
-cd wikijs-mcp
|
|
|
|
|
|
|
+git clone ssh://git@gogs.netdome.biz:10022/netdome/wikijs-mcp-server-cahaseler.git
|
|
|
|
|
+cd wikijs-mcp-server-cahaseler
|
|
|
```
|
|
```
|
|
|
|
|
|
|
|
2. Install dependencies (pnpm primary, npm works too):
|
|
2. Install dependencies (pnpm primary, npm works too):
|
|
@@ -205,13 +260,27 @@ cp env.example .env
|
|
|
To run a local WikiJS instance for testing:
|
|
To run a local WikiJS instance for testing:
|
|
|
|
|
|
|
|
```bash
|
|
```bash
|
|
|
-# Start WikiJS and PostgreSQL
|
|
|
|
|
-docker-compose up -d
|
|
|
|
|
|
|
+# Start WikiJS and PostgreSQL (also brings up the mcp service — see below)
|
|
|
|
|
+docker compose up -d
|
|
|
|
|
+
|
|
|
|
|
+# Start only WikiJS and PostgreSQL:
|
|
|
|
|
+docker compose up -d db wiki
|
|
|
|
|
|
|
|
# The instance will be available at http://localhost:3000
|
|
# The instance will be available at http://localhost:3000
|
|
|
# Follow the setup wizard to create an admin account
|
|
# Follow the setup wizard to create an admin account
|
|
|
```
|
|
```
|
|
|
|
|
|
|
|
|
|
+The `mcp` service in `docker-compose.yml` runs the built server in HTTP mode
|
|
|
|
|
+next to the wiki instance:
|
|
|
|
|
+
|
|
|
|
|
+```bash
|
|
|
|
|
+WIKIJS_MCP_BEARER_TOKEN=choose-a-long-random-token \
|
|
|
|
|
+WIKIJS_API_KEY=<key-from-wiki> \
|
|
|
|
|
+docker compose up -d mcp
|
|
|
|
|
+# -> MCP listener on http://localhost:3001/mcp (port published 3001:3001)
|
|
|
|
|
+```
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
### Building
|
|
### Building
|
|
|
```bash
|
|
```bash
|
|
|
pnpm run build # or: npm run build
|
|
pnpm run build # or: npm run build
|
|
@@ -223,15 +292,24 @@ make build
|
|
|
|
|
|
|
|
### Testing the MCP Server
|
|
### Testing the MCP Server
|
|
|
|
|
|
|
|
-The server is a stdio MCP server — it is started *by* an MCP client, not manually as a daemon.
|
|
|
|
|
|
|
+The default transport is stdio — it is started *by* an MCP client, not manually as a daemon. For the HTTP listener see ["Streamable HTTP transport"](#streamable-http-transport-container--server-mode) above.
|
|
|
|
|
|
|
|
```bash
|
|
```bash
|
|
|
# Quick smoke without a wiki connection: expect output = version from package.json
|
|
# Quick smoke without a wiki connection: expect output = version from package.json
|
|
|
node build/index.js --version
|
|
node build/index.js --version
|
|
|
|
|
|
|
|
-# Run it manually (it then waits, silently, for MCP protocol frames on stdio):
|
|
|
|
|
|
|
+# Run it manually in stdio mode (it then waits, silently, for MCP protocol frames on stdin):
|
|
|
WIKIJS_URL=http://localhost:3000 WIKIJS_API_KEY=your-key node build/index.js
|
|
WIKIJS_URL=http://localhost:3000 WIKIJS_API_KEY=your-key node build/index.js
|
|
|
|
|
|
|
|
|
|
+# Same, but explicit about the transport flag:
|
|
|
|
|
+WIKIJS_URL=http://localhost:3000 WIKIJS_API_KEY=your-key node build/index.js --transport stdio
|
|
|
|
|
+
|
|
|
|
|
+# Run the HTTP listener locally (loopback, no token required):
|
|
|
|
|
+WIKIJS_URL=http://localhost:3000 WIKIJS_API_KEY=your-key \
|
|
|
|
|
+WIKIJS_MCP_TRANSPORT=http WIKIJS_MCP_HOST=127.0.0.1 \
|
|
|
|
|
+node build/index.js
|
|
|
|
|
+# -> WikiJS MCP server listening on http://127.0.0.1:3001/mcp
|
|
|
|
|
+
|
|
|
# The built server auto-loads .env from the current working directory (dotenv),
|
|
# The built server auto-loads .env from the current working directory (dotenv),
|
|
|
# so from the repo root this is sufficient: node build/index.js — provided
|
|
# so from the repo root this is sufficient: node build/index.js — provided
|
|
|
# you created .env via the Setup steps above. Note: env variables take
|
|
# you created .env via the Setup steps above. Note: env variables take
|
|
@@ -243,12 +321,16 @@ npx @modelcontextprotocol/inspector node build/index.js # pnpm: pnpm dlx @m
|
|
|
|
|
|
|
|
Missing env vars abort the server immediately with
|
|
Missing env vars abort the server immediately with
|
|
|
`WIKIJS_URL and WIKIJS_API_KEY must be set` on stderr.
|
|
`WIKIJS_URL and WIKIJS_API_KEY must be set` on stderr.
|
|
|
|
|
+HTTP mode aborts when `WIKIJS_MCP_HOST` is missing or a non-loopback bind
|
|
|
|
|
+has no `WIKIJS_MCP_BEARER_TOKEN`.
|
|
|
|
|
|
|
|
## Security Considerations
|
|
## Security Considerations
|
|
|
|
|
|
|
|
- **API Key Storage**: Never commit your API key to version control
|
|
- **API Key Storage**: Never commit your API key to version control
|
|
|
- **Edit Permissions**: The edit functionality is disabled by default. Only enable it if you trust the environment where the MCP server is running
|
|
- **Edit Permissions**: The edit functionality is disabled by default. Only enable it if you trust the environment where the MCP server is running
|
|
|
- **Scope Permissions**: When creating the WikiJS API key, consider using the minimum required permissions instead of full access
|
|
- **Scope Permissions**: When creating the WikiJS API key, consider using the minimum required permissions instead of full access
|
|
|
|
|
+- **HTTP transport auth**: A non-loopback HTTP bind requires `WIKIJS_MCP_BEARER_TOKEN` — the server refuses to start otherwise. Even with a token, prefer exposing the listener only to the network segment that needs it (container network, not the host's public interfaces)
|
|
|
|
|
+- **HTTP transport token scope**: The bearer token protects the MCP endpoint itself; it is separate from the WikiJS API key
|
|
|
|
|
|
|
|
## Troubleshooting
|
|
## Troubleshooting
|
|
|
|
|
|