Skip to main content
Glama

alexandrie-mcp

Model Context Protocol server for Alexandrie – the self-hosted, open-source Markdown knowledge base.

Let AI agents search, read, write and organize your knowledge base: documents, workspaces, categories, Kanban boards, sharing, files and backups.

CI License: MIT MCP

πŸ‡©πŸ‡ͺ Deutsche Anleitung Β· πŸ“š Tool reference Β· 🧩 MetaMCP guide Β· πŸ” Security


Features

  • 32 tools in 7 toolsets – orientation, full-text search, reading, surgical editing, Kanban, sharing, files, backups, admin stats.

  • Agent-friendly design – compact tree outlines, chunked reading, atomic find/replace & section edits, dry-run deletes, actionable errors.

  • Pixel-perfect documents – uses Alexandrie's own Markdown compiler (LaTeX, mermaid, containers, task lists, internal links).

  • Safe updates – read-merge-write for Alexandrie's full-replace PUT, optimistic concurrency with expected_updated_timestamp.

  • Two transports – stdio for local clients and MetaMCP STDIO, hardened Streamable HTTP for remote use / MetaMCP.

  • Security first – bearer auth, DNS-rebinding protection, rate limiting, read-only mode, toolset allow-list, no account-management tools, secret redaction.

  • Automatic session handling – cookie login, refresh, re-login, optional TOTP 2FA.

  • MCP resources & prompts – alexandrie://tree, alexandrie://node/{id}, Q&A / save / Kanban stand-up prompts.

  • Tested against a real Alexandrie backend; 66 unit tests + live integration test.

Related MCP server: secondbrain-mcp

Quick start

1. Service account

Create a dedicated Alexandrie user for your agents (e.g. ai-agent) via the sign-up page or an admin. Share the workspaces the agents may use with it. Do not use your personal admin account.

2FA? Set ALEXANDRIE_TOTP_SECRET to the base32 secret shown when enabling 2FA. SSO only? Native login must be enabled on the backend (CONFIG_DISABLE_NATIVE_LOGIN=false) for the service account.

2a. Local client (Claude Desktop, Cursor, VS Code, …) – stdio

{
  "mcpServers": {
    "alexandrie": {
      "command": "npx",
      "args": ["-y", "github:oliverhees/alexandrie-mcp"],
      "env": {
        "ALEXANDRIE_API_URL": "https://api.notes.example.com",
        "ALEXANDRIE_USERNAME": "ai-agent",
        "ALEXANDRIE_PASSWORD": "β€’β€’β€’β€’β€’β€’β€’β€’",
        "ALEXANDRIE_FRONTEND_URL": "https://notes.example.com"
      }
    }
  }
}

2b. Server / MetaMCP – Docker + Streamable HTTP

git clone https://github.com/oliverhees/alexandrie-mcp.git && cd alexandrie-mcp
cp .env.example .env && openssl rand -hex 32   # put the token into MCP_AUTH_TOKEN, fill ALEXANDRIE_*
docker compose -f docker-compose.example.yml up -d

Endpoint: http://alexandrie-mcp:3000/mcp with header Authorization: Bearer <MCP_AUTH_TOKEN>. Full walkthrough: docs/METAMCP.md.

2c. From source

npm ci && npm run build
ALEXANDRIE_API_URL=http://localhost:8201 ALEXANDRIE_USERNAME=ai-agent ALEXANDRIE_PASSWORD=… node dist/index.js
# or: node dist/index.js --transport http --port 3000   (needs MCP_AUTH_TOKEN)

Inspect interactively: npm run inspector.

Configuration

All settings are environment variables (see .env.example). Every secret also accepts a <NAME>_FILE variant for Docker/Kubernetes secrets.

Variable

Default

Description

ALEXANDRIE_API_URL

– (required)

Backend URL (API, default port 8201). A trailing /api is fine.

ALEXANDRIE_USERNAME / ALEXANDRIE_PASSWORD

– (required)

Service account.

ALEXANDRIE_TOTP_SECRET

–

Base32 TOTP secret if the account uses 2FA.

ALEXANDRIE_FRONTEND_URL

–

Enables clickable app_url / public_url in results.

ALEXANDRIE_CDN_URL / ALEXANDRIE_CDN_ENDPOINT

– / /alexandrie/

Public S3 URL + bucket path for direct file links.

ALEXANDRIE_READ_ONLY

false

Expose only read tools.

ALEXANDRIE_ALLOW_DESTRUCTIVE

true

Expose delete / revoke tools.

ALEXANDRIE_TOOLSETS

all but admin

nodes,search,kanban,sharing,resources,backup,admin or all.

ALEXANDRIE_MAX_CONTENT_CHARS

100000

Max characters of content per response.

ALEXANDRIE_MAX_UPLOAD_BYTES

20971520

Upload limit (Alexandrie default is 20 MB).

ALEXANDRIE_TIMEOUT_MS

30000

Timeout per backend request.

ALEXANDRIE_ALLOW_INSECURE_HTTP

false

Allow http:// for non-local backends.

MCP_TRANSPORT

stdio

stdio or http.

MCP_HTTP_HOST / MCP_HTTP_PORT / MCP_HTTP_PATH

127.0.0.1 / 3000 / /mcp

HTTP listener (Docker image: 0.0.0.0).

MCP_AUTH_TOKEN

– (required for http)

Bearer token, β‰₯ 32 chars.

MCP_ALLOW_UNAUTHENTICATED

false

Only if another layer authenticates.

MCP_ALLOWED_HOSTS

loopback only when bound to loopback

Host-header allow-list.

MCP_ALLOWED_ORIGINS

–

Browser origins allowed (* for any).

MCP_STATELESS

false

No sessions; each POST is independent.

MCP_SESSION_TTL_SECONDS / MCP_MAX_SESSIONS

1800 / 100

Session store bounds.

MCP_RATE_LIMIT_PER_MINUTE

300

Per client IP, 0 disables.

MCP_TRUST_PROXY

false

Use X-Forwarded-For for rate limiting.

LOG_LEVEL

info

debug, info, warn, error, silent (logs β†’ stderr, JSON).

HTTP endpoints: POST/GET/DELETE /mcp, GET /healthz (liveness), GET /readyz (Alexandrie login works).

Tools

Toolset

Tools

nodes

whoami, get_tree, list_nodes, get_node, get_breadcrumbs, list_tags, read_subtree, create_document, create_container, update_node, edit_content, move_node, duplicate_node, delete_node

search

search

kanban

kanban_get_board, kanban_create_card, kanban_move_card, kanban_manage_columns, kanban_assign

sharing

find_user, list_permissions, share_node, update_permission, revoke_permission, manage_invitations, join_invitation

resources

upload_file, get_file

backup

start_backup, get_backup_status, cancel_backup

admin (opt-in)

admin_stats, admin_list_users

All tool names are prefixed with alexandrie_. Details, parameters and recommended agent workflows: docs/TOOLS.md.

Architecture

MCP client / MetaMCP ──stdio | Streamable HTTP──▢ alexandrie-mcp ──HTTPS + session cookie──▢ Alexandrie backend (Go) ──▢ MySQL / S3
                                                     β”‚
                                                     β”œβ”€ tools/       zod-validated tools, gated by toolset & safety flags
                                                     β”œβ”€ services/    tree, read-merge-write, Kanban, content edits
                                                     β”œβ”€ markdown/    Alexandrie's Markdown compiler (vendored, MIT)
                                                     └─ alexandrie/  API client: login, refresh, TOTP, retries, errors

Development

npm ci
npm run lint && npm run typecheck && npm test
npm run test:coverage
# Live test against a real backend (creates & deletes a temporary workspace):
ALEXANDRIE_IT_URL=http://localhost:8201 ALEXANDRIE_IT_USERNAME=… ALEXANDRIE_IT_PASSWORD=… npm run test:integration

See CONTRIBUTING.md. Compatible with Alexandrie's current API (/api/nodes, /api/resources, /api/backup, …).

License

MIT Β© Oliver Hees / Aiianer and contributors. Includes Alexandrie's Markdown compiler (MIT Β© 2021 Alexandrie) – see THIRD_PARTY_NOTICES.md. This is a community project and not affiliated with the Alexandrie maintainers.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      B
      maintenance
      A self-hosted Markdown knowledge base and Agent Harness with an MCP server that enables AI agents to read and write notes, providing persistent memory and a shared workspace for multi-agent collaboration.
      2
      MIT
    • A
      license
      B
      quality
      B
      maintenance
      Enables AI agents to securely read, search, and write to a local Markdown knowledge base with hybrid RAG retrieval, privacy zones, hash-locked writes, audit logging, and rollback-safe archiving.
      13
      MIT